sensu / sensu-prometheus-collector

Collect Prometheus metrics with Sensu!
MIT License
28 stars 18 forks source link

Flatten tags in graphite output #13

Open eberkut opened 5 years ago

eberkut commented 5 years ago

When using the influx output, tags are "flattened" but this is not the case for the graphite output which can create duplicate keys and make the graphite output unusable.

For instance, for a micrometer Java application: 1) Raw Prometheus output logback_events_total{level="error",} 0.0 logback_events_total{level="warn",} 0.0 logback_events_total{level="info",} 123.0 logback_events_total{level="debug",} 0.0 logback_events_total{level="trace",} 0.0

2) sensu prometheus collector influx output logback_events_total,level=error value=0 1546955856 logback_events_total,level=warn value=0 1546955856 logback_events_total,level=info value=124 1546955856 logback_events_total,level=debug value=2 1546955856 logback_events_total,level=trace value=0 1546955856

3) sensu prometheus collector graphite output logback_events_total 0 1546954471 logback_events_total 0 1546954471 logback_events_total 124 1546954471 logback_events_total 2 1546954471 logback_events_total 0 1546954471

To cope with Graphite grammar for metric names compared to influx, multiple tags could be concatenated with '.' (instead of ',' for influx). In addition, '/' could be converted to '_' and '=' to '.'.