Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Send Nova events to DogStatsD
# Environment Variables: $AMQP_USER, $AMQP_PASSWORD, $AMQP_HOST
import os
from datadog import statsd
from kombu import Connection, Exchange, Queue
nova_x = Exchange('nova', type='topic', durable=False)
info_q = Queue('notifications.info', exchange=nova_x, durable=False,
routing_key='notifications.info')
def process_msg(body, message):
statsd.event(body['event_type'], str(body), alert_type=body['priority'], source_type_name='openstack', tags=['openstack'])
message.ack()
AMQP_USER = os.environ['AMQP_USER']
AMQP_PASSWORD = os.environ['AMQP_PASSWORD']
AMQP_HOST = os.environ['AMQP_HOST']
with Connection('amqp://{0}:{1}@{2}//'.format(AMQP_USER, AMQP_PASSWORD, AMQP_HOST)) as conn:
with conn.Consumer(info_q, callbacks=[process_msg]):
try:
while True:
conn.drain_events()
except KeyboardInterrupt:
exit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.