Add support for Prometheus pushgateway basic auth (#16230)

Co-authored-by: Joe Clarke <jclarke@cisco.com>
This commit is contained in:
Joe Clarke
2024-07-21 14:03:32 -04:00
committed by GitHub
parent 1f01d7e627
commit e6f02ea7ff
3 changed files with 28 additions and 0 deletions

View File

@@ -51,6 +51,12 @@ class Prometheus extends BaseDatastore
$this->client = Http::client()->baseUrl($this->base_uri); $this->client = Http::client()->baseUrl($this->base_uri);
$user = Config::get('prometheus.user', '');
$passwd = Config::get('prometheus.password', '');
if ($user && $passwd) {
$this->client = $this->client->withBasicAuth($user, $passwd);
}
$this->prefix = Config::get('prometheus.prefix', ''); $this->prefix = Config::get('prometheus.prefix', '');
if ($this->prefix) { if ($this->prefix) {
$this->prefix = "$this->prefix" . '_'; $this->prefix = "$this->prefix" . '_';

View File

@@ -35,6 +35,14 @@ continue to function as normal.
lnms config:set prometheus.prefix 'librenms' lnms config:set prometheus.prefix 'librenms'
``` ```
If your pushgateway uses basic authentication, configure the following:
!!! setting "poller/prometheus"
```bash
lnms config:set prometheus.user username
lnms config:set prometheus.password password
```
## Prefix ## Prefix
Setting the 'prefix' option will cause all metric names to begin with Setting the 'prefix' option will cause all metric names to begin with

View File

@@ -5524,6 +5524,20 @@
"section": "prometheus", "section": "prometheus",
"order": 4 "order": 4
}, },
"prometheus.user": {
"default": "",
"type": "text",
"group": "poller",
"section": "prometheus",
"order": 5
},
"prometheus.password": {
"default": "",
"type": "text",
"group": "poller",
"section": "prometheus",
"order": 6
},
"public_status": { "public_status": {
"default": false, "default": false,
"group": "auth", "group": "auth",