ansible-role-grafana_agent icon indicating copy to clipboard operation
ansible-role-grafana_agent copied to clipboard

Add Custom Labels

Open harsha-chamarthi opened this issue 2 years ago • 6 comments

Add support for custom labels to uniquely identify the source of metrics if you are running multiple Grafana Agents across multiple machines

harsha-chamarthi avatar Jan 18 '22 14:01 harsha-chamarthi

Could you provide a config example with these labels?

nleiva avatar Jan 20 '22 14:01 nleiva

https://grafana.com/docs/agent/latest/configuration/metrics-config/#global_config

A list of static labels to add for all metrics.

external_labels: { : }

Add a label, for example environment: dev to differentiate between different environments

harsha-chamarthi avatar Jan 27 '22 13:01 harsha-chamarthi

Thanks. The current config looks like this:

prometheus:
  wal_directory: /tmp/grafana-agent-wal
  global:
    scrape_interval: 15s
  configs: null

Maybe we can make it something like:

prometheus:
  wal_directory: /tmp/grafana-agent-wal
  global:
    scrape_interval: 15s
external_labels:
  { environment : {{ grafana_agent_env | default('dev') }} }
  configs: null

And expose the variable grafana_agent_env. What do you think?

We also need to be mindful of users that don't want any labels.

nleiva avatar Feb 11 '22 21:02 nleiva

Yes, this config looks good to me. Can we maybe use a flag(true or false) like used to install unzip here? to enable disable external_labels.

harsha-chamarthi avatar Feb 14 '22 13:02 harsha-chamarthi

what is required for this to be added?

kmf avatar Jun 29 '22 14:06 kmf

Time and/or a PR. Thanks

nleiva avatar Aug 17 '22 16:08 nleiva