grok_exporter
grok_exporter copied to clipboard
How to hide default labels in grok
Hello All,
I want to hide default labels in Grok Exporter output.
My Output is:
WLSRESTARTFLAG{exported_instance="https://171.17.22.7:2002/console/login/LoginForm.jsp",instance="muclhp522:9968",job="grok"} 0 WLSRESTARTFLAG{exported_instance="https://171.17.22.6:3011/weblogicStatus/index.html",instance="muclhp522:9968",job="grok"} 1 WLSRESTARTFLAG{exported_instance="https://171.17.22.5:3011/weblogicStatus/index.html",instance="muclhp522:9968",job="grok"} 0 WLSRESTARTFLAG{exported_instance="https://171.17.22.4:3012/weblogicStatus/index.html",instance="muclhp522:9968",job="grok"} 0 WLSRESTARTFLAG{exported_instance="https://171.17.22.3:3011/weblogicStatus/index.html",instance="muclhp522:9968",job="grok"} 0 WLSRESTARTFLAG{exported_instance="https://171.17.22.2:3012/weblogicStatus/index.html",instance="muclhp522:9968",job="grok"} 0 WLSRESTARTFLAG{exported_instance="https://171.17.22.1:3011/weblogicStatus/index.html",instance="muclhp522:9968",job="grok"} 0
I don't want the labels - instance and job in Prometheus output as this is causing difficulties in setting up alerts in alertmanager.
How can i hide them ? I don't want them to get printed.
Thanks Priyotosh
I don't think these labels are generated by grok_exporter. To see the labels generated by grok_exporter, go to http://localhost:9144/metrics (or whatever you configured in the server section). If these labels are not there, they are added by another component, maybe by the Prometheus server itself.
Prometheus also provides a relabel configuration, which might help you. Look for relabeling here: https://prometheus.io/docs/prometheus/latest/configuration/configuration
Below is the output for a metric in Prometheus
WLSRESTARTFLAG{exported_instance="https://171.17.22.6:3011/weblogicStatus/index.html",instance="muclhp522:9968",job="grok"} 1
I want to drop the label instance from this output.
Hence i added the below configuration in prometheus.yml file
-
job_name: 'grok' static_configs:
- targets: ['muclhp522:9968']
metric_relabel_configs:
- regex: 'muclhp522.*' action: labeldrop
relabel_configs:
- source_labels: [instance] regex: muclhp.* action: drop
Unfortunately this is not working. Can you help me out here if I am missing something.
The instance label is a special case, because it is generated by Prometheus after relabeling. As the documentation says:
After relabeling, the
instancelabel is set to the value of__address__...
A detailed explanation can be found on Brian's blog post "life of a label".
However, in most cases it should not be necessary to drop the instance label. You can probably use a PromQL query to get the results you want even if you keep the instance label in the metrics.