[feature request] Add static label to metrics via parameters or environment variable
dvhh opened this issue · 5 comments
Prometheus scraping is only adding instance address.
It would be ideal to be able to add static metrics label via parameters or via environment variable. With the goal of adding more significant identifier to the metrics (like hostname for example).
Desirable implementation:
adding an optional parameters:
--extra-label <label_name=label_static_value>
Would addlabel_name="label_static_value"
label to metrics--label-from-env <environnment_variable_name>
Would addenvironnment_variable_name="environnment_variable_value"
adding environment variables to control behavior:
LE_EXTRA_LABEL=<label_name>:<label_value>
Would addlabel_name=label_value
label to metricsLE_LABEL_FROM_ENV=<environnment_variable_name>
Would addenvironnment_variable_name="environnment_variable_value"
Hello @dvhh
I am currently working on making v2 live. You can check my current progress on #204
The v2 version provides yaml configuration, which is usually more convenient for creating extensive prometheus exporter configurations. What do you think about either suggesting me how would you like the label configuration to look like, or making a PR to that branch with the feature itself?
edit: I am working to support stuff like hostname out of the box
Actually, you can take a look on this commit: 90a9dc2
It is more like a proposal in early stage, but I may continue writing something similar
Hello @kuskoman,
Changes looks promising, I was looking at a shorter term solution, But could probably wait for a v2. One critic though, might be that the change of configuration interface could be different from what the user are looking for.
In the meantime will try to come up with a short term stopgap solution for my issue, it might result in a PR that will be obsoleted with your changes.
Hello again @dvhh
I just merged v2 branch, which features reading label config from yaml file, but does not use it yet.
I can address the issue later on, but I am not entirely sure when
If you (or anybody reading this comment) have the knowledge of Go programming and some free time please tell me, so we can cooperate on this feature
@dvhh hello again for the nth time :D
I had some time and took a look on implementing this, but I've met some problems regarding the correct way to approach the problem
Since we need to specify the same labels for each of the servers, I can either:
- ensure that you have labels with the same keys configured for each server. this sounds good but generates a lot of code, so i am not sure about this one
- skip this issue right now and just attach
host
and some other generic, automatic labels to each of them, so that you can use replace_labels, or whatever function do you need in some kind of proxy to attach the needed labels yourself