Jor-El
Jor-El

Reputation: 437

How to create contact point in grafana using API?

I am trying to create a contact point in grafana for pagerduty using grafana API.

Tried with the help of these URLS: AlertProvisioning HTTP_API API call reference

YAML reference of data changed to JSON and tried this way, the YAML reference

But getting error as

{"message":"invalid object specification: type should not be an empty string","traceID":"00000000000000000000000000000000"}

My API code below, replaced with dummy integration key for security.

curl -X POST --insecure -H "Authorization: Bearer XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -H "Content-Type: application/json" -d '{
  "contactPoints": [
    {
      "orgId": 1,
      "name": "test1",
      "receivers": [
        {
          "uid": "test1",
          "type": "pagerduty",
          "settings": {
            "integrationKey": "XXXXXXXXXXXXXXXX",
            "severity": "critical",
            "class": "ping failure",
            "component": "Grafana",
            "group": "app-stack",
            "summary": "{{ `{{ template \"default.message\" . }}` }}"
          }
        }
      ]
    }
  ]
},
  "overwrite": false
}' http://XXXXXXXXXXXXXXXX.us-east-2.elb.amazonaws.com/api/v1/provisioning/contact-points

Upvotes: 2

Views: 2068

Answers (2)

ruslanqa900
ruslanqa900

Reputation: 1

If you didn't know how enable swagger in grafana. You need add swaggerUi = true in [feature_toggles] section in grafana.ini and restart your service or pod or container I hope that this information will be useful for somebody

Upvotes: 0

Jan Garaj
Jan Garaj

Reputation: 28666

I would recommend to enable Grafana swagger UI. You will see POST /api/v1/provisioning/contact-points model there:

enter image description here

Example:

{
  "disableResolveMessage": false,
  "name": "webhook_1",
  "settings": {},
  "type": "webhook",
  "uid": "my_external_reference"
}

Upvotes: 2

Related Questions