Rancher alerts reuse

Hey folks, I have many clusters with enabled monitoring and alerts…but is there a way to create the same alerts in all clusters ? It sounds very strange if I can only add alerts via UI for each cluster… if I need to change an alert - I need to do it everywhere …which is not optimal. Is there a way to create or copy alerts in bulk ? Maybe via api or other way… Thank you for the awesome piece of software!

If you click on the three dots to the right of the alert, there is an option for “View in API”. You can use that to figure out the parameters so you can automate it via the API.

Pro Tip: Almost everything in the Rancher UI also has an API for it. Use the same steps above to see if the thing you want to automate can be edited in the API.

@shubbard343: You say “figure out the parameters” - is there a more or less deterministic way to transform the output of “View in API” (which should be subject to automation itself) into a reusable (yaml-) config? Imho, this process should be more deterministic. I have shortly experimented to recreate a deployment from a File I got from “View in API”, but subsequently I got a new deployment that had different characteristics than what I had entered in the gui - so I postponed further experiments.

If you view something in the Rancher API, there is an “Edit” button in the top right. That button will bring up a form that allows you to edit the fields. At the bottom of that form, there is a “Show Request” button that will show you what a curl command would look like to submit the changes. You would need to write the code to send the request (we use Python) to make changes via the API.

I’m not sure what you mean by: recreate a deployment from a File I got from “View in API”.
Do you mean you tried to use the UI Import YAML function?

@shubbard343 - Thank you that is very helpful! We decided to use Prometheus federation and have all the alerts on another external prometheus, but it’s really awesome that Rancher provides such API capabilities - the CURL requests generation is pretty cool!

Thanks again :slight_smile:

How can I use this API I get in another Rancher cluster? I am unable to find anything on UI for it.