From e5f14cdcb6629c6a406717197d07dfeabd0aa07c Mon Sep 17 00:00:00 2001 From: Marko Culinovic Date: Tue, 27 Feb 2018 17:42:09 +0100 Subject: [PATCH] Add cluster prefix flag to statsd Summary: Flag cluster-prefix is added because we want to differentiate between stats collected on different memgraph clusters. Reviewers: mtomic, buda Reviewed By: mtomic Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D1245 --- tools/src/mg_statsd/main.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/src/mg_statsd/main.cpp b/tools/src/mg_statsd/main.cpp index e809baf34..9bada6e20 100644 --- a/tools/src/mg_statsd/main.cpp +++ b/tools/src/mg_statsd/main.cpp @@ -13,14 +13,20 @@ DEFINE_VALIDATED_int32(port, 2500, "Communication port on which to listen.", DEFINE_string(graphite_address, "", "Graphite address."); DEFINE_int32(graphite_port, 0, "Graphite port."); +DEFINE_string(prefix, "", "Prefix for all collected stats"); std::string GraphiteFormat(const stats::StatsReq &req) { std::stringstream sstr; - sstr << req.metric_path; + if (!FLAGS_prefix.empty()) { + sstr << FLAGS_prefix << "." << req.metric_path; + } else { + sstr << req.metric_path; + } for (const auto &tag : req.tags) { sstr << ";" << tag.first << "=" << tag.second; } sstr << " " << req.value << " " << req.timestamp << "\n"; + LOG(INFO) << sstr.str(); return sstr.str(); }