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

Slack Alert Integration - Overview

Overview

I've created some Powershell scripts that call into Slack's API and pass the necessary info from Orion. This works great to receive alerts to a specific Slack channel.

Prerequisites:

  • Need to install Powershell v3 or greater on your Solarwinds Orion server. We specifically use the Invoke-RestMethod cmdlet. You can download that here.
  • Need to create a team with Slack if you have not already done so.
    • Need to setup an incoming Web Hook. Here is a link that talks about how that can be set up.
  • Download the scripts at links right below this section
    • Place them in a directory on your Orion server
    • Edit each script and fill out the necessary sections in the beginning. That information is most likely going to be exactly the same for each script.

Configuration

Below are links that outline different alert types in Orion, each with it's own instructions and custom Powershell script.

Slack - Alert Integration - Node

Slack - Alert Integration - Node CPU

Slack - Alert Integration - Node Memory

Slack - Alert Integration - Node Disk

Slack - Alert Integration - Node Response Time

Slack - Alert Integration - Node Packet Loss

Slack - Alert Integration - Interface

Slack - Alert Integration - Application

Slack - Alert Integration - Component

Screenshot of how this is formatted in Slack.

2016-05-05 14_30_05-Slack - LehiSalesEngineering.png

Please check back often to see if there have been any improvements or bug fixes to this script.

**Change Log**

  • 2016-03-01 : Initial release
  • 2016-03-18 : Added new scripts and refreshed already existing ones.
  • 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.

Comments

Thanks for posting these chad.every​. I don't see a version for volume capacity alerts; if I were to adapt one of these scripts to provide a volume capacity alert, will it work for Windows volumes that contain backslashes (and thus need "escaping")? There's probably a way to do that in PS - I am just unaware of it. Thanks again!

Yeah, you should be able to adapt any of these scripts to your liking. Does the Node Disk script not cover what you're looking for for volume alerts?

It does, and successfully passes backslashes through - yay! (I just missed it - either not enough coffee - or too much of it - 40+ years of drinking it - still can't get it right)

haha, nice! glad to hear it works!

Hi,

I was trying to implement the host and interface checks via the PS scripts. If I open them in the powershell editor adopt the variables and test it I see the test post in Slack but if I create an Alert in Solarwinds and test it inside the Alert I don't get anything in my Slack channel. Any idea what I'm doing wrong or what I'm missing?

Thanks for any help,

Chris

Try changing the following Windows services to not run as 'Local System' and to run as either a local or domain account. Restart services once changed.

  • Orion Module Engine
  • Alerting Engine
  • Alerting Service v2

I've seen similar issues of the script working outside of Orion but not inside. Changing these services seem to have fixed that for me.

Thanks I tried changing it and it didn't work, so I ended up double-checking the path to the script and saw that I had a typo in there. At the beginning of the path I didn't delete the < sign. After that I tested with a domain account on the services as well as the local account and both options are working now.

Thanks for your help!!

Hello guys,

I have the same issue. The script works outside Orion, but inside there is some problem. I tried create a bat file to execute the command, even so, it seems something internal in the Orion Server, as if it doesn't got call the command/procedure.

I made all the changes that you suggested but no way. Anything else do you think?

Tks for the reply and for the great job.

Thanks for posting these chad.every.  Every click in THWACK gets me a little further, I do appreciate you sharing the scrips! 

If i execute the file manually in powershell am getting the message in SLACK if i run via solarwinds alert external program am not getting any message. Kindly help me in tis issue.

Try updating the SolarWinds Orion Module Service to run as either a local Windows account or an AD account. I've seen issues with Orion executing scripts when that service runs as 'Local System'.

Currently am trying to run in local system account if i change to another account it asking for some special permission.

The Alert Detail and Acknowledgement Links are being created properly.

pastedImage_0.png

Any ideas?

Hi All,

Do you have a template script for Alert Acknowledgement? I want to be informed as well when someone Acknowledge an alert.
We do have an existing Alert created for acknowledgment and this will inform us through email. We use the variable ${ObjectName} in the subject field and that alone tells us who acknowledge the alert and what alert has been acknowledged.
But that variable won't work for Slack.

We run the script through "Execute An External Program" in Orion:

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File C:\Scripts\SlackSender.ps1 "${ObjectName}" "${N=Generic;M=DateTime;F=OrigianlValue}"


Below is my powershell script:
============================================================================================================================================

#Define Params to make life easy

param([string]$Object,[string]$ORIONTIME)

# Define varilables

$curl = 'C:\sw_tools\cURL\bin\curl.exe'

$icon = 'https://lh3.googleusercontent.com/-SV1-YUgXozE/AAAAAAAAAAI/AAAAAAAABFE/LVzp7vgXZbs/photo.jpg'

$webhook = 'https://hooks.slack.com/services/xxxxxxxxxxxxxxxxxxxxxxxxx'

$channel = 'orion-alerts'

$username = 'OrionBot'

$myarg = '-X POST --data-urlencode "payload={\"channel\": \"#' + $channel + '\", \"username\": \"' + $username + '\", \"text\": \"What: ' + $Object + '\nTime: ' + $ORIONTIME + '\", \"icon_url\": \"' + $icon + '\"}" ' + $webhook

Start-Process $curl -ArgumentList $myarg


============================================================================================================================================

One quick feedback, on the Slack - Alert Integration - Node Disk it triggers an OK status for 100 % occupation, when comparing to 90 for example, because of the if condition comparing strings:

if ($VOLUMEPERCENTUSED -ge $VOLUMECRITICALTHRESHOLD) {$VOLUMESTATUS = "Critical"}


Do you have a pre-built alert for Transaction Failures with slack integration?

I am getting the below error when trying to access the link for the Web Hook,

 

jkoziol_0-1586551567634.png

 

Great contribution your publication, I am trying to implement it in my productive environment, but I am receiving the following error - - WARNING - The underlying connection was closed: An unexpected error occurred on a receive.

Version history
Revision #:
1 of 1
Last update:
‎03-02-2016 09:30 PM
Updated by: