oncall-engine/engine/apps/integrations/templates/html/integration_prtg.html
Michael Derynck 6b40f95033 World, meet OnCall!
Co-authored-by: Eve832 <eve.meelan@grafana.com>
    Co-authored-by: Francisco Montes de Oca <nevermind89x@gmail.com>
    Co-authored-by: Ildar Iskhakov <ildar.iskhakov@grafana.com>
    Co-authored-by: Innokentii Konstantinov <innokenty.konstantinov@grafana.com>
    Co-authored-by: Julia <ferril.darkdiver@gmail.com>
    Co-authored-by: maskin25 <kengurek@gmail.com>
    Co-authored-by: Matias Bordese <mbordese@gmail.com>
    Co-authored-by: Matvey Kukuy <motakuk@gmail.com>
    Co-authored-by: Michael Derynck <michael.derynck@grafana.com>
    Co-authored-by: Richard Hartmann <richih@richih.org>
    Co-authored-by: Robby Milo <robbymilo@fastmail.com>
    Co-authored-by: Timur Olzhabayev <timur.olzhabayev@grafana.com>
    Co-authored-by: Vadim Stepanov <vadimkerr@gmail.com>
    Co-authored-by: Yulia Shanyrova <yulia.shanyrova@grafana.com>
2022-06-03 08:09:47 -06:00

98 lines
No EOL
3.1 KiB
HTML

<blockquote>
PRTG can use the script to send the alerts to Grafana OnCall. Please use the format below
</blockquote>
<p>
<h6>Body Fields Format:</h6>
<ul>
<li><code>alert_uid</code> [char][not required] - unique alert ID for grouping;</li>
<li><code>title</code> [char][not required] - title;</li>
<li><code>image_url</code> [char][not required] - url for image attached to alert;</li>
<li><code>state</code> [char][not required] - could be &quot;ok&quot; or &quot;alerting&quot;, helpful for auto-resolving;</li>
<li><code>link_to_upstream_details</code> [char][not required] - link back to your monitoring system;</li>
<li><code>message</code> [char][not required] - alert details;</li>
</ul>
</p>
<h6>ps1 script example:</h6>
<p>
<pre>
# You are very welcome to change this script to fit your needs and formats
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 = "amixr"
$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 Amixr."
# 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 Amixr
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;
}
</pre>
</p>
<h4>Next steps:</h4>
<p><ol>
<li>
1. Add the routes and escalations in <code class='code-inline'>Escalations settings</code>
</li>
<li>
2. Check grouping, auto-resolving, and rendering templates in
<code class='code-inline'>Alert Templates</code> Settings
</li>
<li>
3. Make sure all the users set up their <code class='code-inline'>Personal Notifications</code> Settings
on the <code class='code-inline'>Users</code> Page
</li>
</ol></p>