Prometheus Alerts API

Upload rules

POST /v2/alerts/prom/config/rules/

Curl example:

curl -X POST 'https://YOUR-API-KEY@api.hostedgraphite.com/v2/alerts/prom/config/rules/' --form 'rules=@{filename including path}'

You can also see how to configure rules file by the following rules configuration link.

Note:
The previous rules configuration will be changed.

Status Codes:

  • 200 - OK
  • 400 - Something wrong with the rules file.

Upload alertmanager configs

POST /v2/alerts/prom/config/alertmanager/

Curl example:

curl -X POST 'https://YOUR-API-KEY@api.hostedgraphite.com/v2/alerts/prom/config/alertmanager/' --form 'alertmanager=@{filename including path}'

You can also see how to configure alertmanager file by the following alertmanager configuration link.

Note:
The previous alertmanager configuration will be changed.

Status Codes:

  • 200 - OK
  • 400 - Something wrong with the alertmanager file.

Obtain notification channels info

GET /v2/alerts/prom/notifications/ - Returns a list of notification channels for Prometheus alerts.

Curl example:

curl -X GET "https://YOUR-API-KEY@api.hostedgraphite.com/v2/alerts/prom/notifications/"

Response format:

HTTP/1.1 200
Content-Type: application/json

[{
    "destination": "email@example.com",
    "type": "email",
    "description": "Email me"
},
{
    "destination": "https://hooks.slack.com/services/example",
    "type": "slack",
    "description": "Alert slack"
}]

Status Codes:

  • 200 - OK

Obtain alerts info

GET /v2/alerts/prom/alerts/ - Returns a list of all active alerts.

Curl example:

curl -X GET "https://YOUR-API-KEY@api.hostedgraphite.com/v2/alerts/prom/alerts/"

Response format:

HTTP/1.1 200
Content-Type: application/json

[{
    "state": "Alert status",
    "labels": {"<Key-value pairs of labels>"},
    "annotations": {"<Key-value pairs of annotations>"},
    "value": "2.98e+00",
    "activeAt": "2020-07-22T11:44:49.564128025Z"
}]

Status Codes:

  • 200 - OK

Obtain rules info

GET /v2/alerts/prom/rules/ - Returns list of alerting rules.

Curl example:

curl -X GET "https://YOUR-API-KEY@api.hostedgraphite.com/v2/alerts/prom/rules/"

Alert response format:

HTTP/1.1 200
Content-Type: application/json

{
"groups": [
    {
        "name": "example",
        "rules": [
            {
                "alerts": ["<List of triggered alerts with this rule>"],
                "name": "Name of the alert",
                "labels": { "<Key-value pairs of labels>" },
                "evaluationTime": 0.004250918,
                "lastEvaluation": "2020-07-22T11:39:49.564325153Z",
                "state": "Alert rule status 'inactive/firing'",
                "health": "ok",
                "duration": 0,
                "query": "Alert expression",
                "lastError": "",
                "type": "alerting",
                "annotations": {"<Key-value pairs of annotations>"}
            }
        ],
        "interval": 60,
        "evaluationTime": 0.012137449,
        "file": "rules.yaml",
        "lastEvaluation": "2020-07-22T11:39:49.564312072Z"
    }
]}

Status Codes:

  • 200 - OK