I'm a little unsure how to alter the scrape path of a kubernetes_sd_config job with a role of node:
https://prometheus.io/docs/prometheus/latest/configuration/configuration/#nodeThe current relabel_configs look like this:
relabel_configs:
- action: labelmap
regex: __meta_kubernetes_node_label_(.+)
- target_label: __address__
replacement: kubernetes.default.svc:443
- source_labels: [__meta_kubernetes_node_name]
regex: (.+)
target_label: __metrics_path__
replacement: /api/v1/nodes/${1}:4194/proxy/metrics
This is not the path I want to hit, though. I want to scrape `<node_name>:8080/metrics`.
As per the description on the docs for the node role of this sd config: "The
node role discovers one target per cluster node
with the address defaulting
to the Kubelet's HTTP port.
The target address defaults to the first existing address of the Kubernetes
node object in the address type order of
NodeInternalIP,
NodeExternalIP,
NodeLegacyHostIP, and
NodeHostName."
Highlighted is a problem for me, I think. I want to use my custom port of 8080, not the kubelet port. I'm wondering if the following relabel configs would get me the metrics path of `<node_name>:8080/metrics`:
relabel_configs:
- action: labelmap
regex: __meta_kubernetes_node_label_(.+)
- source_labels: [__address__]
regex: (.+):(\d+)
target_label: __address__
replacement: ${1}:8080
- source_labels: [__metrics_path__]
regex: (.+)
target_label: __metrics_path__
replacement: /metrics
Is that the right format for regex? Would that pull out the hostname into ${1} from `hostname:port` format? And the last one with the __metrics_path__, is that the nicest/easiest/right way to just set the metrics path?
Lastly, is there any way to see what Prometheus is doing with these relabels? In other words, how do I verify that when Prometheus is running, it is scraping from <node_name>:8080/metrics?
Thanks so much in advance!