- PowerShell 5.0 or later
- .NET 3.5 or later
- Windows 8 or later
Get Opsgenie alerts with PowerShell script using REST API. With the build in config file, the script has flexibility to get whatever you need. Chose automatic refresh period, write custom query, sound alarm, alerts limit, etc.
Here are the key features of the script. It’s a simple and elegant solution to have a full featured monitoring dashboard.
- Trigger sound alarm for new alerts with specific priorities.
- Copy alert URL in the clipboard: From column ‘Link’ mark a value, e.g. ‘id=8’, then press right mouse button.
- Open alert URL in default browser: From column ‘Link’ mark a value, e.g. ‘id=12’ and press Enter.
- Copy full alert info in the clipboard: From column ‘Alert’ mark a value, e.g. ‘og=16’, then press right mouse button.
- Get full alert info in the dashboard: From column ‘Alert’ mark a value, e.g. ‘og=24’ and press Enter. Press escape to go back in the dashboard.
To run the script without modifying the execution policy, simply execute batch file ‘Get-OpsgenieAlerts.bat‘. It will prompt to run the script as administrator.
Following values in config ‘Config.ini’ file must be changed prior to execution.
Address = mycompany.eu.opsgenie.com Api = api.opsgenie.com GenieKey = xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Replace ‘mycompany‘ with the actual business name.
Get a valid ‘GenieKey‘ from your administrator or supervisor.
If the company is located in Europe, then the format of Opsgenie address and REST API is:
Address = mycompany.app.eu.opsgenie.com Api = api.eu.opsgenie.com
Play notification alarm for new alert with priority P1 and P2:
Alarm = P1, P2
Refresh the dashboard on every 3 minutes The value is expressed in seconds:
Refresh = 180
Get up to 200 alerts in the dashboard. It’s mandatory to set a limit to avoid API overload.
Limit = 200
Specify query filter. Example how to fetch alerts in status opened, not acknowledged, priority P1 and P2.
Query = status:open+AND+acknowledged:false+AND+priority>P3
To filter alerts for team ‘my-support’, add in the query ‘responders:my-support’.
For alerts in New Relic only, add in the query ‘integration.type:NewRelicV2’.
Don’t forget to include ‘+AND+’ before and after the string query. Example:
Query = status:open+AND+acknowledged:false+AND+integration.type:NewRelicV2+AND+responders:my-support+AND+priority>P3