SIGNL4 Alert Transport (#16037)

* SIGNL4 Alert Transport

SIGNL4 alert transport added.

* Update Transports.md

* Update Signl4.php
This commit is contained in:
Ron
2024-05-22 10:16:35 -05:00
committed by GitHub
parent 7c4f04ab9d
commit 79184e8345
2 changed files with 94 additions and 0 deletions
+78
View File
@@ -0,0 +1,78 @@
<?php
/* Copyright (C) 2024 SIGNL4
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>. */
/**
* API Transport
*
* @author SIGNL4 <[email protected]>
* @copyright 2024 SIGNL4
* @license GPL
*/
namespace LibreNMS\Alert\Transport;
use LibreNMS\Alert\Transport;
use LibreNMS\Enum\AlertState;
use LibreNMS\Exceptions\AlertTransportDeliveryException;
use LibreNMS\Util\Http;
class Signl4 extends Transport
{
protected string $name = 'SIGNL4';
public function deliverAlert(array $alert_data): bool
{
$url = $this->config['signl4-url'];
$alert_status = match ($alert_data['state']) {
AlertState::RECOVERED => 'resolved',
AlertState::ACKNOWLEDGED => 'acknowledged',
default => 'new'
};
$s4_data = [
'X-S4-ExternalID' => (string) $alert_data['alert_id'],
'X-S4-Status' => $alert_status,
'Body' => $alert_data['alert_notes'],
];
$data = array_merge($s4_data, $alert_data);
$res = Http::client()->post($url, $data);
if ($res->successful()) {
return true;
}
throw new AlertTransportDeliveryException($alert_data, $res->status(), $res->body(), '', $alert_data);
}
public static function configTemplate(): array
{
return [
'config' => [
[
'title' => 'Webhook URL',
'name' => 'signl4-url',
'descr' => 'SIGNL4 webhook URL including team or integration secret.',
'type' => 'text',
],
],
'validation' => [
'signl4-url' => 'required|url',
],
];
}
}
+16
View File
@@ -764,6 +764,22 @@ Sensu to LibreNMS alerts, they'll be lost on the next event (silences will work)
| Check Prefix | lnms |
| Source Key | hostname |
## SIGNL4
SIGNL4 offers critical alerting, incident response and service dispatching for operating critical infrastructure. It alerts you persistently via app push, SMS text, voice calls, and email including tracking, escalation, on-call duty scheduling and collaboration.
Integrating SIGNL4 with LibreNMS to forward critical alerts with detailed information to responsible people or on-call teams. The integration supports triggering as well as closing alerts.
In the configuration for your SIGNL4 alert transport you just need to enter your SIGNL4 webhook URL including team or integration secret.
**Example:**
| Config | Example |
| ------ | ------- |
| Webhook URL | https://connect.signl4.com/webhook/{team-secret} |
You can find more information about the integration [here](https://docs.signl4.com/integrations/librenms/librenms.html).
## Slack
The Slack transport will POST the alert message to your Slack Incoming