Dynamically apply cloud instance metadata ipv4 within yaml promQL

Viewed 25

I am looking to run the below curl request(curl http://169.254.169.254/latest/meta-data/local-ipv4) on cloud instance and assign dynamically that address to the filter "instance" which is currenly manually assigned "10.30.8.14" in the below yaml manifest. So very time yaml configuratio n applies on different instances then it will automatically fetch through curl and applies in instance filter. Looking how to make it assigned to it ?

curl http://169.254.169.254/latest/meta-data/local-ipv4

yaml : 

apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
  labels:
    prometheus-name: rancher-monitoring-prometheus
  name: pcd-prometheus-rules
spec:
  groups:
  - name: network.pcd.rules
    rules:
    - expr:  avg((sum(rate(node_network_transmit_bytes_total{device="eth0", instance="10.30.8.14"}[2m])) BY (instance)))
      record: instance:node_network_transmit_bytes:avg
      labels:
        namespace: delivery
        service: rancher-monitoring-prometheus-node-exporter
0 Answers
Related