grafana-client icon indicating copy to clipboard operation
grafana-client copied to clipboard

Add x-disable-provenance header to allow alert rules to be edited from the UI

Open jyepesr1 opened this issue 3 years ago • 4 comments

What API call you use?

  • Based on this PR https://github.com/grafana/grafana/pull/58410 which was merged in the new version 9.3.0, we can the header x-disable-provenance to allow the alert rules created under the alert provisioning API to be modifiable via UI.

This can only be added on the POST request, if we try to update with the PUT operation an alert has already been created we got the following error:

{
    "message": "cannot changed provenance from 'api' to ''",
    "traceID": ""
}

What is the actual output?

  • Without the header when the rule is created we cannot edit the alert rules via UI, we got the label "provisioned".

What is the expected output? And what output is expected.

  • Alerts created with the header can be edited via UI like in the s screenshot below image

jyepesr1 avatar Dec 02 '22 20:12 jyepesr1

Hi Johan Sebastian,

that's a very good suggestion, thank you. Are you sure the header should not be attached to the PUT request as well?

Citing the post...

We are enabling a workaround within the Provisioning API to do it by adding the x-disable-provenance header to the following requests:

POST /api/v1/provisioning/alert-rules
PUT /api/v1/provisioning/alert-rules/{UID}

... makes me think the header should be attached to both types of requests, no?

With kind regards, Andreas.

amotl avatar Dec 02 '22 21:12 amotl

I've just submitted #53, following your suggestion. Do you agree with the implementation?

amotl avatar Dec 02 '22 21:12 amotl

Hi @amotl,

Sorry for the delay, I tested on PUT operation and I get the error I mentioned, the error only happens when there is a rule already created without the header and we try to update it.

This is the only consideration!

jyepesr1 avatar Dec 02 '22 23:12 jyepesr1

Hi again,

I tested on PUT operation and I get the error I mentioned, the error only happens when there is a rule already created without the header and we try to update it.

All right. I see, that makes sense. With the new improvements from #53, you will be able to control sending the header on your own behalf, by using the disable_provenance argument on the methods create_alertrule and update_alertrule.

The improvement has been released with grafana-client 3.4.0. Feedback is very much appreciated.

With kind regards, Andreas.

amotl avatar Dec 03 '22 00:12 amotl

Hi @jyepesr1,

have you been able to test the feature successfully?

With kind regards, Andreas.

amotl avatar Dec 19 '22 15:12 amotl

Hi @amotl ,

I was able to test it out successfully. It works like a charm!

Thanks again

jyepesr1 avatar Dec 19 '22 15:12 jyepesr1

Excellent, thank you for reporting back, and for your suggestion in the first place. Cheers, Andreas.

amotl avatar Dec 20 '22 10:12 amotl