2

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
Jor-El
  • 187
  • 3
  • 11

2 Answers2

1

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"
}
Jan Garaj
  • 25,598
  • 3
  • 38
  • 59
  • can you share steps how to deploy that using helm charts. I am new to grafana, sorry if that is a small question – Jor-El Sep 08 '22 at 10:07
  • @Jor-El sorry, helm is not in the scope of your question - you asked how to create contact point via API, so you have an answer how to create via API. Please accept answer if it is correct answer. – Jan Garaj Sep 08 '22 at 11:59
  • my bad, sorry for that. But for this, I didn't get your steps exactly, can you please send the steps in detail, or any links – Jor-El Sep 08 '22 at 13:00
0

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