Merge ~hloeung/charm-graylog:master into ~graylog-charmers/charm-graylog:master

Proposed by Haw Loeung
Status: Merged
Merged at revision: 1abfa8c18229b48e416fb2ca178bdab2faeffa0a
Proposed branch: ~hloeung/charm-graylog:master
Merge into: ~graylog-charmers/charm-graylog:master
Diff against target: 94 lines (+49/-0)
4 files modified
config.yaml (+17/-0)
layer.yaml (+1/-0)
metadata.yaml (+3/-0)
reactive/graylog.py (+28/-0)
Reviewer Review Type Date Requested Status
Barry Price Approve
Review via email: mp+327996@code.launchpad.net

Description of the change

Add nagios checks for both web UI and API

Add basic and simple nagios checks to ensure both Graylog web UI and API services are up.

To post a comment you must log in.
Revision history for this message
Barry Price (barryprice) wrote :

+1

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 f4f86d6..3bc2bd2 100644
3--- a/config.yaml
4+++ b/config.yaml
5@@ -13,3 +13,20 @@ options:
6 type: string
7 default: "http://0.0.0.0:9000/"
8 description: The uri the web interface will be available at.
9+ nagios_context:
10+ default: "juju"
11+ type: string
12+ description: |
13+ Used by the nrpe-external-master subordinate charm.
14+ A string that will be prepended to instance name to set the host name
15+ in nagios. So for instance the hostname would be something like:
16+ juju-myservice-0
17+ If you're running multiple environments with the same services in them
18+ this allows you to differentiate between them.
19+ nagios_servicegroups:
20+ default: ""
21+ type: string
22+ description: >
23+ A comma-separated list of nagios servicegroups.
24+ If left empty, the nagios_context will be used as the servicegroup.
25+
26diff --git a/layer.yaml b/layer.yaml
27index 5434c97..3c9b49d 100644
28--- a/layer.yaml
29+++ b/layer.yaml
30@@ -5,6 +5,7 @@ includes:
31 - 'interface:elasticsearch'
32 - 'interface:http'
33 - 'interface:mongodb-cluster'
34+ - 'interface:nrpe-external-master'
35 options:
36 snap:
37 graylog:
38diff --git a/metadata.yaml b/metadata.yaml
39index 03f1516..b5f3096 100644
40--- a/metadata.yaml
41+++ b/metadata.yaml
42@@ -10,6 +10,9 @@ tags:
43 - misc
44 subordinate: false
45 provides:
46+ nrpe-external-master:
47+ interface: nrpe-external-master
48+ scope: container
49 website:
50 interface: http
51 requires:
52diff --git a/reactive/graylog.py b/reactive/graylog.py
53index 6f2aa95..db7a976 100644
54--- a/reactive/graylog.py
55+++ b/reactive/graylog.py
56@@ -6,6 +6,7 @@ from urllib.parse import urlparse
57 from charms.reactive import hook, when, when_not, remove_state, set_state
58 from charms.reactive.helpers import data_changed
59 from charmhelpers.core import host, hookenv
60+from charmhelpers.contrib.charmsupport import nrpe
61
62
63 API_PORT = '9001' # This is the default set by the snap
64@@ -144,3 +145,30 @@ def set_conf(key, value, conf_path=CONF_FILE):
65
66 with open(conf_path, 'wb') as conf_file:
67 conf_file.write('\n'.join(conf).encode())
68+
69+
70+@when('nrpe-external-master.available')
71+def configure_nagios(nagios):
72+ if hookenv.hook_name() == 'update-status':
73+ return
74+
75+ # Ask charmhelpers.contrib.charmsupport's nrpe to work out our hostname
76+ hostname = nrpe.get_nagios_hostname()
77+ nrpe_setup = nrpe.NRPE(hostname=hostname, primary=True)
78+
79+ conf = hookenv.config()
80+ if conf['web_listen_uri']:
81+ url = urlparse(conf['web_listen_uri'])
82+ check_string = '<title>Graylog Web Interface</title>'
83+ nrpe_setup.add_check(
84+ 'graylog_http',
85+ 'Graylog Web UI check',
86+ '/usr/lib/nagios/plugins/check_http -I {} -p {} -s "{}"'.format(url.hostname, str(url.port), check_string)
87+ )
88+ check_string = 'cluster_id'
89+ nrpe_setup.add_check(
90+ 'graylog_api',
91+ 'Greylog API check',
92+ '/usr/lib/nagios/plugins/check_http -I 127.0.0.1 -p {} -u "/api" -s "{}"'.format(API_PORT, check_string)
93+ )
94+ nrpe_setup.write()

Subscribers

People subscribed via source and target branches

to all changes: