I want to add a "hostname" label to my metrics in Prometheus, because I don't need domain or port information in my dashboards.
I tried adding this to the respective exporter settings in my Prometheus config:
relabel_configs:
- source_labels:
- instance
regex: "([a-z][a-z0-9-]*)(\\.[a-z][a-z0-9-]*)*(:[0-9]+)?"
target_label: hostname
but it doesn't seem to have an effect. Even if I remove the regular expression, I don't get a label "hostname" in the scraped metrics when I would have expected a copy of the label "instance."