I’m using Grafana 9 managed by helm charts. Setting alerting manually trough UI is fine, but it would be much nicer if I could provision them by helm chart as well. Atm I’m using helm chart ver. 6.29.11 and moving to 6.31.2. Any advice? Or using API is the only way?
I did not. The only progress I have is that I got the alert’s JSON code via the API, but even if I manually set the file into /etc/grafana/provisioning/alerts (tried with both - json and yaml) , it does not appear on the interface.
I posted this by mistake on a Grafana 8 thread. I can’t seem to get json provisioning working via the api on Grafana 9.3.1 on kubernetes (as a first step to provisioning via config files/sidecar).
Can you elaborate on how you managed to do it?
I created an alert in the UI and then exported it:
I would expect to be able to import the exported rule, but when I delete the rule or delete the grafana pod and try and post back to the api I get this error:
if I use the template for the body from here I also get the same error. (That body might be outdated. I will reach out internally about that.)
So, I basically did the same thing. I manually created an alert rule via the UI, like you did (I used TestData as its datasource)
Then I GOT the alert JSON via the /api/v1/provisioning/alert-rules/{UID} endpoint
Finally I used that JSON to POST a new rule (but incrementing the id, leaving the uid empty, and giving it a new title)
but when I delete the rule or delete the grafana pod and try and post back to the api I get this error
Make sure to set the Content-Type: application/json header. You can get bad request data if you send JSON without telling Grafana that the request contains JSON.