Skip to content

Commit

Permalink
#19 Prometheus metrics customization
Browse files Browse the repository at this point in the history
  • Loading branch information
sorobon committed Mar 24, 2017
1 parent b1c7be9 commit 4d522a6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 4 additions & 1 deletion tests/group_vars/group01.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@ nginx_extra_servers_path: "{{ playbook_dir }}/files"
nginx_extra_servers_template_path: "{{ playbook_dir }}/templates"

web2_port: 8888
nginx_prometheus_metrics_port: 9888
nginx_prometheus_metrics_port: 9888
nginx_prometheus_metrics_path: /mymetrics

hostname: nginx
8 changes: 6 additions & 2 deletions tests/test_ansible.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest
import urllib2


@pytest.fixture()
Expand Down Expand Up @@ -58,13 +59,16 @@ def test_nginx_service(File, Service, Socket, AnsibleVars):
assert Service("nginx").is_enabled
assert Service("nginx").is_running
assert Socket("tcp://0.0.0.0:9999").is_listening
assert Socket("tcp://0.0.0.0:" + str(web2_port)).is_listening
assert Socket("tcp://0.0.0.0:{0}".format(web2_port)).is_listening


def test_nginx_prometheus_service(File, Service, Socket, AnsibleVars):
metrics_port = AnsibleVars["nginx_prometheus_metrics_port"]
metrics_path = AnsibleVars["nginx_prometheus_metrics_path"]
hostname = AnsibleVars["hostname"]
assert File("/lib/systemd/system/nginx.service").exists
assert Service("nginx").is_enabled
assert Service("nginx").is_running
assert Socket("tcp://0.0.0.0:9999").is_listening
assert Socket("tcp://0.0.0.0:" + str(metrics_port)).is_listening
assert Socket("tcp://0.0.0.0:{0}".format(metrics_port)).is_listening
assert 200 == urllib2.urlopen('http://{0}:{1}{2}'.format(hostname, metrics_port, metrics_path)).getcode()

0 comments on commit 4d522a6

Please sign in to comment.