Solarwinds Alerts to Slack

I've read through the Incomplete guide, and tried to use the curl command they gave for a interface down alert, however it doesn't seem to work.  Would anyone be able to give an example of the alert for interface down.  Either using send to external program to use curl, or send a POST to webserver.  Hoping to get one working example, then I can try reworking it for other alerts.

Example from pdf(I did edit path, channel, botname, and webhook url):

PATH _ TO _ CURL\bin\curl.exe -X POST --data-urlencode “payload={\”channel\”: \”#YOURCHANNEL\”, \”username\”: \”OrionBot\”, \”text\”: \”Alert - Interface: ${N=SwisEntity;M=Caption} status changed to ${N=SwisEntity;M=Status}\ nView: <${N=Alerting;M=AlertDetailsUrl}|Details>, <${N=SwisEntity;M=Node.DetailsUrl}|Node>\nTo acknowledge click <${N=Alerting;M=AcknowledgeUrl}|here>\”}”, https://YOUR _ SLACK _ WEBHOOK

  • Looks like Slack changed their payload requirements and have gone to a more "block"-centric style.

    This is how I got it to work in PowerShell

    $HookUri = "https://hooks.slack.com/services/NotMy/Real/WebHookUri"
    
    $Payload = [PSCustomObject]@{
        # Blocks MUST be an array - indicated by the @( )
        blocks = @( [PSCustomObject]@{
            type = 'section';
            text = [PSCustomObject]@{
                type = "mrkdwn";
                # In PowerShell the new line character is `n
                text = "Hello, World!`n<thwack.solarwinds.com|THWACK>`n<thwack.solarwinds.com/product-forums/the-orion-platform/f/alert-lab/92775/solarwinds-alerts-to-slack|This Post>"
            }
        })
    }
    Invoke-RestMethod -Uri $HookUri -Method Post -Headers @{ 'Content-Type' = 'application/json' } -Body ( $Payload | ConvertTo-Json -Depth 2 )
    # Your JSON -Depth might need to do deeper if you are embedding things in embedded things in embedded things...
    # A depth of 2 is fine for this simple example.

    You can probably do the same thing with regular curl.exe, but you'll need to linearize the JSON and swap out some quotes to get it to work.

  • Oh - I also noticed that you can't have https:// or http:// in the URL.  Don't know why, but you can't.