Exemplo n.º 1
0
def create_heartbeat():

    # Create a new heartbeat
    try:
        heartbeat = Heartbeat.parse_heartbeat(request.data)
    except Exception, e:
        return jsonify(response={"status": "error", "message": str(e)})
Exemplo n.º 2
0
    def on_message(self, headers, body):

        if 'type' not in headers or 'correlation-id' not in headers:
            LOG.warning(
                'Malformed header missing "type" or "correlation-id": %s',
                headers)
            self.statsd.metric_send('alerta.alerts.rejected', 1)
            return

        LOG.info("Received %s %s", headers['type'], headers['correlation-id'])
        LOG.debug("Received body : %s", body)

        if headers['type'] == 'Heartbeat':
            heartbeat = Heartbeat.parse_heartbeat(body)
            if heartbeat:
                heartbeat.receive_now()
                LOG.debug('Queueing successfully parsed heartbeat %s',
                          heartbeat.get_body())
                self.queue.put(heartbeat)
        else:
            try:
                alert = Alert.parse_alert(body)
            except ValueError:
                self.statsd.metric_send('alerta.alerts.rejected', 1)
                return
            if alert:
                alert.receive_now()
                LOG.debug('Queueing successfully parsed alert %s',
                          alert.get_body())
                self.queue.put(alert)
Exemplo n.º 3
0
    def on_message(self, headers, body):

        if 'type' not in headers or 'correlation-id' not in headers:
            LOG.warning('Malformed header missing "type" or "correlation-id": %s', headers)
            self.statsd.metric_send('alerta.alerts.rejected', 1)
            return

        LOG.info("Received %s %s", headers['type'], headers['correlation-id'])
        LOG.debug("Received body : %s", body)

        if headers['type'] == 'Heartbeat':
            heartbeat = Heartbeat.parse_heartbeat(body)
            if heartbeat:
                heartbeat.receive_now()
                LOG.debug('Queueing successfully parsed heartbeat %s', heartbeat.get_body())
                self.queue.put(heartbeat)
        else:
            try:
                alert = Alert.parse_alert(body)
            except ValueError:
                self.statsd.metric_send('alerta.alerts.rejected', 1)
                return
            if alert:
                alert.receive_now()
                LOG.debug('Queueing successfully parsed alert %s', alert.get_body())
                self.queue.put(alert)
Exemplo n.º 4
0
def create_heartbeat():

    # Create a new heartbeat
    try:
        heartbeat = Heartbeat.parse_heartbeat(request.data)
    except Exception, e:
        return jsonify(response={"status": "error", "message": str(e)})
Exemplo n.º 5
0
Arquivo: daemon.py Projeto: ob3/alerta
    def on_message(self, headers, body):

        LOG.info("Received %s %s", headers['type'], headers['correlation-id'])
        LOG.debug("Received body : %s", body)

        if headers['type'] == 'Heartbeat':
            heartbeat = Heartbeat.parse_heartbeat(body)
            if heartbeat:
                heartbeat.receive_now()
                LOG.debug('Queueing successfully parsed heartbeat %s', heartbeat.get_body())
                self.queue.put(heartbeat)
        elif headers['type'].endswith('Alert'):
            try:
                alert = Alert.parse_alert(body)
            except ValueError:
                self.statsd.metric_send('alerta.alerts.rejected', 1)
                return
            if alert:
                alert.receive_now()
                LOG.debug('Queueing successfully parsed alert %s', alert.get_body())
                self.queue.put(alert)
Exemplo n.º 6
0
def create_heartbeat():

    try:
        heartbeat = Heartbeat.parse_heartbeat(request.data)
    except ValueError, e:
        return jsonify(status="error", message=str(e))