graphite-dev team mailing list archive
-
graphite-dev team
-
Mailing list archive
-
Message #05540
[Question #266956]: Where is the documentation to connect Carbon to RabbitMQ?
New question #266956 on Graphite:
https://answers.launchpad.net/graphite/+question/266956
I'm trying to get data from the message queue of RabbitMQ, but so far unsuccessful.
/etc/rabbitmq/rabbit.config:
[{kernel,[{inet_dist_use_interface,{127,0,0,1}}]}].
/etc/rabbitmq/rabbitmq-env.conf:
export RABBITMQ_NODENAME=rabbit@localhost
export RABBITMQ_NODE_IP_ADDRESS=127.0.0.1
export ERL_EPMD_ADDRESS=127.0.0.1
export RABBITMQ_CONFIG_FILE="/etc/rabbitmq/rabbit"
/etc/carbon/carbon.conf:
AMQP_VERBOSE = True
AMQP_HOST = rabbit@localhost
AMQP_PORT = 5672
AMQP_VHOST = /
AMQP_USER = guest
AMQP_PASSWORD = guest
AMQP_EXCHANGE = graphite
AMQP_METRIC_NAME_IN_BODY = True
Script to push data to RabbitMQ:
#!/usr/bin/env python
import subprocess, time
import pika # imported via a virtual environment (local pip)
def get_data():
command = subprocess.Popen(["sinfo", "-h", "-a", "-o %F"],
stdout=subprocess.PIPE).communicate()[0]
return(command, int(time.time()))
def sort_data(data):
data = data.replace("/", " ").rstrip("\n")
data_l = data.split(" ")
data_l.remove("")
return(tuple(data_l))
def send_data(data_s, queue_name, server):
connection = pika.BlockingConnection(pika.ConnectionParameters(server))
channel = connection.channel()
channel.queue_declare(queue=queue_name)
channel.basic_publish(exchange='amq.direct',
routing_key=queue_name,
body=data_s)
connection.close()
def main():
server = "localhost"
queue_name = "graphite"
metric_paths = ("rabbitmq.slurm.job_allocation.alloc",
"rabbitmq.slurm.job_allocation.idle",
"rabbitmq.slurm.job_allocation.other",
"rabbitmq.slurm.job_allocation.total")
data, timestamp = get_data()
data_t = sort_data(data)
for metric in range(len(metric_paths)):
data_s = "%s, %d, %d" % (metric_paths[metric],
int(data_t[metric]), timestamp)
send_data(data_s, queue_name, server)
if __name__ == "__main__":
main()
Data is pushed to RabbitMQ:
[root@gtw1 carbon]# rabbitmqctl list_queues
Listing queues ...
graphite 12
...done.
But Carbon doesn't get the data from the queue. I think this has to do with the exchange types. The default in the configuration file is set to 'AMQP_EXCHANGE = graphite', but when I run:
[root@gtw1 carbon]# rabbitmqctl list_exchanges
Listing exchanges ...
direct
amq.direct direct
amq.fanout fanout
amq.headers headers
amq.match headers
amq.rabbitmq.log topic
amq.rabbitmq.trace topic
amq.topic topic
...done.
I don't get that exchange. I can't find any documentation about this setup. Is there any?
--
You received this question notification because you are a member of
graphite-dev, which is an answer contact for Graphite.