I dynamically generate tags for consul services and I’ve just realised I may not be using service tags correctly, I’ve been reading through the documentation and can’t find a clear standard or practice, so I believe it’s down to preference but thought it worth asking
if I use a common example that’s documented many times over of using node_exporter to present a monitoring end point, I’ve had this service definition
node-exporter:
address: 1.2.3.4
checks:
- http: http://localhost:9100/metrics
interval: 10s
port: 9100
tags:
- "job:node-exporter"
- "function:telemetry"
- "source:metrics"
- "hardware:virtual"
- "arch:x86_64"
- "osname:RedHat"
- "osversion:9.6"
meta:
SLA: 1
which outputs a service file like this
{"service":{"address":"1.2.3.4","checks":[{"http":"http://localhost:9100/metrics","interval":"10s"}],"enable_tag_override":false,"id":"node-exporter","meta":{"SLA":"1"},"name":"node-exporter","port":9100,"tags":["job:node-exporter","function:telemetry","source:metrics","hardware:virtual","arch:x86_64","osname:RedHat","osversion:9.6"]}}
I don’t fully know if there should be a space between the key and value in the tags
eg:
"arch:x86_64"
or
"arch: x86_64"
I’m also now unclear on how to search based on tags from the command line, in older versions I could do
consul catalog service -tag=$something
I’m not sure how to actually do that now in the current version ?
I’d appreciate clarification or pointing at the documentation that shows how to set tags ‘properly’
thanks