This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

Is there any way to change the TriggeredMessage of an Alert using the SDK?

I am trying to modify the text of an alert after firing in order to make it more useful. I have a trap and I want to pass it along to an external script in order to extract a substring from it, so far so good. What I can't seem to find is how can I update the TriggeredMessage field in the database after I've extracted the substring. I tried swis.query('UPDATE... (I am using python) but (un)fortunately it does input validation and doesn't let me abuse it like this.

Is there any other way to do it? From what I can tell swiss.update only works if you have an uri and I cannot find one for the AlertActive tabel.

LE: Found the uri, but it doesn't let me change TriggeredMessage. emoticons_sad.png Here is the error:

raise HTTPError(http_error_msg, response=self)

requests.exceptions.HTTPError: 403 Client Error: Operation not supported on Orion.AlertActive for url: localhost:17778/.../AlertActiveID=221,AlertObjectID=89

and the code:

swis.update(Uri, TriggeredMessage='Am reusit!')

  • I'd think you will have better luck updating the orion.alertconfiguration.Trigger value.   Alert active is more of a historical record of what happens after an alert fires.   The alert configuration is where those decisions about what needs to happen are made.   The trigger and reset are pretty big blocks of xml so it may take a bit to find the section to change, but your case might be simple enough for something like a straight replace(trigger, 'old message', 'new message').

  • I don't quite understand what you are proposing, there is no way of making the trigger extract the substring I want, that is why I am using an external script. What I am trying to do is out of a trap like this: IF-MIB:linkDown : sysUpTime = 3 hours 11 minutes 44.96 seconds, ifIndex.10 = 10, ifDescr.10 = Tunnel11, ifType.10 = 131, locIfReason.10 = Tunnel Down

    I want to display on the router in question just the 'Tunnel Down' string as the alert message. This is just an example, not the real trap I am working with.

  • The reason I suggested you make the change inside the alertconfiguration is first of all because alertactive is not editable in the API, so its a non-starter right out of the gate.  If you wanted to change a message you need to change the alertconfiguration before the event actually happens.  If you did manage to edit the alertactive it still wouldn't be much help since the alert message would already have been emailed out unless you intentionally added a lag time between the alert firing to allow your script to make the change before the email gets sent.  All of this is adding WAY too much complexity to the issue.

    So the root issue is you just want to display a substring of the message instead of the whole message, no need for any external complicated scripting or using the API anyway.  SWQL has substring() and charindex() functions so you can just handle it directly in Orion with SWQL or SQL with a custom variable.

    Something like this should work as a custom SWQL variable:

    ${N=SWQL;M=select top 1 substring('${N=OLM.AlertingMacros;M=OLMAlertMessage.EventMessage}',charindex('locIfReason','${N=OLM.AlertingMacros;M=OLMAlertMessage.EventMessage}')+17,20)

    from orion.nodes n}

    pastedImage_1.png

    I expect that's pretty similar to what you were doing in your external script, but there's not reason to add that all in when you can make it happen natively.

  • This seems like a really nice solution, thank you. What does the +17,20 do? Is it telling it how many chars to print after 'locIfReason.10 ='?

  • I tried using the SWQL variable, but it does not return the truncated substring.  Instead my code is returned along with the full string of the OLMAlertMessage.EventMessage.  What am I missing?

  • Post a screenshot of exactly how you have it set up and the result when it runs, when the whole query displays it usually indicates a syntax mistake was made somewhere.

  • Alert Configuration:

    Alert Configuration.png

    Result:

    Alert Result.png

  • Do you have an IBM DataPower Gateway in your environment?  It looks like the error might be originating from there.

  • It's a trap from a Datapower device....emoticons_confused.png

  • Looks like I made a mistake in the version I posted before, needed to assign a name to the column in SWQL or it wont run.

    Try this

    ${N=SWQL;M=select top 1 substring('${N=OLM.AlertingMacros;M=OLMAlertMessage.EventMessage}',charindex('locIfReason','${N=OLM.AlertingMacros;M=OLMAlertMessage.EventMessage}')+17,20) as message

    from orion.nodes n}