I figured it by myself
The problem was that I tried to change just a part of an alert, which was kinda intuitive for me, but not appropriate for Provisioning API. Instead, I should have specified the whole configuration of an alert, not only 'title'
.
So, the 'data'
JSON must look like this:
data = {
'id': 294,
'uid': auid,
'orgID': 1,
'folderUID': 'Your folder UID',
'ruleGroup': 'Your rule group',
'title': 'Your alert title',
'condition': 'A',
'data':[
{
'refId': 'The name of query',
'queryType': 'sql',
'relativeTimeRange': {'from': 18221112, 'to': 0},
'datasourceUid': '7eMUser7k',
'model': {
'format': 0,
'intervalMs': 1000,
'maxDataPoints': 43200,
'meta': {
'builderOptions': {
'fields': [],
'limit': 100,
'mode': 'list'
}
},
'queryType': 'sql',
'rawSql': "select 'Hi' ",
'refId': 'The name of query'
}
},
{
'refId': 'A',
'queryType': '',
'relativeTimeRange': {'from': 0, 'to': 0},
'datasourceUid': '-100',
'model': {
'conditions': [
{
'evaluator': {'params': [-3], 'type': 'lt'},
'operator': {'type': 'and'},
'query': {'params': ['The name of query']},
'reducer': {'params': [], 'type': 'last'},
'type': 'query'
}
],
'datasource': {'type': '__expr__', 'uid': '-100'},
'hide': False,
'intervalMs': 1000,
'maxDataPoints': 43200,
'refId': 'A',
'type': 'classic_conditions'}}],
'noDataState': 'OK',
'execErrState': 'OK',
'for': 0,
'annotations': {
'__dashboardUid__': 'dashbourd_uid',
'__panelId__': 'panel_id'
},
'labels': {
'some': 'label'
}
}
When I tried to PUT the whole structure it worked and an alert appeared in Grafana UI.
As not to get confused with this big JSON, I just have sent a GET request to get this JSON, changed what I needed to change and did a PUT request to the same url.
So, basically your are not “updating an existing alert rule” as it is said in documentation, but you are recreating it, because the process of creating of new alert is almost the same, but instead of PUT you are doing POST and without alert UID in the url.