oncall-engine/docs/sources/configure/integrations/references/prtg/index.md
Jack Baldry 9ae442faa6
Replace docs/reference shortcode with ref URIs (#4301)
You can use `ref` URIs in admonitions (or any shortcodes) because they
are inline and not subject to the issues noted in the [`admonition`
shortcode](https://grafana.com/docs/writers-toolkit/write/shortcodes/#code-shortcode:~:text=to%20core%20understanding.-,WARNING,For%20more%20information%2C%20refer%20to%20Markdown%20Reference%20Links%20in%20Shortcodes.,-Examples).

The `ref` URIs perform the same pattern matching as `docs/reference` but
don't require the use of reference-style links and the destinations are
ordinary (full) URLs that can include version substitution. Unlike
`docs/reference`, the implementation doesn't use `relref` so you don't
have to be careful with omitting trailing slashes and the links will
follow redirects.

Documentation:
https://grafana.com/docs/writers-toolkit/write/links/#link-from-source-content-thats-used-in-multiple-projects

To check the links, refer to the deploy preview in
https://github.com/grafana/website/pull/19630.

Signed-off-by: Jack Baldry <jack.baldry@grafana.com>

---------

Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
2024-07-29 14:13:24 +00:00

4 KiB

title menuTitle description weight keywords labels canonical aliases refs
PRTG integration for Grafana OnCall PRTG PRTG integration reference material for Grafana OnCall. 0
OnCall
Integrations
Alerts
PRTG
Notifications
products
cloud
https://grafana.com/docs/oncall/latest/configure/integrations/references/prtg
/docs/grafana-cloud/alerting-and-irm/oncall/configure/integrations/references/prtg
/docs/grafana-cloud/alerting-and-irm/oncall/integrations/prtg
add-prtg/
../integrations/
user-and-team-management
pattern destination
/docs/oncall/ /docs/oncall/<ONCALL_VERSION>/manage/user-and-team-management/
pattern destination
/docs/grafana-cloud/ /docs/grafana-cloud/alerting-and-irm/oncall/manage/user-and-team-management/

PRTG integration for Grafana OnCall

{{< admonition type="note" >}} This integration is available exclusively on Grafana Cloud. {{< /admonition >}}

The PRTG integration for Grafana OnCall handles ticket events sent from PRTG webhooks. The integration provides grouping, auto-acknowledge and auto-resolve logic via customizable alert templates.

Configuring Grafana OnCall to Receive Alerts from PRTG

  1. In the Integrations tab, click + New integration.
  2. Select PRTG from the list of available integrations.
  3. Enter a name and description for the integration, click Create
  4. A new page will open with the integration details. Copy the OnCall Integration URL from HTTP Endpoint section.

Configuring PRTG to Send Alerts to Grafana OnCall

PRTG can use the script to send the alerts to Grafana OnCall. Please use the format below

Body Fields Format:

alert_uid [char][not required] - unique alert ID for grouping;
title [char][not required] - title;
image_url [char][not required] - url for image attached to alert;
state [char][not required] - could be "ok" or "alerting", helpful for auto-resolving;
link_to_upstream_details [char][not required] - link back to your monitoring system;
message [char][not required] - alert details;

ps1 script example:

# This script sends alerts from PRTG to Grafana OnCall
Param(
  [string]$sensorid,
  [string]$date,
  [string]$device,
  [string]$shortname,
  [string]$status,
  [string]$message,
  [string]$datetime,
  [string]$linksensor,
  [string]$url
)

# PRTG Server
$PRTGServer = "localhost:8080"
$PRTGUsername = "oncall"
$PRTGPasshash  = *****

#Directory for logging
$LogDirectory = "C:\temp\prtg-notifications-msteam.log"

#Acknowledgement Message for alerts ack'd via Teams
$ackmessage = "Problem has been acknowledged via OnCall."

# the acknowledgement URL
$ackURL = [string]::Format("{0}/api/acknowledgealarm.htm?id={1}&ackmsg={2}&username={3}&passhash={4}",
$PRTGServer,$sensorID,$ackmessage,$PRTGUsername,$PRTGPasshash);

# Autoresolve an alert in OnCall
if($status -eq "Up")
{ $state = "ok" }
ElseIf($status -match "now: Up")
{ $state = "ok" }
ElseIf($status -match "Up (was:")
{ $state = "ok" }
Else
{ $state = "alerting" }

$image_datetime = [datetime]::parse($datetime)
$sdate = $image_datetime.AddHours(-1).ToString("yyyy-MM-dd-HH-mm-ss")
$edate = $image_datetime.ToString("yyyy-MM-dd-HH-mm-ss")

$image_url = "$PRTGServer/chart.png?type=graph&graphid=-1&avg=0&width=1000&height=400
&username=$PRTGUsername&passhash=$PRTGPasshash&id=$sensorid&sdate=$sdate&edate=$edate"

$Body = @{
            "alert_uid"="$sensorid $date";
            "title"="$device $shortname $status at $datetime ";
            "image_url"=$image_url;
            "state"=$state;
            "link_to_upstream_details"="$linksensor";
            "message"="$message";
            "ack_url_get"="$ackURL"
} | ConvertTo-Json
$Body

try
{ Invoke-RestMethod -uri $url -Method Post -body $Body -ContentType 'application/json; charset=utf-8'; exit 0; }
Catch
{
    $ErrorMessage = $_.Exception.Message
    (Get-Date).ToString() +" - "+ $ErrorMessage | Out-File -FilePath $LogDirectory -Append
    exit 2;
}