grok_exporter icon indicating copy to clipboard operation
grok_exporter copied to clipboard

How to hide default labels in grok

Open Priyotosh008 opened this issue 7 years ago • 4 comments
trafficstars

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

Priyotosh008 avatar Oct 23 '18 15:10 Priyotosh008

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.

fstab avatar Oct 23 '18 15:10 fstab

Prometheus also provides a relabel configuration, which might help you. Look for relabeling here: https://prometheus.io/docs/prometheus/latest/configuration/configuration

fstab avatar Oct 23 '18 15:10 fstab

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.

Priyotosh008 avatar Oct 24 '18 10:10 Priyotosh008

The instance label is a special case, because it is generated by Prometheus after relabeling. As the documentation says:

After relabeling, the instance label 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.

fstab avatar Oct 24 '18 19:10 fstab