mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Alertmanager fix 2 (#9860)
* Improved Alertmanager transport * Typo fix * Fix according to Travis fail
This commit is contained in:
@@ -46,7 +46,7 @@ class Alertmanager extends Transport
|
||||
$alertmanager_status = 'startsAt';
|
||||
}
|
||||
$gen_url = (Config::get('base_url') . 'device/device=' . $obj['device_id']);
|
||||
$host = ($api['url'] . '/api/v1/alerts');
|
||||
$host = ($api['url'] . '/api/v2/alerts');
|
||||
$curl = curl_init();
|
||||
$alertmanager_msg = strip_tags($obj['msg']);
|
||||
$data = [[
|
||||
@@ -61,10 +61,14 @@ class Alertmanager extends Transport
|
||||
'alertname' => $obj['name'],
|
||||
'severity' => $obj['severity'],
|
||||
'instance' => $obj['hostname'],
|
||||
'source' => $api['source'],
|
||||
],
|
||||
]];
|
||||
|
||||
unset($api['url']);
|
||||
foreach ($api as $label => $value) {
|
||||
$data[0]['labels'][$label] = $value;
|
||||
};
|
||||
|
||||
$alert_message = json_encode($data);
|
||||
curl_setopt($curl, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
|
||||
set_curl_proxy($curl);
|
||||
|
@@ -36,7 +36,7 @@ It has built-in functionality for deduplicating, grouping and routing alerts bas
|
||||
|
||||
LibreNMS uses alert grouping by alert rule, which can produce an array of alerts of similar content for an array of hosts, whereas Alertmanager can group them by alert meta, ideally producing one single notice in case an issue occurs.
|
||||
|
||||
The one and only possible parameter to be passed is `source` - this is required to distinguish LibreNMS alerts from alerts coming from different sources.
|
||||
It is possible to configure as much label values as required in Alertmanager Options section. Every label and it's value should be entered as a new line.
|
||||
|
||||
[Alertmanager Docs](https://prometheus.io/docs/alerting/alertmanager/)
|
||||
|
||||
@@ -46,6 +46,7 @@ The one and only possible parameter to be passed is `source` - this is required
|
||||
| ------ | ------- |
|
||||
| Alertmanager URL | http://alertmanager.example.com |
|
||||
| Alertmanager Options: | source=librenms |
|
||||
| | customlabel=value |
|
||||
|
||||
## API
|
||||
API transports definitions are a bit more complex than the E-Mail configuration.
|
||||
|
Reference in New Issue
Block a user