Skip to content

Commit e6f02ea

Browse files
Add support for Prometheus pushgateway basic auth (librenms#16230)
Co-authored-by: Joe Clarke <[email protected]>
1 parent 1f01d7e commit e6f02ea

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

LibreNMS/Data/Store/Prometheus.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ public function __construct()
5151

5252
$this->client = Http::client()->baseUrl($this->base_uri);
5353

54+
$user = Config::get('prometheus.user', '');
55+
$passwd = Config::get('prometheus.password', '');
56+
if ($user && $passwd) {
57+
$this->client = $this->client->withBasicAuth($user, $passwd);
58+
}
59+
5460
$this->prefix = Config::get('prometheus.prefix', '');
5561
if ($this->prefix) {
5662
$this->prefix = "$this->prefix" . '_';

doc/Extensions/metrics/Prometheus.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ continue to function as normal.
3535
lnms config:set prometheus.prefix 'librenms'
3636
```
3737

38+
If your pushgateway uses basic authentication, configure the following:
39+
40+
!!! setting "poller/prometheus"
41+
```bash
42+
lnms config:set prometheus.user username
43+
lnms config:set prometheus.password password
44+
```
45+
3846
## Prefix
3947

4048
Setting the 'prefix' option will cause all metric names to begin with

misc/config_definitions.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5524,6 +5524,20 @@
55245524
"section": "prometheus",
55255525
"order": 4
55265526
},
5527+
"prometheus.user": {
5528+
"default": "",
5529+
"type": "text",
5530+
"group": "poller",
5531+
"section": "prometheus",
5532+
"order": 5
5533+
},
5534+
"prometheus.password": {
5535+
"default": "",
5536+
"type": "text",
5537+
"group": "poller",
5538+
"section": "prometheus",
5539+
"order": 6
5540+
},
55275541
"public_status": {
55285542
"default": false,
55295543
"group": "auth",

0 commit comments

Comments
 (0)