discourse / prometheus_exporter

A framework for collecting and aggregating prometheus metrics
MIT License
537 stars 155 forks source link

Support for dynamic labels/tags (set in runtime) #121

Open raivil opened 4 years ago

raivil commented 4 years ago

Hi,

Are there plans to add support for dynamic labels/tags set in runtime?

The idea would be to add custom tags to support metrics segmented by Customers or any other attribute. Example:

sidekiq_job_duration_seconds{queue="default",worker="Jobs::SomeJobClass", customer_id="ABC"} 123456
sidekiq_jobs_total{queue="default",worker="Jobs::SomeJobClass", customer_id="ABC"} 65.0

For more context, on Newrelic or ELK APM's, it's possible to add custom labels or context data to transactions, that would work similarly to adding tags/labels to Prometheus metrics. Examples: ELK and Newrelic

I'm aware that it is usually a bad idea to place identifiers into Prometheus as it may cause huge memory consumption by both Prometheus and your application. https://prometheus.io/docs/practices/naming/#labels.

I'm not sure if this is the best way to accomplish that, and I'd appreciate your input.

Best,

SamSaffron commented 4 years ago

In general you would handle custom segmentation by writing a custom collector, perhaps inherit off the sidekiq collector and adjust to taste?