From 142e9473ba48042795b354fbe467e6bd4ed2233c Mon Sep 17 00:00:00 2001 From: Denys Zhdanov Date: Sun, 9 Jul 2023 16:11:02 +0200 Subject: [PATCH] Adding AMQP control --- README.md | 11 +++++++++++ conf/etc/service/carbon/run | 29 +++++++++++++++++++++++++++++ conf/opt/graphite/conf/carbon.conf | 20 ++++++++++---------- 3 files changed, 50 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index f0a16e0..0647c6b 100644 --- a/README.md +++ b/README.md @@ -187,6 +187,17 @@ Graphite stores tag information in a separate tag database (TagDB). Please check ## Collectd Use `COLLECTD=1` environment variable to enable local collectd instance +## AMQP +* CARBON_ENABLE_AMQP: (false) if set to 1 or true will enable AMQP ingestion in Carbon. +* CARBON_AMQP_VERBOSE: (false) if set to 1 or true will enable verbose AMQP output +* CARBON_AMQP_HOST: (localhost) +* CARBON_AMQP_PORT: (5672) +* CARBON_AMQP_VHOST: (/) +* CARBON_AMQP_USER: : (guest) +* CARBON_AMQP_PASSWORD: (guest) +* CARBON_AMQP_EXCHANGE: (graphite) +* CARBON_AMQP_METRIC_NAME_IN_BODY: (false) + ## Carbon-cache If custom environment `GRAPHITE_CARBONLINK_HOSTS` variable is setup `carbon-cache` instances as daemons/services are [managed](./conf/etc/run_once/carbon-cache) based on the that, otherwise default instance (`127.0.0.1:7002`) is used. diff --git a/conf/etc/service/carbon/run b/conf/etc/service/carbon/run index da3141d..f5aa4c3 100755 --- a/conf/etc/service/carbon/run +++ b/conf/etc/service/carbon/run @@ -10,6 +10,35 @@ if [ -n "${CARBON_DISABLE_TAGS}" ]; then sed -i 's/ENABLE_TAGS = True/ENABLE_TAGS = False/g' /opt/graphite/conf/carbon.conf fi +# AMQP params +if [ -n "${CARBON_ENABLE_AMQP}" ]; then + sed -i 's/# ENABLE_AMQP = False/ENABLE_AMQP = True/g' /opt/graphite/conf/carbon.conf + if [ -n "${CARBON_AMQP_VERBOSE}" ]; then + sed -i 's/# AMQP_VERBOSE = False/AMQP_VERBOSE = True/g' /opt/graphite/conf/carbon.conf + fi + if [ -n "${CARBON_AMQP_HOST}" ]; then + sed -i "s/AMQP_HOST = localhost/AMQP_HOST = ${CARBON_AMQP_HOST}/g" /opt/graphite/conf/carbon.conf + fi + if [ -n "${CARBON_AMQP_PORT}" ]; then + sed -i "s/AMQP_PORT = 5672/AMQP_PORT = ${CARBON_AMQP_PORT}/g" /opt/graphite/conf/carbon.conf + fi + if [ -n "${CARBON_AMQP_VHOST}" ]; then + sed -i "s/AMQP_VHOST = \//AMQP_VHOST = ${CARBON_AMQP_VHOST}/g" /opt/graphite/conf/carbon.conf + fi + if [ -n "${CARBON_AMQP_USER}" ]; then + sed -i "s/AMQP_USER = graphite/AMQP_USER = ${CARBON_AMQP_USER}/g" /opt/graphite/conf/carbon.conf + fi + if [ -n "${CARBON_AMQP_PASSWORD}" ]; then + sed -i "s/AMQP_PASSWORD = guest/AMQP_PASSWORD = ${CARBON_AMQP_PASSWORD}/g" /opt/graphite/conf/carbon.conf + fi + if [ -n "${CARBON_AMQP_EXCHANGE}" ]; then + sed -i "s/AMQP_EXCHANGE = graphite/AMQP_EXCHANGE = ${CARBON_AMQP_EXCHANGE}/g" /opt/graphite/conf/carbon.conf + fi + if [ -n "${CARBON_AMQP_METRIC_NAME_IN_BODY}" ]; then + sed -i 's/AMQP_METRIC_NAME_IN_BODY = False/AMQP_AMQP_METRIC_NAME_IN_BODY = True/g' /opt/graphite/conf/carbon.conf + fi +fi + BIN=/opt/graphite/bin/python3 [[ -f "/opt/graphite/bin/pypy3" ]] && BIN=/opt/graphite/bin/pypy3 exec ${BIN} /opt/graphite/bin/carbon-cache.py start --debug 2>&1 diff --git a/conf/opt/graphite/conf/carbon.conf b/conf/opt/graphite/conf/carbon.conf index ba3cdb7..8cbe353 100644 --- a/conf/opt/graphite/conf/carbon.conf +++ b/conf/opt/graphite/conf/carbon.conf @@ -267,19 +267,19 @@ WHISPER_FALLOCATE_CREATE = False CARBON_METRIC_INTERVAL = 10 # Enable AMQP if you want to receve metrics using an amqp broker -# ENABLE_AMQP = False +ENABLE_AMQP = False # Verbose means a line will be logged for every metric received # useful for testing -# AMQP_VERBOSE = False - -# AMQP_HOST = localhost -# AMQP_PORT = 5672 -# AMQP_VHOST = / -# AMQP_USER = guest -# AMQP_PASSWORD = guest -# AMQP_EXCHANGE = graphite -# AMQP_METRIC_NAME_IN_BODY = False +AMQP_VERBOSE = False + +AMQP_HOST = localhost +AMQP_PORT = 5672 +AMQP_VHOST = / +AMQP_USER = guest +AMQP_PASSWORD = guest +AMQP_EXCHANGE = graphite +AMQP_METRIC_NAME_IN_BODY = False # The manhole interface allows you to SSH into the carbon daemon # and get a python interpreter. BE CAREFUL WITH THIS! If you do