Windows_exporter metric_relabel_config

I use Grafana Cloud with windows_exporter integration.
Here is my agent-config.yaml

server:
  http_listen_port: 12345
  #log_level: debug
prometheus:
  wal_directory: C:\ProgramData\grafana-agent-wal
  global:
    scrape_interval: 15s
    remote_write:
    - url: https://prometheus-blocks-prod-us-central1.grafana.net/api/prom/push
      basic_auth:
        username: USERNAME
        password: PASSWORD
  configs:
    - name: integrations
integrations:
  windows_exporter:
    enabled: true
    enabled_collectors: "system"
    relabel_configs:
      - source_labels: ['__name__']
        regex: 'windows_system_system_up_time'
        action: keep

Please help to drop some metrics. I need to keep only one metric with name ‘windows_system_system_up_time’ - all other metrics need to be droped.

You’re almost there @oriondvd5.

First, it should be metric_relabel_configs rather than relabel_configs. Also, your values need not be in single quotes.

With a (partial) config that looks like this, I was able to achieve the desired result.

  windows_exporter:
    enabled: true
    metric_relabel_configs:
      - source_labels: [__name__]
        regex: windows_system_system_up_time
        action: keep
2 Likes

@ryangeyer Thanks so much for the simple explanation of this. The documentation is very unclear about how to include/exclude specific metrics from collection. There are no concrete examples of how to do that using the agent.

1 Like

This topic was automatically closed after 365 days. New replies are no longer allowed.