cancel
Showing results for 
Search instead for 
Did you mean: 
Create Post

Pushing OpsGenie alert changes into Solarwinds with Marid

2016-06-12 Updated script: Solarwinds 12.x appears to have deprecated the AddNote() action for the Orion.AlertStatus object so that it can't append comments to alerts for some kinds of Solarwinds objects (e.g. Hardware Sensors). Instead, you must use the AppendNote() action and the Orion.AlertActive object if you want this script to work reliably with alerts for all kinds of Solarwinds objects. To use the new script, you must make three changes in Solarwinds and in OpsGenie.

  1. In any Solarwinds alert action that sends updates to OpsGenie, add the line "AlertObjectID=${N=Alerting;M=AlertObjectID}&" to the POST body. Orion.AlertActive.AppendNote() requires this value.
  2. In OpsGenie, modify your Solarwinds integration. In the "Extra Properties" section, add an entry with the name "AlertObjectID" (no quotes) and the value "{{AlertObjectID}}" (no quotes).
  3. In OpsGenie, modify your Marid integration. In the "Extra Properties" section, add an entry with the name "AlertObjectID" (no quotes) and the value "{{AlertObjectID}}" (no quotes).

Description

We're using OpsGenie to notify our on-call engineers when an alert is triggered in Solarwinds. OpsGenie provides a pre-built integration tool for getting Solarwinds alerts into OpsGenie. However, they don't deliver a method for getting updates to OpsGenie alerts back into Solarwinds. I wanted the engineers to be able to manage both the OpsGenie alert and the original Solarwinds alert with a single action.

OpsGenie provides the Marid integration server free of charge. The Marid server subscribes to your OpsGenie account and is aware of any updates to your OpsGenie alert actions (close, delete, add note, acknowledge, etc.).

I created the Groovy script SolarwindsActionHandler.groovy to act on OpsGenie's Close, Acknowledge, and AddNote actions. When everything is configured, closing or acknowledging an alert in OpsGenie will acknowledge the corresponding alert in Solarwinds (since you can't manually close an alert in Solarwinds). Adding a note in OpsGenie will add a comment to the alert in Solarwinds.

Requirements

An OpsGenie account, configured to handle alerts originating from your Solarwinds server

A Marid installation on a server you manage

A Solarwinds account that can acknowledge alerts

Configure OpsGenie

Edit your Solarwinds integration. In the "Extra Properties" section, add an entry with the name "AlertObjectID" (no quotes) and the value "{{AlertObjectID}}" (no quotes).

pastedImage_8.png

Edit your Marid integration. In the "Extra Properties" section, add an entry with the name "AlertObjectID" (no quotes) and the value "{{AlertObjectID}}" (no quotes).

pastedImage_9.png

Configure Marid

Copy the attached script SolarwindsActionHandler.groovy to the /var/ops/opsgenie/marid/scripts directory on your Marid server. Correct the permissions and ownership:

chmod 775 /var/ops/opsgenie/marid/scripts/SolarwindsActionHandler.groovy 
chown opsgenie:opsgenie /var/ops/opsgenie/marid/scripts/SolarwindsActionHandler.groovy

Edit /etc/opsgenie/marid/marid.conf  as follows.

Find the lines beginning with:

actions.AddNote.script= 
actions.Close.script=
actions.Acknowledge.script=

and change them to:

actions.AddNote.script=SolarwindsActionHandler.groovy 
actions.Close.script=SolarwindsActionHandler.groovy
actions.Acknowledge.script=SolarwindsActionHandler.groovy

Add this section at the end of the file, substituting appropriate values for your Solarwinds installation:

solarwinds.url=https://<your solarwinds server IP or FQDN>:17778
solarwinds.host=<your solarwinds server IP or FQDN>
solarwinds.login=<name of Solarwinds user that can acknowledge alerts>
solarwinds.password=<password for Solarwinds user that can acknowledge alerts>

Restart Marid:

service marid restart
Attachments
Comments

This is great content. Question, what permissions/ownership do you set for the SolarwindsActionHandler.groovy file in Windows?

We're running Marid (with Groovy scripts) on Linux, not Windows. Permissions on SolarwindsActionHandler.groovy in Linux are:

chmod 775 /var/ops/opsgenie/marid/scripts/SolarwindsActionHandler.groovy

chown opsgenie:opsgenie /var/ops/opsgenie/marid/scripts/SolarwindsActionHandler.groovy

So in Windows, you'd want to grant Read permissions to everyone and Execute permissions to the service account that's going to run the scripts.

Any chance i could see your working marid.conf file? im having some real issues getting this integration flowing back into solarwinds.
Of course blank your URL, USERNAME, PASSWORD and API KEY.

Would be great if you could replace your specific values with the capitalised words so i know where and what information is actually required for a working integration

Many thanks if i can see a copy!

Sure! Here's our (redacted, of course) marid.conf file.

######################################## MARID CONFIGURATION ##################################################

######################################## PROXY SERVER CONFIGURATION ############################################

http.proxy.server.enabled=false

http.proxy.server.port=11111

http.proxy.server.host=localhost

######################################## PROXY CONFIGURATION FOR EXTERNAL HTTP REQUESTS FROM MARID##############

http.proxy.enabled=false

######################################## HTTP SERVER CONFIGURATION ############################################

######################################## HTTPS SERVER CONFIGURATION ############################################

https.server.enabled=false

#######################################ALERT ACTION SCRIPT CONFIGURATION #####################################

actions.AddNote.script=SolarwindsActionHandler.groovy

actions.Delete.script=SolarwindsActionHandler.groovy

actions.Close.script=SolarwindsActionHandler.groovy

actions.Acknowledge.script=SolarwindsActionHandler.groovy

##############################################################################################################

##########################################SOLARWINDS SPECIFIC VALUES##########################################

solarwinds.url=https://solarwinds.yourcompany.com:17778

solarwinds.host=solarwinds.yourcompany.com

solarwinds.login=SolarwindsAccountName

solarwinds.password=SecretPassword

##############################################################################################################

Does anyone have a version of the groovy script that handles an un-acknowledge?

It looks like the Marid integration configuration in OpsGenie doesn't allow you to specify an action for UnAck. If they ever add support for UnAck, the handler will look something like this (not tested):

void unAcknowledgeSolarwindsAlert(String alertObjectId, String comment) {

    String url = _conf("url", true) + "/SolarWinds/InformationService/v3/Json/Invoke/Orion.AlertActive/Unacknowledge"

    def requestParameters = [:]

    def requestHeaders = ["Content-Type":"application/json"];

    def contentArray = [

        [

                [

                "alertObjectId":alertObjectId

                ]

        ]

        ]

    def builder = new groovy.json.JsonBuilder(contentArray);

    String content = builder.toString();

    logger.warn ("Unacknowledgement details: ${content}");

    def post = ((OpsGenieHttpClient) HTTP_CLIENT).preparePostMethod(url, content, requestHeaders, requestParameters);

    sendHttpRequestToSolarwinds(post);

}

Hi,

We are trying to integrate the OPsgenie to Solarwinds and as part of it I am trying to configure Opsgenie create and close alert with a specific test device with a particular alert condition. By using send GET or POST request to server I have added the opsgenie API key URL and added variables. After creating alert, I have tested the alert, I can see the alert being generated in Solarwinds but http request to opsgenie is getting failed. No communication is being initiated to Opsgenie to check the logs from their end. I have approached Solarwinds but they finally said that we are only supporting our licensed products but not the integration to other tools. Can someone please help on what the issue is causing the http request to fail.

Can you show the HTTP action configuration here, please?

Here is the http body to post:

ActionType=Create&

alias=${N=Alerting;M=AlertObjectID}-${N=Alerting;M=AlertID}&

ObjectID=${N=Alerting;M=AlertObjectID}&

NodeName=${NodeName}&

AlertID=${N=Alerting;M=AlertID}&

AlertDefID=${N=Alerting;M=AlertDefID}&

AlertName=${N=Alerting;M=AlertName}&

AlertMessage=${N=Alerting;M=AlertMessage}&

AlertDescription=${N=Alerting;M=AlertDescription}&

AlertDetailsUrl=${N=Alerting;M=AlertDetailsUrl}&

DownTime=${N=Alerting;M=DownTime}&

AcknowledgeUrl=${N=Alerting;M=AcknowledgeUrl}&

Acknowledged=${N=Alerting;M=Acknowledged}&

AcknowledgedBy=${N=Alerting;M=AcknowledgedBy}&

AcknowledgedTime=${N=Alerting;M=AcknowledgedTime;F=DateTime}&

AlertTriggerCount=${N=Alerting;M=AlertTriggerCount}&

AlertTriggerTime=${N=Alerting;M=AlertTriggerTime;F=DateTime}&

LastEdit=${N=Alerting;M=LastEdit;F=DateTime}&

ObjectType=${N=Alerting;M=ObjectType}&

Severity=${N=Alerting;M=Severity}&

TimeOfDay=${N=Alerting;M=TimeOfDay}&

DateTime=${N=Generic;M=DateTime;F=DateTime}&

teams=<comma_separated_list_of_teams>&

tags=<comma_separated_list_of_tags>

I don't believe you can use HTTP for POST actions to OpsGenie. You'd need to use HTTPS.

My apologies here,

I am actually using HTTPS to send post to Opsgenie

Thanks. The message body looks good. Can you post your URL (without the API key)? It should look like https://api.opsgenie.com/v1/json/solarwinds?apiKey=*************** . Make sure you're using HTTPS, t...

https://api.opsgenie.com/v1/json/solarwinds?apiKey=

Here is the API url. Yes I am using HTTPS in solarwinds to send post

Didn't they recently change it to v2 instead of v1? Thus, the POST should go to: https://api.opsgenie.com/v2/json/solarwinds?apikey=********

Forgive me if I'm incorrect in my thinking, it's been a few months since I've touched this. Was at my old job.

I am also trying to set up Bi-Directional communication with OpsGenie....can someone tell me if the above marid config example is still accurate? the new version of marid config file likes like the below.... do i still just add my api key and add the section for my solarwinds info?

and what about the action script config? those are now inside the file folder in the marid download...do i still add each one in the config as show in an earlier post?

pastedImage_0.png

They did implement API v2, but they're still supporting v1 for event creation. My event actions still point to v1.

Yes, that's still the correct way to configure Marid. For example, my marid.conf Alert Action section looks like this:

#######################################ALERT ACTION SCRIPT CONFIGURATION #####################################

#actions.<action_name>.script=<script_file_name>

actions.AddNote.script=SolarwindsActionHandler.groovy

actions.Delete.script=SolarwindsActionHandler.groovy

actions.Close.script=SolarwindsActionHandler.groovy

actions.Acknowledge.script=SolarwindsActionHandler.groovy

actions.Unacknowledge.script=SolarwindsActionHandler.groovy

actions.Unmanage_24_hrs.script=SolarwindsActionHandler.groovy

actions.Poll_Now.script=SolarwindsActionHandler.groovy

##############################################################################################################

OK, that looks correct. One other thing to check - go to "Manage Alerts" and click on the Action Manager tab. Find your OpsGenie action in the list of actions, and make sure it's enabled.

Yes the opsgenie alert is enabled as well

Hi Milligan,

Were you able to check my http post body.

Version history
Revision #:
1 of 1
Last update:
‎03-10-2016 06:21 PM
Updated by: