grafana_api_sdk icon indicating copy to clipboard operation
grafana_api_sdk copied to clipboard

Question / Request for guidance on provisioning Alerting resources (rules, contact points, etc.)

Open matagyula opened this issue 1 year ago • 0 comments
trafficstars

First of all, thank you for working on this SDK! I am quite a novice when it comes to Python (and to working with REST APIs), and am having a hard time producing the simplest example for creating a new alert rule with this SDK (for what it's worth, I did manage to create a Dashboard using a JSON template).

I suppose that I am feeding the wrong kind of data/template to the function:

...
alerting: Alerting = Alerting(model)
alert_json = "JSON/alert_template.json"

with open(alert_json) as file:
    json_alert = json.load(file)

try:
    alerting.create_or_update_alertmanager_alerts(json_alert, "grafana")
...

Which throws the error message: AttributeError: 'str' object has no attribute 'starts_at'

The JSON template I am trying I got from the Grafana API overview in the Swagger Editor ... I have added the "starts_at" record to the JSON, but no luck.

Thank you for your help in advance, kind regards, Gyuszi

EDIT: I should be using "alerting_provisioning", not just alerting, sorry about that.

matagyula avatar Oct 02 '24 14:10 matagyula