Skip to content

Instantly share code, notes, and snippets.

@michaeljs1990
Created December 10, 2018 17:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaeljs1990/f1fbc660c72252a5e5a894f472faf6e5 to your computer and use it in GitHub Desktop.
Save michaeljs1990/f1fbc660c72252a5e5a894f472faf6e5 to your computer and use it in GitHub Desktop.
PromQL CLI
#!/bin/bash
# Basic: HOSTNAME=prom.something.com ./promql.sh '(time() - puppet_time{type="last_run"}) > 4801'
# Getting something useful out from this looks like this. Best used in combination with JQ.
# Complete: HOSTNAME=prom.something.com ./promql.sh '(time() - puppet_time{type="last_run"}) > 4801' | jq '.data.result[] | .metric.host'
curl \
-X GET \
-G \
-s \
--data-urlencode "query=$1" \
"https://$HOSTNAME/api/v1/query"
# Make output look a little nicer.
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment