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}
| Match 1 |
|---|
| Full match | 1-5 | `prod` |
| Group 1. | 1-5 | `prod` |
| Match 2 |
|---|
| Full match | 6-19 | `elasticsearch` |
| Group 1. | 6-19 | `elasticsearch` |
| Match 3 |
|---|
| Full match | 20-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?