Skip to content

Allow use of `instance` and `job` labels

It's now possible to set the instance and job labels on metrics, where previously they had been reserved.

The reason we'd reserved them is that Prometheus automatically generates values for them when it scrapes a target, and we didn't want to cause a collision. It turns out Prometheus handles that collision just fine.

By default, Prometheus server will prepend exported_ to them if they're present in the scraped data (i.e. exported_instance and exported_job). Users can set honor_labels in their Prometheus server config if they prefer the labels from the scraped metric data to take precedence over the labels generated by the server.

Before this MR, Prometheus::Client::Push usage example from README was incorrect, because it was raising error (see: https://gitlab.com/-/snippets/2569284).

Based on: https://github.com/prometheus/client_ruby/pull/277

Merge request reports