#!/bin/bash | |
MACKEREL_APIKEY=<YOUR_MACKEREL_APIKEY> | |
SERVICE_NAME="alerts-count" | |
NOW=$(date +%s) | |
ALERT_LOG_FILE="/path/to/logfile" | |
function push_mackerel_alerts_count () { | |
curl -sS \ | |
-X POST \ | |
-H 'X-Api-Key: '${MACKEREL_APIKEY} \ | |
-H 'Content-Type: application/json' \ | |
-d '[{"name":"'$1'","time":'$NOW',"value":'$2'}]' \ | |
https://api.mackerelio.com/api/v0/services/alerts-count/tsdb | |
} | |
cat $ALERT_LOG_FILE | cut -f 4 | sort | uniq -c | while read LINE | |
do | |
TYPE="alerts_count."$(echo "$LINE" | cut -d' ' -f 2) | |
COUNT=$(echo "$LINE" | cut -d' ' -f 1) | |
push_mackerel_alerts_count $TYPE $COUNT | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment