Merge ~brad-marshall/charm-prometheus-openstack-exporter/+git/promtheus-openstack-exporter-charm:add-nem-interface-fix-metadata into ~prometheus-charmers/charm-prometheus-openstack-exporter/+git/prometheus-openstack-exporter-charm:master

Proposed by Brad Marshall
Status: Merged
Approved by: James Hebden
Approved revision: 703b6e479490edf6c4537a14e10ed01088bd8ff5
Merged at revision: 703b6e479490edf6c4537a14e10ed01088bd8ff5
Proposed branch: ~brad-marshall/charm-prometheus-openstack-exporter/+git/promtheus-openstack-exporter-charm:add-nem-interface-fix-metadata
Merge into: ~prometheus-charmers/charm-prometheus-openstack-exporter/+git/prometheus-openstack-exporter-charm:master
Diff against target: 97 lines (+40/-4)
4 files modified
config.yaml (+14/-0)
layer.yaml (+1/-0)
metadata.yaml (+10/-4)
reactive/openstack_exporter.py (+15/-0)
Reviewer Review Type Date Requested Status
James Hebden (community) Approve
Review via email: mp+328900@code.launchpad.net

Description of the change

Added nrpe-external-master interface and a http check, fix some metadata details

To post a comment you must log in.
Revision history for this message
James Hebden (ec0) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/config.yaml b/config.yaml
2index 0ccae6e..faf8cea 100644
3--- a/config.yaml
4+++ b/config.yaml
5@@ -50,3 +50,17 @@ options:
6 description: |
7 If install_method is set to "snap" this option controlls channel name.
8 Supported values are: "stable", "candidate", "beta" and "edge"
9+ nagios_context:
10+ default: "juju"
11+ type: string
12+ description: |
13+ A string that will be prepended to instance name to set the host name
14+ in nagios. So for instance the hostname would be something like:
15+ juju-myservice-0
16+ If you're running multiple environments with the same services in them
17+ this allows you to differentiate between them.
18+ nagios_servicegroups:
19+ default: "juju"
20+ type: string
21+ description: |
22+ Comma separated list of nagios servicegroups for the graphite check
23diff --git a/layer.yaml b/layer.yaml
24index fef8dd8..a51fd28 100644
25--- a/layer.yaml
26+++ b/layer.yaml
27@@ -2,6 +2,7 @@ includes:
28 - 'layer:basic'
29 - 'layer:snap'
30 - 'interface:http'
31+ - 'interface:nrpe-external-master'
32 # Included in the charm itself, see hooks/*relations*
33 # - 'interface:keystone-credentials'
34 # - 'interface:swift'
35diff --git a/metadata.yaml b/metadata.yaml
36index e612d05..a296e6a 100644
37--- a/metadata.yaml
38+++ b/metadata.yaml
39@@ -1,10 +1,13 @@
40 name: prometheus-openstack-exporter
41-maintainer: bootstack-is@canonical.com
42-summary: Short summary of charm
43+maintainer: Prometheus Charmers <prometheus-charmers@lists.launchpad.net>
44+summary: Openstack exporter for Prometheus
45 description: |
46- Longline summary of charm
47+ This is an exporter that exposes information gathered from Openstack
48+ for use by the Prometheus monitoring system.
49 tags:
50 - openstack
51+ - monitoring
52+ - prometheus
53 requires:
54 identity-credentials:
55 interface: keystone-credentials
56@@ -12,7 +15,10 @@ requires:
57 interface: swift
58 provides:
59 prometheus-openstack-exporter-service:
60- interface: http
61+ interface: http
62+ nrpe-external-master:
63+ interface: nrpe-external-master
64+ scope: container
65 series:
66 - xenial
67 - trusty
68diff --git a/reactive/openstack_exporter.py b/reactive/openstack_exporter.py
69index 2182d07..f5aa6c8 100644
70--- a/reactive/openstack_exporter.py
71+++ b/reactive/openstack_exporter.py
72@@ -32,6 +32,7 @@ from charmhelpers.core import (
73 )
74 from charmhelpers.core.templating import render
75 from charms.layer import snap
76+from charmhelpers.contrib.charmsupport import nrpe
77
78 SNAP_NAME = 'prometheus-openstack-exporter'
79 SVC_NAME = ('snap.prometheus-openstack-exporter.'
80@@ -195,3 +196,17 @@ def do_restart():
81 def configure_exporter_service(exporter_service):
82 config = hookenv.config()
83 exporter_service.configure(config.get('port'))
84+
85+
86+@when('nrpe-external-master.available')
87+def update_nrpe_config(svc):
88+ hostname = nrpe.get_nagios_hostname()
89+ nrpe_setup = nrpe.NRPE(hostname=hostname)
90+ config = hookenv.config()
91+ port = config.get('port')
92+ nrpe_setup.add_check('prometheus_openstack_exporter_http',
93+ 'Prometheus Openstack Exporter HTTP check',
94+ 'check_http -I 127.0.0.1 -p {} -u /metrics'.format(port)
95+ )
96+ nrpe_setup.write()
97+

Subscribers

People subscribed via source and target branches