Effectively monitor and manage your infrastructure and application health by integrating SCOM with Freshservice. Multiple alerts sent for the same issue from SCOM get automatically aggregated as a single alert record in Freshservice to help you quickly understand and get to the bottom of the issue. 


When SCOM notifies about issue resolution, the corresponding alert record gets resolved in Freshservice as well.


To integrate SCOM with Freshservice:


Configuration in Freshservice:

  • Click on Admin > Alert Profiles > Create a New Alert Profile or open an existing Alert Profile.
  • Click on “Add Integration” to select the tool to integrate with.
  • Select “Microsoft SCOM” in the tool selection page. 
  • Get the Endpoint URL and the Auth key for SCOM by following the integration setup.
  • Click Enable to save the configuration in Freshservice


Configuration in SCOM:


In order to send alerts to Freshservice, a powershell script has to be created

In the following Powershell script, paste the Endpoint URL in  [string]$amsURL and Auth token in [string]$authKey fields and save it as AlertNotification_scom.ps1 in your local storage.


#input parameters from WebHook/Script action

Param(

  [string]$resource,

  [string]$metric_name,

  [string]$severity,

  [string]$message,

  [string]$priority,

  [string]$category,

  [string]$resolution_state_name,

  [string]$timestamp,

  [string]$owner,

  [string]$alert_id,

  [string]$node,

  [string]$web_console_url,

  [string]$amsURL = "Endpoint URL",

  [string]$authKey = "Auth token"

)

if ($severity -eq '1') {

    $severity = 'warning'

} elseif ($severity -eq '2') {

    $severity = 'critical'

} elseif ($severity -eq '0') {

    $severity = 'information'

}

 

if ($resolution_state_name -eq 'Resolved' -Or $resolution_state_name -eq 'Closed') {

    $severity = 'ok'

}

 

if ($priority -eq '1') {

  $priority = 'Medium'

} elseif ($priority -eq '2') {

  $priority = 'High'

} elseif ($priority -eq '0') {

  $priority = 'Low'

}

 

#RestAPI headers

$AuthHeader = @{

  "Content-Type"  = "application/json";

  "Authorization" = "auth-key " + $authKey

}

 

#payload construction

$jsondata = @{

    resource          = $resource;

    metric_name      = $metric_name;

    severity         = $severity;

    message         = $message;

    priority        = $priority;

    category         = $category;

    resolution_state_name = $resolution_state_name;

    timestamp         = $timestamp;

    owner         = $owner;

    alert_id          = $alert_id;

    node          = $node;

    web_console_url     = $web_console_url;

}

 

#remove empty keys

($jsondata.GetEnumerator() | ? { -not $_.Value }) | % { $jsondata.Remove($_.Name) }

 

#convert to json object

$Body = ConvertTo-Json $jsondata

Write-Host $Body

 

#To Fix UnauthorizedAccess due to TLS protocol version

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls -bor [Net.SecurityProtocolType]::Tls11 -bor [Net.SecurityProtocolType]::Tls12

 

# Freshservice AMS restapi call

try {

    Invoke-RestMethod -Method Post -Uri $amsURL -Headers $AuthHeader -Body $Body;

     exit 0;

} Catch {

    $ErrorMessage = $_.Exception.Message

    Write-Host "Error: " $ErrorMessage

}




Step 1:  To enable a command notification

  1. Log in to your account as an Administrator

  2. In the Operations console, click Administration.

  3. In the navigation pane, under Notifications, right-click Channels. Click New channel and then click Command.

  4. Type a unique name for this command channel in the Command Notification Channel name field and a brief description in the Description field. Click Next.

  5. Type the path to the executable file that you want to run in the Full path to command file field.

For ex:  C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe

  1. In Command line parameters field, copy and paste the below content. Replace the first line with the file path of your notification script.

Command line parameters:

"C:\scom_notification\AlertNotification_scom.ps1" -resource '$Data/Context/DataItem/ManagedEntityDisplayName$' -metric_name '$Data/Context/DataItem/AlertName$' -severity '$Data/Context/DataItem/Severity$' -message '$Data/Context/DataItem/AlertDescription$' -priority '$Data/Context/DataItem/Priority$' -category '$Data/Context/DataItem/Category$' -resolution_state_name '$Data/Context/DataItem/ResolutionStateName$' -timestamp '$Data/Context/DataItem/TimeRaisedLocal$' -alert_id '$Data/Context/DataItem/AlertId$' -node '$Data/Context/DataItem/ManagedEntityFullName$' -web_console_url '$Target/Property[Type="Notification!Microsoft.SystemCenter.AlertNotificationSubscriptionServer"]/WebConsoleUrl$?DisplayMode=Pivot&AlertID=$Data/Context/DataItem/AlertId$'


  1. Type the directory for this command in the Startup folder for the command line field.

For ex: C:\scom_notification

  1. Click Finish and then click Close.

Step 2: To create a notification subscriber 

  1. Log in as an Administrator in your account

  2. In the Operations console, click Administration.

  3. Under Notifications, right-click Subscribers, and click New subscriber.

  4. On the Description page, type a display name for this subscriber.

  1. On the Schedule Notifications page, click Always send notifications

  2. On the Subscriber Addresses page, click Add to add subscriber addresses to the notification.

  3. On the Describe the Subscriber Address page, enter a name to identify the subscriber address, and then click Next.

  4. On the Provide the Channel and Delivery Address page, perform the following steps:

    1. In Channel Type, select command for the method of notification.

    2. In Command Channel, select the name of a command channel. Click Next.

  5. On the Schedule Notifications page, click Always send notifications, or Notify only during the specified times and click Add to create a date range, and then click Next.

  6. Click Add to define another subscriber address. Otherwise, click Finish, and then click Close.

  1. The new subscriber displays in the Subscribers pane.



Step 3: To create a notification subscription

  1. Log on to the computer with an account that is a member of the Operations Manager Administrators role.

  2. In the Operations console, click Administration.

  3. In the Administration workspace, expand Notifications, right-click Subscriptions, and then click New subscription. The Notification Subscription Wizard starts.

  4. On the Description page, in Subscription name, type a descriptive name for the subscription, type a short description, and then click Next.

  1. On the Subscription Criteria page, you can set conditions that will determine when notifications will be sent to specified subscribers. If you do not set conditions, notifications will be sent for all alerts. Click Next.

  1. On the Subscribers page, click Add to add subscribers who are already defined.

  1. Click Next.

  2. On the Channels page, click Add to add a channel that is already defined.

  3. In the Alert aging section on the Channels page, select to send notifications without delay or set a value in minutes that notification should be delayed unless conditions remain unchanged, and then click Next.

  1. Review the settings on the Summary page.

    

Click Finish, and then click Close.


When SCOM sends out alert notifications, it will create an aggregated alert record in Freshservice.