SEND TEST ALARMS TO ALERTMANAGER

If running on Kubernetes, first do the port-forwarding:
 


kubectl port-forward -n [monitoring_namespace] [alertmanager_pod] 9093

 
Then just save this to a file and run it:
 

  
#!/usr/bin/env bash

NAME=test-alert
AM_URL='http://localhost:9093/api/v1/alerts'
DATE=$(date --rfc-3339=seconds | sed 's/ /T/')

alert_data() {
cat <<EOF
[{
  "status": "$1",
  "labels": {
    "alertname": "${NAME}",
    "service": "my-test-service",
    "severity":"warning",
    "instance": "${NAME}.example.net",
    "namespace": "my-test-alert",
    "label_costcentre": "TEST"
  },
  "annotations": {
  "summary": "This is just a test!"
  },
  "generatorURL":
  "http://example.net/${NAME}"
  $2
  $3
}]
EOF
}

echo "Firing alert ${NAME}"
printf -v startsAt ',"startsAt": "%s"' ${DATE}
POSTDATA_FIRING=$(alert_data 'firing' "${startsAt}")
curl "${AM_URL}" --data "${POSTDATA_FIRING}" --trace-ascii /dev/stdout

echo; read "Press enter to resolve alert ${NAME}"
echo -e "\nSending resolved for ${NAME}"
printf -v endsAt ',"endsAt": "%s"' ${DATE}
POSTDATA_RESOLVE=$(alert_data 'firing' "${startsAt}" "${endsAt}")
curl "${AM_URL}" --data "${POSTDATA_RESOLVE}" --trace-ascii /dev/stdout