metrics
metrics copied to clipboard
Per measurement tags for telegraf and InfluxDB
Hi there,
First of all, thanks for this great lib. I particularly enjoy this no vendor lock-in approach :+1:
Most (if not all) formats that support tags support setting different tags for each measurement.
It would be nice to retain the global (per $collector instance) tags, but also to support additional tags that would be set for only the current measurement, via additional (optional) function parameters.
For example:
$collector = \Beberlei\Metrics\Factory::create('telegraf');
$collector->setTags(['app_name' => 'myApp']);
$collector->increment('foo.bar', ['additional_tag' => 'tag_value']);
I could make a PR if you agree with that change.
EDIT: I didn't see that this just got implemented via the InlineTaggableGaugeableCollector interface. Only DogStatsD seems to implement it but Telegraf and InfluxDB should also support it.
Hello @p3r7
It looks like a good idea to me.
Could you submit a PR?
Thanks.
Yeah, sure :wink:
Prometheus also supports per metric labels / tags. Currently they can only be set globally for the service.
http_requests_total{method="post",code="200"} 1027 1395066363000
http_requests_total{method="post",code="400"} 3 1395066363000
Reference: https://prometheus.io/docs/instrumenting/exposition_formats/
@buffcode : yeah, and I implemented it. You've seen my PR. I would gladly accept some help or you taking ownership if you feel like.