Set host name as label for all prometheus metrics #162
-
Hello, Is it possible to set a default label of host to all metrics being exported? I tried this exporter and it does not seem to add any labels by default. I tried using a SQL query to grab the hostname, but since I am on RDS, I do not see the actual name and an internal ip. For my use case, I am looking for a single exporter which can be used with multiple PostgreSQL & MySQL instances. Wondering if that is something which can be achieved using this exporter? Thanks, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hey @abhi-kapoor, sorry for the late answer, I was on a sick leave. Personally, I'd avoid mixing two different types of instances, but it might work, I just haven't extensively tested it. Have a look at this example? This variant adds instance labels automatically. As a side note: the main use case for this exporter is usually running it as a sidecar container in Kubernetes. With a small footprint it's not a big deal to collect data from this exporter. Alternative usage is always welcome, but dispatching requests to multiple database instances contradicts with a goal of being simple. Let me know if it works or what are the issues. 🙂 Kind regards, |
Beta Was this translation helpful? Give feedback.
Hey @abhi-kapoor, sorry for the late answer, I was on a sick leave.
Personally, I'd avoid mixing two different types of instances, but it might work, I just haven't extensively tested it. Have a look at this example? This variant adds instance labels automatically.
As a side note: the main use case for this exporter is usually running it as a sidecar container in Kubernetes. With a small footprint it's not a big deal to collect data from this exporter. Alternative usage is always welcome, but dispatching requests to multiple database instances contradicts with a goal of being simple.
Let me know if it works or what are the issues. 🙂
Kind regards,
Sergei