group_left
unfortunately is more of a limited workaround than a solution. I've been trying in vai for a month to find a coherent explanation of group_left
, and expressions aren't labels. Having to tack an incantation onto every simple expression would be annoying; figuring out how to build more complex PromQL queries with multiple metrics is another entirely. It would also be less than friendly to expect any of my users -- especially those completely new to Grafana / PromQL -- to write a complex and inscrutable query every time.
My first stab was something like this:
- job_name: 'node_exporter'
scrape_interval: 10s
static_configs:
- targets: ['1.2.3.4:9100']
labels:
cluster: 'rkv-image01'
ceph_role: 'mon'
instance_node: 'rkv1701'
Which is frowned on by upstream as an "antipattern" because apparently there is an expectation that instance
be the only label whose value is unique across all metrics in the job. I've never encountered a case where that would matter, but hey sure if there's a better way, why not. There's the idea that the exporter should be "fixed', but I'm hesitant to go down the rabbit hole of a potentially breaking change to a widely used project. I'm also loathe to fork it and have to maintain in parallel with upstream, I have neither the time nor the karma.
Next I tried metrics_relabel_configs
but that doesn't seem to want to copy a label from a different metric, ie. node_uname_info{nodename}
-> instance
-- I get a syntax error at startup.
Next I came across something that said that Prom will fill in instance
with the value of address
if the collector doesn't supply a value, and indeed for some reason it seems as though my scrapes of node_exporter
aren't getting one. Which seems odd. But what I found to actually work is the simple and so blindingly obvious that I didn't think to even try:
- job_name: 'node_exporter'
scrape_interval: 10s
static_configs:
- targets: ['1.2.3.4:9100']
labels:
cluster: 'rkv-image01'
ceph_role: 'mon'
instance: 'rkv1701'
...
I.e., simply applying a target label in the scrape config. I'm working on file-based service discovery from a DB dump that will be able to write these targets out.
It may be a factor that my environment does not have DNS A or PTR records for the nodes in question. Yes, I know, trust me I don't like either but it's out of my control. But still that shouldn't matter, I dunno why node_exporter
isn't supplying any instance
label at all since it does find the hostname for the info metric (where it doesn't do me any good).
$ curl http://1.2.3.4:9100/metrics | grep instance
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 80082 0 80082 0 0 4383k 0 --:--:-- --:--:-- --:--:-- 4600k
$ curl http://1.2.3.4:9100/metrics | grep rkv1701
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 80085 0 80085 0 node_uname_info{domainname="(none)",machine="x86_64",nodename="rkv1701.myco.com",release="4.17.13-1.el7.elrepo.x86_64",sysname="Linux",version="#1 SMP Mon Aug 6 14:16:00 EDT 2018"} 1
0 9268k 0 --:--:-- --:--:-- --:--:-- 9776k
$