metrics icon indicating copy to clipboard operation
metrics copied to clipboard

Per measurement tags for telegraf and InfluxDB

Open p3r7 opened this issue 8 years ago • 4 comments

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.

p3r7 avatar Dec 21 '16 17:12 p3r7

Hello @p3r7

It looks like a good idea to me.

Could you submit a PR?

Thanks.

lyrixx avatar Dec 22 '16 09:12 lyrixx

Yeah, sure :wink:

p3r7 avatar Dec 22 '16 10:12 p3r7

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 avatar Mar 30 '17 20:03 buffcode

@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.

p3r7 avatar Mar 31 '17 14:03 p3r7