Skip to content

Instantly share code, notes, and snippets.

@jderrett
Last active August 29, 2015 14:16
Show Gist options
  • Save jderrett/a703a2e5660ab153af3d to your computer and use it in GitHub Desktop.
Save jderrett/a703a2e5660ab153af3d to your computer and use it in GitHub Desktop.
Librato active alerts with service counts (using jq)
# Required:
# http://stedolan.github.io/jq/
# brew install jq
LIBRATO_USER="justin@example.com"
LIBRATO_TOKEN="<your api token>"
LIBRATO_AUTH="$LIBRATO_USER:$LIBRATO_TOKEN"
ALERTS_ENDPOINT="https://metrics-api.librato.com/v1/alerts?version=2"
# Show active alerts with service counts (i.e. how many notifications are getting sent if it fires)
# And a URL to the alert
curl -s -X GET -u $LIBRATO_AUTH $ALERTS_ENDPOINT \
| jq '.alerts[] | select(.active==true)' \
| jq '{id: .id, url: ("https://metrics.librato.com/alerts#/" + (.id | tostring)), name: .name, service_count: (.services | length)}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment