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
This commit is contained in:
Marko Culinovic 2018-02-27 17:42:09 +01:00
parent 79dc10960e
commit e5f14cdcb6

View File

@ -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();
}