Merge ~cmars/prometheus-charm:nrpe_check_fix into prometheus-charm:master

Proposed by Casey Marshall
Status: Merged
Approved by: Paul Gear
Approved revision: e78b063687e8d713303185d8708e5d33012dbe43
Merged at revision: ed0f47541b373f6ec506349766dfbd81708905c9
Proposed branch: ~cmars/prometheus-charm:nrpe_check_fix
Merge into: prometheus-charm:master
Diff against target: 22 lines (+9/-1)
1 file modified
reactive/prometheus.py (+9/-1)
Reviewer Review Type Date Requested Status
Paul Gear (community) Approve
Thomas Cuthbert (community) Needs Fixing
Domas Monkus (community) Approve
Review via email: mp+342903@code.launchpad.net

Commit message

Use external path for nrpe check_http plugin.

Fixes the 404 warning state that prometheus is in w/nagios
when the external_url config option is set; commonly used with url
rewriting in frontend like haproxy.

Description of the change

Use external path for nrpe check_http plugin.

Fixes the 404 warning state that prometheus is in w/nagios
when the external_url config option is set; commonly used with url
rewriting in frontend like haproxy.

To post a comment you must log in.
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

This merge proposal is being monitored by mergebot. Change the status to Approved to merge.

Revision history for this message
Domas Monkus (tasdomas) :
review: Approve
Revision history for this message
Thomas Cuthbert (tcuthbert) wrote :

comments inline.

review: Needs Fixing
Revision history for this message
Casey Marshall (cmars) wrote :

Comment is unclear to me, please advise.

Revision history for this message
Paul Gear (paulgear) wrote :

LGTM; in the case where external_url is something like "https://my.special.site:8443", this results in "//graph", but that's only cosmetic.

review: Approve
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision ed0f47541b373f6ec506349766dfbd81708905c9

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/reactive/prometheus.py b/reactive/prometheus.py
2index 669db9c..23c9bab 100644
3--- a/reactive/prometheus.py
4+++ b/reactive/prometheus.py
5@@ -648,9 +648,17 @@ def update_nrpe_config(svc):
6 hostname = nrpe.get_nagios_hostname()
7 nrpe_setup = nrpe.NRPE(hostname=hostname)
8 port = unitdata.kv().get('prometheus.port', 9090)
9+
10+ config = hookenv.config()
11+ graph_path = "/graph"
12+ external_url = config.get("external_url", "")
13+ if external_url:
14+ ext_url = urlparse(external_url)
15+ graph_path = '/{}/graph'.format(ext_url.path.strip('/'))
16+
17 nrpe_setup.add_check('prometheus_http',
18 'Prometheus HTTP check',
19- 'check_http -I 127.0.0.1 -p {} -u /graph'.format(port)
20+ 'check_http -I 127.0.0.1 -p {} -u {}'.format(port, graph_path)
21 )
22 nrpe_setup.write()
23

Subscribers

People subscribed via source and target branches