Is there a way to disable/enable an alert via command line?

  • 14 July 2021
  • 3 replies

Userlevel 1
Badge +2

I am working on some command line automation and need to disable/enable an alert. I see that qoperation execscript is what I need but not seeing a qscript that will do what I want. Looking to disable an alert. Then the opposite to enable it.

Many thanks!


Best answer by RMcG 14 July 2021, 05:46

View original

3 replies

Userlevel 7
Badge +23

@RMcG - thoughts ? :)


Userlevel 3
Badge +6

I think the simplest method would be to use the REST API. If you want a quick way to do this via the Command Line then you can use the QCurl command

Basic steps...

  • Login using QLogin
  • List the alerts so you can fetch the alert id
    • qcurl -op GET -url "https://{server}/webconsole/api/AlertRule"
  • Disable the alert
    • qcurl -op POST -url "https://{server}/webconsole/api/AlertRule/{alertId}/Action/Disable" -req " "
  • Enable the alert
    • qcurl -op POST -url "https://{server}/webconsole/api/AlertRule/{alertId}/Action/Enable" -req " "

Alternatively if you’re a fan of PowerShell then you can use the Invoke-WebRequest or Invoke-RestAPI method to achieve the same.

Screenshot showing examples of QCurl method in action...

 Alert Operations REST API Docs:

Userlevel 1
Badge +2

Thank you so much! I’ve been using their qoperation cmds and wrapping them around Powershell. I’ve been avoiding the REST API a bit because I don’t fully understand how to implement it. Let me take a look some more. Thanks again!!