github.com/m3db/m3@v1.5.0/scripts/development/m3_prom_remote_stack/emit_scrape_configs.sh (about)

     1  #!/usr/bin/env bash
     2  
     3  set -xe
     4  
     5  nodes=()
     6  while IFS='' read -r line; do nodes+=("$line"); done < <(curl http://localhost:8001/api/v1/nodes | jq '.items[].metadata.name' | tr -d \")
     7  
     8  
     9  cp prometheus-scraper.yml prometheus-scraper.yml.tmp
    10  
    11  limit=30
    12  
    13  i=0
    14  for node in "${nodes[@]}" ; do
    15    i=$((i+1))
    16    if [ "$i" -gt "$limit" ]; then
    17      break;
    18    fi
    19    echo "
    20    - job_name: cadvisor_${node}
    21      metrics_path: /api/v1/nodes/${node}/proxy/metrics/cadvisor
    22      static_configs:
    23        - targets:
    24          - host.docker.internal:8001
    25          labels:
    26            instance: ${node}
    27    " >> prometheus-scraper.yml.tmp
    28  done