NGalert / Grafana 8 alert feature: How to export / import alerts as yml/json?

Hello, is it possible to export all alerts of the new Grafana 8 alerts to a json or yml file like all the other dashboards (and use it later in the provision process)? We want to have all our infrastructure as code and therefore want to have everything available in files and not in the Grafana database.

Greetings and thanks in advance,
Tobias

11 Likes

#2.

@kaeset: Did you find out how to do this?

1 Like

No, not yet. From my current point of view this is not possible.

ok, thanks for the quick response. If you find out how to do it, I would be really thankful for a small update/link :-).
My first try will be on use a custom DB and not the interal sqllite3 db where this kind of data is stored.

1 Like

Yes this sounds like a good solution. But I’ll keep you updated if I find out anything…
And for me this is a must… Hope they will add this in a few versions.

I have the same issue. Any update…?

2 Likes

Provisioning alerts is also a must for our team.

Bumping this issue :slight_smile:

2 Likes

bumping too cos export reimport is a must

+1 export/import of all alerts/dashboards would be much appreciated.

I wrote a small javascript function to export all the alert info I need by utilizing the Grafana API. One should be able to write a similar API-based import facility for a full backup and restore cycle.
https://community.grafana.com/t/grafana-8-how-to-import-export-alerts-in-unified-alert-section/50431/11?u=fedorg

3 Likes

This feature is a must to deploy over multiple stages or production instances. In my case we have multiple kubernetes cluster for production use. And the import feature using a configmap is great. I wish to have this for unified alerts as well.

2 Likes

Hi an export of the alerts is definitely possible, using the API:
curl -X GET -H “Authorization: Bearer TOKEN” -H “Content-type: application/json” ‘http://IP:3000/api/ruler/grafana/api/v1/rules/{Namespace}’ | jq > alerts.json
This outputs a json file with all alerts from the given namespace.
The Problem is importing this data to another grafana instance,

curl -X POST -H “Authorization: Bearer TOKEN” -H “Content-type: application/json” -d “$(cat alerts.json)” ‘http://IP2/api/ruler/grafana/api/v1/rules/{namespace}

outputs the error {“message”:“rule group name is not valid”}.

Does anyone know a solution?

3 Likes

+1 definitely need import/export of alerting rules to be able to deploy them across various stages

+1 on this and also wondering if there is an update. Since the alerts are still linked and stored in the dashboard jsons (at least before v8, as far as I am aware) but don’t show up in the new alert rules, it seems related to this GitHub issue when upgrading from v8.2 to v8.3. I’m hoping the fix for this will also involve a separate export possibility for alert rules.

This is much needed, there must be a way to import/export alerts to make it easy to provision alerts.

2 Likes

+1 export/import of all alerts/dashboards would be much appreciated.

+1 export/import feature would be very helpful

Any alternative of export alert rules to grafana ?

+1. Incredibly necessary feature.

+1, we are stuck on upgrading our OSS Grafana instance without this feature