What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

PagerDuty HTTP notification

Votes:

3

I'm looking to integrate with PagerDuty for advanced notification scheduling. While it is possible to simply dispatch an email, I'd prefer to use their API to avoid notification problems from email server issues.

Their API takes JSON-encoded input data - it would be fantastic if the HTTP notification option could be expanded to send JSON post data.

json notifications prtg

Created on Dec 14, 2011 2:53:20 PM

Last change on Oct 3, 2016 8:55:54 AM by  Luciano Lingnau [Paessler]



24 Replies

Votes:

0

Hello,

we will put it onto the wishlist.

best regards.

Created on Dec 14, 2011 3:43:57 PM by  Torsten Lindner [Paessler Support]



Votes:

1

Did some further testing on this.

The server I am sending to does not require Content-type set for JSON, so this should work as-is (but does not).

My notification has HTTP Action enabled with the following:

URL:http://events.pagerduty.com/generic/2010-04-15/create_event.json
Postdata:{ "service_key": "ServiceKeyDeleted", "incident_key": "prtg/test", "event_type": "trigger", "description": "Test event without placeholders", "details": { "status": "status", "device": "device" } }

If I telnet to their server directly and post as below, it works.

----------------------Submit by telnet to events.pagerduty.com 80----------------------
POST /generic/2010-04-15/create_event.json HTTP/1.1
Host: events.pagerduty.com
Content-Length: 215

{ "service_key": "ServiceKeyDeleted", "incident_key": "prtg/test", "event_type": "trigger", "description": "Test event without placeholders", "details": {  "status": "status", "device": "device" } }

----------------------End----------------------

Can you shed any light on what else PRTG might be adding to the postdata? PRTG logs only show "HTTP/1.1 400 Bad Request" for a test notification. Any way I can get to the data being returned?

Created on Dec 14, 2011 6:06:40 PM

Last change on Aug 8, 2018 7:16:02 AM by  Luciano Lingnau [Paessler]



Votes:

0

I think the problem is, that PRTG encodes the POSTDATA and that may break pagerduty's stuff. We will look into creating pagerduty support in one of the next versions.

Created on Jan 4, 2012 1:54:02 PM by  Dirk Paessler [Founder Paessler AG] (11,025) 3 6



Votes:

0

Thanks for the update and for giving this some consideration.

Even a simple option to encode or not encode the postdata on an HTTP notification would be a convenient shorter-term solution.

It's also be helpful to have state change notification options for "Down Acknowledged" and "Paused" (this would let us do our acknowledgments in PRTG and then pass that notification out ).

Thanks again.

Created on Jan 4, 2012 2:06:36 PM



Votes:

0

Would love to have this capability with PagerDuty, we ran into the encode issue too with Leftronic.

Created on Jul 16, 2012 3:38:11 AM



Votes:

0

Hello,

Is there anything new on this subject?

I need to do HTTP Notification with PagerDuty and I have only HTTP/1.1 400 Bad Request logs when i try to test http notification on pagerduty.

Thanks.

Created on Oct 26, 2012 10:13:46 AM



Votes:

0

Any update on "We will look into creating pagerduty support in one of the next versions." ?

Created on Jan 30, 2013 4:07:31 PM



Votes:

0

I'm sorry, but due to a low number of requests it was postponed, but it is still on the list. Please bear with us.

Created on Jan 30, 2013 4:39:42 PM by  Torsten Lindner [Paessler Support]



Votes:

1

I'm a little late to the party, and this isn't exactly a clean way of doing this, but the PagerDuty Nagios API will accept other content-types than JSON. You would just create a Nagios service within PagerDuty.

http://events.pagerduty.com/nagios/2010-04-15/create_event?pd_nagios_object=host&CONTACTPAGER=<pagerduty_api_key>&NOTIFICATIONTYPE=PROBLEM&HOSTNAME=<hostname>&HOSTSTATE=down

Cheers, Ryan

Created on Apr 3, 2013 5:10:33 PM

Last change on Aug 10, 2015 5:45:07 AM by  Luciano Lingnau [Paessler]



Votes:

0

We are also very interested in using this feature, and would like to see it implemented as soon as possible.

-Groundspeak IT

Created on Apr 21, 2013 7:47:50 PM



Votes:

0

Hi

I would like this too. I have had a bit of a stab at it and come up with the following powershell v3 script

You need to setup a generic api service in pagerduty and update the script with your personal key

Param(
  [string]$Sitename,
  [string]$Device,
  [string]$Name,
  [string]$Status,
  [string]$Down,  
  [string]$message
)
$Description = "$Device $Name $Status $Down"
	$Body = @{
	  "service_key"="<servicekey>";
      "event_type"="trigger";
      "description"=$Description;
      "client"=$Sitename;
      "client_url"="<url>";
      "details"="$Message"
	} | ConvertTo-Json
	Invoke-RestMethod -Uri "https://events.pagerduty.com/generic/2010-04-15/create_event.json" -ContentType application/json -Method POST -Body $Body 
	#$Body | out-file ".\pager.txt"

Now this works flawlessly when running via powershell, when running it via the notification test, the logs come up with "Status sending EXE:Ok".

However I do not get anything at all.

Any ideas on how to debug this ?

Thanks

Created on Oct 9, 2014 4:21:58 PM

Last change on Oct 10, 2014 8:47:33 AM by  Torsten Lindner [Paessler Support]



Votes:

3

Ok, have modified the script a little bit

The trick seems to be that the PRTG notification setting does not enclose each passed variable in single quotes, so items with spaces in them break the script.

It now looks like (this is what works for us, and yes more can be added, but at present we don't need the extra info, we just need to know something has happened)

Param(
  [string]$probe,
  [string]$device,
  [string]$name,
  [string]$status,
  [string]$down,  
  [string]$message
)

$Description = "CRITICAL: $probe $device $name $status $down"
	$Body = @{
	  "service_key"="<apiservicekey>";
      "event_type"="trigger";
      "description"=$Description;
      "client"="$probe";
      "client_url"="<url>";
      "details"="$message"
	} | ConvertTo-Json
	Invoke-RestMethod -Uri "https://events.pagerduty.com/generic/2010-04-15/create_event.json" -ContentType application/json -Method POST -Body $Body 
	#$Body | out-file ".\pager.txt"
	

In the prtg notification settings the variables under EXE action need to be specified as follows (in the parameter field)

'%probe' '%device' '%name' '%status' '%down' '%message'

Use at your on risk etc

Hopefully this helps someone Thanks

Created on Oct 10, 2014 6:01:13 AM

Last change on Oct 10, 2014 8:48:08 AM by  Torsten Lindner [Paessler Support]



Votes:

0

PRTG Guys, I don't understand why you don't deliver a simple integration to REST API's it doesn't require that much and they are all the same json based API's

please consider them.

Created on Oct 12, 2014 5:21:07 AM



Votes:

2

Integration with PagerDuty, OpsGenie, and VictorOps native WebAPI calls would be an excellent feature. It feels like a majority of PRTG's competitors have exiting integration with these products. It would be a good sales feature, and also helpful to the pre-existing userbase.

Created on Oct 14, 2014 3:01:22 PM



Votes:

1

Felipe, thank you very much for the feedback. I'll put this on the wish list!

Created on Oct 15, 2014 8:06:03 AM by  Torsten Lindner [Paessler Support]



Votes:

3

If anyone is still looking for a resolution for this, I was able to overcome the headers. I configured a Nagios Service in PagerDuty, then I hit the nagios create_event. Below is how I was able to succesfully send a new trigger and resolve a trigger from PRTG

URL - Make sure it's HTTPS

https://events.pagerduty.com/nagios/2010-04-15/create_event

Postdata to trigger event

NOTIFICATIONTYPE=PROBLEM&pd_nagios_object=service&HOSTNAME=HOSTNAME&SERVICESTATE=DOWN&HOSTADDRESS=HOSTADDRESS&CONTACTPAGER=<YOUR API KEY>&pd_version=1.0&SERVICEDESC=TESTING

Postdata to resolve the event

NOTIFICATIONTYPE=RECOVERY&pd_nagios_object=service&HOSTNAME=HOSTNAME&SERVICESTATE=DOWN&HOSTADDRESS=HOSTADDRESS&CONTACTPAGER=<YOUR API KEY>&pd_version=1.0&SERVICEDESC=TESTING

Created on Dec 2, 2014 8:00:22 PM

Last change on Jun 26, 2015 6:59:29 AM by  Luciano Lingnau [Paessler]



Votes:

1

Agreed. Bi-directional VictorOps, OpsGenie, and PagerDuty integration is something other solutions have and we are considering switching platforms for this support.

Created on Jul 7, 2015 5:54:05 PM



Votes:

0

Dear response3

We collect user feedback to help us decide which features would help the most users. We continue to improve our notification emails, however integration with PagerDuty and similar tools is not something we are going for in the foreseeable future.

That does not mean it is off the table forever.

Created on Jul 9, 2015 12:34:28 PM by  Arne Seifert [Paessler Support]



Votes:

1

OpsGenie has instructions on how to integrate PRTG and OpsGenie: https://www.opsgenie.com/docs/integrations/prtg-integration

Created on Jul 22, 2016 11:52:03 AM by  Kimberley Trommler [Paessler Support] (7) 3



Votes:

1

To expand (or update) on Rhyse posted way above:

I have 2 notifications, a "create pagerduty incident" and "resolve pagerduty incident"

Each of these has a executes a custom script.

The script for "create" is

Param(
  [string]$probe,
  [string]$device,
  [string]$name,
  [string]$status,
  [string]$down,  
  [string]$message
)

$Description = "CRITICAL: $probe $device $name $status $down"
	$Body = @{
	  "service_key"="<api key>";
      "event_type"="trigger";
      "incident_key"=$device;
      "description"=$Description;
      "client"="$probe";
      "client_url"="<url>";
      "details"="$message"
	} | ConvertTo-Json
	Invoke-RestMethod -Uri "https://events.pagerduty.com/generic/2010-04-15/create_event.json" -ContentType application/json -Method POST -Body $Body 
	#$Body | out-file ".\pager.txt"

and for the "resolve":

Param(
  [string]$probe,
  [string]$device,
  [string]$name,
  [string]$status,
  [string]$down,  
  [string]$message
)

$Description = "CRITICAL: $probe $device $name $status $down"
	$Body = @{
	  "service_key"="<api key>";
      "event_type"="resolve";
      "incident_key"=$device;
      "description"=$Description;
      "client"="$probe";
      "client_url"="<url>";
      "details"="$message"
	} | ConvertTo-Json
	Invoke-RestMethod -Uri "https://events.pagerduty.com/generic/2010-04-15/create_event.json" -ContentType application/json -Method POST -Body $Body 
	#$Body | out-file ".\pager.txt"

You will note the main difference is I am submitting the incident_key (using the deviceID). This means Pageryduty can resolve the incident if PRTG tells it.

Created on Jan 20, 2017 4:10:39 AM



Votes:

0

Dear AndrewG,

As always, thank you for your contribution.

Best,
Sebastian

Created on Jan 20, 2017 6:58:13 AM by  Sebastian Kniege [Paessler Support]



Votes:

0

I grew tired of the issue of email and the not so great integration into pagerduty, difficult to read and sometimes dodgy on it's functionality. So I wrote a script to handle this and then had to update the script for their new API. You would need to create an API key with PagerDuty then switch the notification type to custom EXE in PRTG and just use a powershell script to call pagerduty. I am sure I left some things defaulted for my environment (I tried to remove all the defining stuff I just hard coded it since it doesn't change). This hopefully will help a few others get this rolling and I have suggested this to pagerduty as the preferred or alternative integration. If the sensor comes back down the script checks to see if alert exists and if it does then it skips saying it already exists unless it's paused or warning, or anything but down really, in which case it closes the ticket. I am sure there are optimizations that could be made it works right now.

Hope this helps.

#################  Start Here! #########################################
Param(
    [string]$Probe,
    [string]$Device,
    [string]$Name,
    [string]$Status,
    [string]$Down,
    [string]$DateTime,
    [string]$LinkDevice,
    [string]$Message
)

$Hour = Get-Date -format "HH:mm"
$text = "$Probe-$Device-$Name"
$Title = $text
$APIKey = "API_Key_20_character"
$servicekey = "service_key_32_characters_string"
$companyname = "subdomain"
$PagerdutyEventURL = "https://events.pagerduty.com/generic/2010-04-15/create_event.json"
$PagerdutyAPIURL = "https://api.pagerduty.com/incidents"

$pagerdutystatus1 = "triggered"
$pagerdutystatus2 = "acknowledged"
$Service = "SERVICE"
$data= "?statuses[]=$pagerdutystatus1`&statuses[]=$pagerdutystatus2`&time_zone=UTC&sort_by:desc&include[]=services:$Service"
$CALL0 = Invoke-WebRequest -Method GET -ContentType "application/vnd.pagerduty+json;version=2" $PagerdutyAPIURL/count$data -Headers @{"Authorization"=("Token token=" + $APIKey)}
$Response0 = $CALL0.content | ConvertFrom-JSON
$CALL1 = Invoke-WebRequest -Method GET -ContentType "application/vnd.pagerduty+json;version=2" $PagerdutyAPIURL$data -Headers @{"Authorization"=("Token token=" + $APIKey)}
$Response1 = $CALL1.content | ConvertFrom-JSON
write-host $Response0.triggered "Triggered and" $Response0.acknowledged "acknowledged"
write-host "Searching for incident_key or title matching ""$Title"""

function createincident 
{
	$Body= (
	 New-Object PSObject |
	 Add-Member -PassThru NoteProperty "service_key" "$servicekey" |
	 Add-Member -PassThru NoteProperty "event_type" "trigger" |
	 Add-Member -PassThru NoteProperty "description" "$Title" |
	 Add-Member -PassThru NoteProperty "incident_key" "$Title" |
	 Add-Member -PassThru NoteProperty "client" "PRTG" |
	 Add-Member -PassThru NoteProperty "client_url" "$LinkDevice" |
	 Add-Member -PassThru NoteProperty details (
	  New-Object PSObject |
	  Add-Member -PassThru NoteProperty "Message" "$Message" |
	  Add-Member -PassThru NoteProperty "Device" "$Device" |
	  Add-Member -PassThru NoteProperty "Name" "$Name" |
	  Add-Member -PassThru NoteProperty "Down" "$Down" |
	  Add-Member -PassThru NoteProperty "DateTime" "$DateTime" |
	  Add-Member -PassThru NoteProperty "Status" "$Status" |
	  Add-Member -PassThru NoteProperty "Probe" "$Probe"
	 ) |
	 Add-Member -PassThru NoteProperty contexts @(
	   (
	   New-Object PSObject |
	   Add-Member -PassThru NoteProperty -name "type" -value "link" |
	   Add-Member -PassThru NoteProperty -name "href" -value "$LinkDevice"
	   )
	   (
	   New-Object PSObject |
	   Add-Member -PassThru NoteProperty -name "type" -value "link" |
	   Add-Member -PassThru NoteProperty -name "href" -value "https://$companyname.pagerduty.com" |
	   Add-Member -PassThru NoteProperty -name "text" -value "View the incident on PagerDuty"
	   )
	 )
	) | ConvertTo-JSON -Compress

	$CALL2 = Invoke-WebRequest -Method POST -ContentType "application/json" -Body $Body -URI $PagerdutyEventURL
	$Response2 = $CALL2.content | ConvertFrom-JSON
	write-host $Response2.incident_key "created at $Hour"
}
If ($Response0.triggered -eq 0 -and $Response0.acknowledged -eq 0) {
	If ($Status -match "Down" -or $Status -match "Escalation" -and $Status -notmatch "ended") {
		write-host "No open or acknowledged alerts! Whoo Hoo... D'oh!"
		createincident
		}
	else 
	{
		write-host "No incidents found resolving impossible"
	}
}
else
{
	If ($Response1.incidents.incident_key -contains $Title) {
		$Incidents = $Response1.incidents
		If ($Status -match "Down" -or $Status -match "Escalation" -and $Status -notmatch "ended") {
			write-host "PagerDuty Ticket ""$Title"" already exists exiting"
		}
		else 
		{
		Foreach ($Incident in $Incidents | Where {$_.incident_key -eq $Title}) {
			write-host "******************** Start Of Incident Information ********************"
			write-host "id = " $Incident.id
			write-host "incident_number =" $Incident.incident_number
			write-host "incident_key =" $Incident.incident_key
			write-host "created_at =" $Incident.created_at
			write-host "status =" $Incident.status
			write-host "html_url =" $Incident.html_url
			write-host "urgency =" $Incident.urgency
			write-host "title =" $Incident.title
			write-host "description =" $Incident.description
			write-host "urgency =" $Incident.urgency
			write-host "********************* End Of Incident Information *********************"

				$Resolve = (
				New-Object PSObject |
				 Add-Member -PassThru NoteProperty "service_key" "$servicekey" |
				 Add-Member -PassThru NoteProperty "event_type" "resolve" |
				 Add-Member -PassThru NoteProperty "description" "$Title" |
				 Add-Member -PassThru NoteProperty "incident_key" "$Title" 
				) | ConvertTo-JSON -Compress
				
				write-host "PagerDuty Ticket $Title exists, resolving"
				$CallResolve = Invoke-WebRequest -Method POST -ContentType "application/json" -Body $Resolve -URI $PagerdutyEventURL
				$ResponseResolve = $CallResolve.content | ConvertFrom-JSON
				write-host "Ticket with incident_key"$ResponseResolve.incident_key"attempted ticket closing result:" $ResponseResolve.status
				exit
			} 
		}
	}
	else
	{
		If ($Status -match "Down" -or $Status -match "Escalation" -and $Status -notmatch "ended") {
			write-host "PagerDuty Ticket ""$Title"" does not already exist"
			createincident
		}
		else
		{
		write-host "PagerDuty Ticket ""$Title"" does not exist and cannot be closed"
		}
	}
}
##################  End Here! ##########################################

Created on Mar 7, 2017 9:24:34 PM

Last change on Mar 23, 2017 8:48:26 AM by  Torsten Lindner [Paessler Support]



Votes:

1

Another vote for implementing bi-directional acks with PRTG and PagerDuty. The PD-PTRG integration with de-dedupe using a RegEx works OK, but it'd be so much better to only have to ack an incident in one place...

Created on Feb 8, 2018 4:00:39 PM



Votes:

0

Another vote for implementing bi-directional alerts/acks with PagerDuty. It's been almost 10 years, any way this is coming any time soon?

Created on Apr 13, 2021 8:16:38 PM




Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.