github.com/m3db/m3@v1.5.0/src/cmd/services/m3query/scripts/prom-m3-diff.sh (about) 1 #!/bin/bash 2 # This script can be used to run the same query on prometheus as well as m3. 3 # Sample usage: bash prom-m3-diff.sh "count_over_time(go_gc_duration_seconds[30s])" 1535125074 4 target=${1?"Missing target, usage: $0 target start"} 5 start=${2?"Missing start, usage: $0 target start"} 6 duration=${3:-1000} 7 step=${4:-"15s"} 8 end=$((start + duration)) 9 m3port="localhost:7201" 10 promport="localhost:9090" 11 curl -fsS $promport/status > /dev/null || { echo "Prom port not open"; exit 1; } 12 curl -fsS $m3port/health > /dev/null || { echo "M3Query port not open"; exit 1; } 13 queryurl="/api/v1/query_range?start=$start&end=$end&step=$step --data-urlencode query=$target" 14 m3url="$m3port/$queryurl" 15 promurl="$promport/$queryurl" 16 echo $m3url 17 echo $promurl 18 curl -G $m3url > m3out 19 curl -G $promurl > promout 20 jq ".data.result|.[]|.metric,.values" m3out > m3result 21 jq ".data.result|.[]|.metric,.values" promout > promresult 22 echo "M3 file size" $(stat -f%z m3result) 23 echo "Prom file size" $(stat -f%z promresult)