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.

Slack - Alert Integration - Node

This article shows how to setup this script as an alert action. Please take time to review the main overview article if you have not already done so: Slack Alert Integration - Overview . The main overview article contains information necessary to completely setup this script.

This script is specifically designed for node based alerts.

7.png

In the Trigger Actions I added 'Execute an External Program' action.

5.png

This is the full text in the 'Network path to external program' field.

  • C:\windows\system32\windowspowershell\v1.0\powershell.exe -ExecutionPolicy unrestricted -command "<C:\path\to\script>\Slack_Alert_Trigger_Action_Node.ps1 '${N=SwisEntity;M=DisplayName}' '${N=SwisEntity;M=Status;F=Status}' '${N=Alerting;M=AlertDetailsUrl}' '${N=SwisEntity;M=DetailsUrl}' '${N=Alerting;M=AcknowledgeUrl}' '${N=Generic;M=DateTime;F=OriginalValue}'"

**You will need to update the <C:\path\to\script> in the above line to the location that you have the script saved.**

I'm passing in the following Orion variables:

  • Node Name: ${N=SwisEntity;M=Node.DisplayName}
  • Node Status: ${N=SwisEntity;M=Status;F=Status}
  • Alert Details Page: ${N=Alerting;M=AlertDetailsUrl}
  • Node Details Page:${N=SwisEntity;M=DetailsUrl}
  • Auto Acknowledge URL: ${N=Alerting;M=AcknowledgeUrl}
  • Orion Date/Time: ${N=Generic;M=DateTime;F=OriginalValue}

Once that alert action is completed then copy it to Reset Actions.

Finish editing the alert and you should be done.

**Change Log**

  • 2016-03-02 : Initial Release
  • 2016-03-18 : Added Alert Name variable into action. Updated and cleaned up script.
  • 2016-03-22 : Removed Alert Name variable from alert action.
  • 2016-05-06 : Major overhaul. revamped message to Slack attachments for better formatting. Please also update your 'Network path to external program' in the alert action as some variables have been changed/added.

If you find this useful feel free to rate this article.

Slack_Alert_Trigger_Action_Node.ps1
  • chad.every  This works great for most alerts, but when I apply it to the alert for "node rebooted", it just sends to slack that the node is up.  is there a way to modify either the script or the variables sent to it to say node rebooted?

  • Yeah, the script can be reworked to accommodate server reboots. Might have to adjust what variable(s) are being passed. Or just hard code the message output stating the server was rebooted.

  • it appears that in NPM 12.2 you can simply use the HTTP post action, the catch here is that if the destination services utilized a specific format of the API, then the message of the alert must be in the in that format.

    for example, when doing http post form Orion to Slack channel and you have the API sting, the body of the POST message must be in JSON format otherwise you will get http error msg.

    You can then simulate the alert and make sure it works.

    Body to POST

    {
       "text": "this is ONLY a test"

    }

    Incoming Webhooks | Slack

  • Our Slack Node Alerts were working but now have stopped.

    Log report shows: WARNING - The request was aborted: Could not create SSL/TLS secure channel. 

  •  

    Slack has changed it's support of TLS to only include TLS 1.2 or higher.

    https://api.slack.com/changelog/2019-07-deprecate-early-tls-versions

    These Powershell scripts rely on Invoke-RestMethod which will only use TLS 1.0 by default. Server 2016 for example only has SSL 3 and TLS enabled by default.

    You can control TLS support per-session by using the below by including it in the script(s). This will make TLS 1.2 the only option for the session it is ran in.

    [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

    You can also enable support of additional ciphers in Powershell on the entire system by doing:

    Set-ItemProperty -Path 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NetFramework\v4.0.30319' -Name 'SchUseStrongCrypto' -Value '1' -Type DWord


    Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\.NetFramework\v4.0.30319' -Name 'SchUseStrongCrypto' -Value '1' -Type DWord

    The above registry modifications will result in additional ciphers being supported in Powershell permanently which can be checked with

    [Net.ServicePointManager]::SecurityProtocol
  •  Sorry for the late response.

    Thank you for replying back. I did everything you suggested and it works perfectly!

  •  @chad.every   What is the best alert conditions so to utilize the the "up", "down", and "critical" alerts?