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
diff --git a/config.yaml b/config.yaml
index f4f86d6..3bc2bd2 100644
--- a/config.yaml
+++ b/config.yaml
@@ -13,3 +13,20 @@ options:
13 type: string13 type: string
14 default: "http://0.0.0.0:9000/"14 default: "http://0.0.0.0:9000/"
15 description: The uri the web interface will be available at.15 description: The uri the web interface will be available at.
16 nagios_context:
17 default: "juju"
18 type: string
19 description: |
20 Used by the nrpe-external-master subordinate charm.
21 A string that will be prepended to instance name to set the host name
22 in nagios. So for instance the hostname would be something like:
23 juju-myservice-0
24 If you're running multiple environments with the same services in them
25 this allows you to differentiate between them.
26 nagios_servicegroups:
27 default: ""
28 type: string
29 description: >
30 A comma-separated list of nagios servicegroups.
31 If left empty, the nagios_context will be used as the servicegroup.
32
diff --git a/layer.yaml b/layer.yaml
index 5434c97..3c9b49d 100644
--- a/layer.yaml
+++ b/layer.yaml
@@ -5,6 +5,7 @@ includes:
5 - 'interface:elasticsearch'5 - 'interface:elasticsearch'
6 - 'interface:http'6 - 'interface:http'
7 - 'interface:mongodb-cluster'7 - 'interface:mongodb-cluster'
8 - 'interface:nrpe-external-master'
8options:9options:
9 snap:10 snap:
10 graylog:11 graylog:
diff --git a/metadata.yaml b/metadata.yaml
index 03f1516..b5f3096 100644
--- a/metadata.yaml
+++ b/metadata.yaml
@@ -10,6 +10,9 @@ tags:
10 - misc10 - misc
11subordinate: false11subordinate: false
12provides:12provides:
13 nrpe-external-master:
14 interface: nrpe-external-master
15 scope: container
13 website:16 website:
14 interface: http17 interface: http
15requires:18requires:
diff --git a/reactive/graylog.py b/reactive/graylog.py
index 6f2aa95..db7a976 100644
--- a/reactive/graylog.py
+++ b/reactive/graylog.py
@@ -6,6 +6,7 @@ from urllib.parse import urlparse
6from charms.reactive import hook, when, when_not, remove_state, set_state6from charms.reactive import hook, when, when_not, remove_state, set_state
7from charms.reactive.helpers import data_changed7from charms.reactive.helpers import data_changed
8from charmhelpers.core import host, hookenv8from charmhelpers.core import host, hookenv
9from charmhelpers.contrib.charmsupport import nrpe
910
1011
11API_PORT = '9001' # This is the default set by the snap12API_PORT = '9001' # This is the default set by the snap
@@ -144,3 +145,30 @@ def set_conf(key, value, conf_path=CONF_FILE):
144145
145 with open(conf_path, 'wb') as conf_file:146 with open(conf_path, 'wb') as conf_file:
146 conf_file.write('\n'.join(conf).encode())147 conf_file.write('\n'.join(conf).encode())
148
149
150@when('nrpe-external-master.available')
151def configure_nagios(nagios):
152 if hookenv.hook_name() == 'update-status':
153 return
154
155 # Ask charmhelpers.contrib.charmsupport's nrpe to work out our hostname
156 hostname = nrpe.get_nagios_hostname()
157 nrpe_setup = nrpe.NRPE(hostname=hostname, primary=True)
158
159 conf = hookenv.config()
160 if conf['web_listen_uri']:
161 url = urlparse(conf['web_listen_uri'])
162 check_string = '<title>Graylog Web Interface</title>'
163 nrpe_setup.add_check(
164 'graylog_http',
165 'Graylog Web UI check',
166 '/usr/lib/nagios/plugins/check_http -I {} -p {} -s "{}"'.format(url.hostname, str(url.port), check_string)
167 )
168 check_string = 'cluster_id'
169 nrpe_setup.add_check(
170 'graylog_api',
171 'Greylog API check',
172 '/usr/lib/nagios/plugins/check_http -I 127.0.0.1 -p {} -u "/api" -s "{}"'.format(API_PORT, check_string)
173 )
174 nrpe_setup.write()

Subscribers

People subscribed via source and target branches

to all changes: