Skip to content

Instantly share code, notes, and snippets.

@sfilyh
Forked from cherti/alert.sh
Created August 31, 2022 08:38
Show Gist options
  • Select an option

  • Save sfilyh/8204d3945ff2335299088281a5e5648d to your computer and use it in GitHub Desktop.

Select an option

Save sfilyh/8204d3945ff2335299088281a5e5648d to your computer and use it in GitHub Desktop.

Revisions

  1. @cherti cherti created this gist Dec 9, 2016.
    43 changes: 43 additions & 0 deletions alert.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,43 @@
    #!/bin/bash

    name=$RANDOM
    url='http://localhost:9093/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 ""