feat: add support for additional labels on metrics#536
Conversation
|
This is really cool! I had envisioned this in #386. I wonder if this can be extended more widely |
|
@Sharpz7 instead of additional labels how about overriding labels. Let me take some time and implement it for all metrics. |
|
@Sharpz7 can you review the PR |
|
Hey @rajsameer. I will try to get to it ASAP |
|
@rajsameer are you able to provide some results from a devstack with this working? |
I am using the exporter for ironic metrics, I do not have all components of openstack. Do you need the metrics output? |
|
Its more that I would like this tested before we merge it. In a devstack, or potentially integration tests when #481 lands. I appreciate you have already put a lot of work in, so I'll try my best to help out getting this merged. |
hey sorry for the late reply did not get time from work. I will try to get the verification done in few days. |
Add generic --extra-labels flag for customising metric labels
Summary
Introduces a new --extra-labels CLI flag that allows operators to attach additional labels to any metric across all OpenStack service exporters, without requiring code changes. This
replaces the narrower, Ironic-specific --ironic.additional-labels approach with a generic solution.
Motivation
Users often need to enrich metrics with environment-specific context (e.g. rack ID, datacenter, environment name) that is available in OpenStack API responses but not exposed as
Prometheus labels by default. Previously, adding such labels required service-specific code changes per exporter.
Changes
New --extra-labels flag (main.go, utils/kingping_extra_labels_parser.go)
Generic reflect-based field resolver (exporters/fields_cahce.go)
All service exporters updated
Extra label support added to all 15 exporters: ironic, cinder, nova, neutron, glance, keystone, loadbalancer, heat, placement, manila, designate, trove, gnocchi, containerinfra,
objectstore
Testing
conductor label and the static env="test" const label in the collected output
Usage
Add the conductor field and a static datacenter label to all ironic node metrics
openstack-exporter --extra-labels=ironic.node:conductor,datacenter=dc1 mycloud
Add a nested extra field and a static env label to ironic node metrics
openstack-exporter --extra-labels=ironic.node:extra.rack_id,env=production mycloud
Multiple services in one invocation (cumulative flag)
openstack-exporter
--extra-labels=ironic.node:conductor
--extra-labels=nova.server:hypervisor_hostname,region=eu-west
mycloud