With this integration, get trigger alerts from PRTG and have them converted to incidents within Freshservice so you can find quicker resolutions to critical issues.


Note: PRTG supports Windows Powershell script, batch files, and executables.


Step 1: To create a PowerShell script file and add it to the location

 

Given below is a sample of a PowerShell script file. You can create or modify according to your requirements and add it to the location given: <PRTG Network Monitor Home>\Notifications\EXE

# This will send an rest api request to FreshService AMS module.

# Alert will be created based on the payload sent which inturn will create/update ticket(s) based on alertrules defined in AMS.

# hostname, resource and status parameters are mandatory.

# hostname, resource and mo_name combination forms the businesskey of the alert. mo_name is not mandatory.

# auth-key will be generated as part of FreshService Account creation. Integration key in Accounts will be the auth-key.

# amsURL: rest api URL should be  https://subdomain.alerts.freshservice.com/alerts

#input parameters from PRTG action

Param(

  [string]$hostname,

  [string]$resource,

  [string]$message,

  [string]$mo_name,

  [string]$description,

  [string]$ip_address,

  [string]$value,

  [string]$status,

  [string]$additional_info,

  [string]$amsURL =
"https://subdomain.alerts.freshservice.com/alerts",

  [string]$amsAuthKey = "<account_integrationkey>"

)


#RestAPI headers

$AuthHeader = @{

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

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

}

if ($severity-eq 'down') {

    $severity = 'critical'

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


    $severity = 'ok'


}

#payload construction

$jsondata = @{

    hostname          = $hostname;

    ip_address      = $ip_address;

    resource          = $resource;

    #mo_name          = $mo_name;

    message         = $message;

    description     = $description;

    value             = $value;

    severity             = $severity;

    updated_by         = "PRTG"

    additional_info = $additional_info


}

#remove empty keys

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

#convert to json object

$Body = ConvertTo-Json $jsondata

Write-Host $Body

# 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 2: To create a notification template 

  1. Log in to your PRTG Web Client UI. 

  2. Click the Setup tab. The Setup page will appear. 

  3. Click Notification Templates under Account Settings

  4. Click the Add Notification Template button at the top-right. The template page will open.

  5. Provide a Template Name

  6. Default settings will already be enabled such as Notification Summarization and Access Rights.

  7. Click the Execute Program notification type (this will automatically toggle the switch for Execute Program).

  8. Select the Program File dropdown and choose the Powershell Script file created during Step 1.  

  9. Add the required Parameters. These Parameters will be the input for the Powershell script file.
    Example: 
    hostname %device  -resource %name  -severity %status  -message "%message" -ip_address %host

  10. (Optional) You can add additional parameters such as Tags, Descriptions, and Alert group key.

  11. Click the Create button. 


Step 3: To create notification triggers 

  1. Click the Devices tab and select the Notification Triggers tab. 

  2. Click +Add State Trigger if you’d like to receive notifications based on the status change. 

  3. Select the created notification template, the state, and the time while setting up the state trigger under the Rule

  4. Select the created template when the sensor leaves/changes from the previous state listed under the Rule

  5. Click the tick mark button to save.