query Prometheus by __meta_gce_tags

81 views
Skip to first unread message

David

unread,
Nov 6, 2017, 4:06:01 AM11/6/17
to Prometheus Users
We are using Prometheus to monitor out GCE machines. we wish to search by GCE tags. we are doing it today by relabeling:

      - source_labels: [__meta_gce_tags]
        target_label: tags

This gives us all the GCE tags into tags labels. For example: tags=",prod,elasticsearch,data-node,"

The problem is that when we wish to do queries, we have to use regex by the specific order. for example: max(elasticsearch_cluster_health_status{color="red",tags=~".*?elasticsearch.?"}) == 1

We wish to do relabeling that will help us to query by tags. we tried to do the following:

      - source_labels: [__meta_gce_tags]
        regex: '([^,\s][^\,]{1}[^,\s]*)'
        replacement: ${1}
        target_label: ${1}

which in regex101.com gives the following matches: 

Match 1
Full match1-5`prod`
Group 1.1-5`prod`
Match 2
Full match6-19`elasticsearch`
Group 1.6-19`elasticsearch`
Match 3
Full match20-29`data-node`
Group 1.20-29`data-node`

but in Prometheus is doesn't do relabeling to nothing. what is the best way to do it and query Prometheus by GCE tags?

Meier

unread,
Nov 8, 2017, 7:26:26 AM11/8/17
to Prometheus Users
Are you missing an "by(<label>)" clause in your  query ?
Reply all
Reply to author
Forward
0 new messages