Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save devopsy-ir/fd2d7c06f112a449a3380b40baa8a32e to your computer and use it in GitHub Desktop.
Save devopsy-ir/fd2d7c06f112a449a3380b40baa8a32e to your computer and use it in GitHub Desktop.
How to fire a random alert in Prometheus Alertmanager
#!/bin/bash
#https://gist.githubusercontent.com/cherti/61ec48deaaab7d288c9fcf17e700853a/raw/a69ddd1d96507f6d94059071d500fe499631e739/alert.sh
name=$RANDOM
url='https://alertmanager.example.ir/api/v1/alerts'
echo "firing up alert $name"
# change url o
curl -XPOST $url -d "[{
\"status\": \"firing\",
\"labels\": {
\"alertname\": \"$name\",
\"service\": \"my-service\",
\"severity\":\"warning\",
\"instance\": \"$name.example.net\"
},
\"annotations\": {
\"summary\": \"High latency is high!\"
},
\"generatorURL\": \"http://prometheus.int.example.net/<generating_expression>\"
}]"
echo ""
echo "press enter to resolve alert"
read
echo "sending resolve"
curl -XPOST $url -d "[{
\"status\": \"resolved\",
\"labels\": {
\"alertname\": \"$name\",
\"service\": \"my-service\",
\"severity\":\"warning\",
\"instance\": \"$name.example.net\"
},
\"annotations\": {
\"summary\": \"High latency is high!\"
},
\"generatorURL\": \"http://prometheus.int.example.net/<generating_expression>\"
}]"
echo ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment