Skip to content

Commit 39da55d

Browse files
aequitasmxsasha
authored andcommitted
Configure prometheus exporters to be externally accessible (with authentication)
1 parent 49ec644 commit 39da55d

File tree

4 files changed

+82
-2
lines changed

4 files changed

+82
-2
lines changed

docker/compose.development.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ services:
2828
action: rebuild
2929
volumes:
3030
# mount monitoring credentials for testing/development
31-
- ./webserver/dev.htpasswd:/etc/nginx/htpasswd/monitoring.htpasswd:ro
31+
- ./webserver/dev.htpasswd:/etc/nginx/htpasswd/monitoring.htpasswd
3232

3333
app:
3434
develop:

docker/compose.integration-tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ services:
194194
ipv4_address: $IPV4_WEBSERVER_IP_PUBLIC
195195
volumes:
196196
# mount monitoring credentials for testing/development
197-
- ./webserver/dev.htpasswd:/etc/nginx/htpasswd/monitoring.htpasswd:ro
197+
- ./webserver/dev.htpasswd:/etc/nginx/htpasswd/monitoring.htpasswd
198198

199199
unbound:
200200
networks:

docker/compose.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,7 @@ services:
801801

802802
profiles:
803803
- monitoring
804+
- monitoring-exporters
804805

805806
redis-exporter:
806807
image: ${DOCKER_IMAGE_REDIS_EXPORTER}
@@ -821,6 +822,7 @@ services:
821822

822823
profiles:
823824
- monitoring
825+
- monitoring-exporters
824826

825827
statsd-exporter:
826828
image: ${DOCKER_IMAGE_STATSD_EXPORTER}
@@ -844,6 +846,7 @@ services:
844846

845847
profiles:
846848
- monitoring
849+
- monitoring-exporters
847850

848851
healthcheck:
849852
# container image includes the test command, setting interval and start_interval here
@@ -909,6 +912,7 @@ services:
909912

910913
profiles:
911914
- monitoring
915+
- monitoring-exporters
912916

913917
docker_stats_exporter:
914918
# https://github.com/jan4843/docker_stats_exporter
@@ -932,6 +936,7 @@ services:
932936

933937
profiles:
934938
- monitoring
939+
- monitoring-exporters
935940

936941
nginx_logs_exporter:
937942
platform: linux/amd64
@@ -956,6 +961,7 @@ services:
956961

957962
profiles:
958963
- monitoring
964+
- monitoring-exporters
959965

960966
query-exporter:
961967
image: ${DOCKER_IMAGE_QUERY_EXPORTER}

docker/webserver/nginx_templates/default.conf.template

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,80 @@ server {
321321
proxy_pass $alertmanager;
322322
}
323323

324+
# expose all metrics exporters for external monitoring
325+
location /node-exporter {
326+
include http.headers;
327+
include hsts_h3.headers;
328+
auth_basic "Please enter your monitoring username and password";
329+
auth_basic_user_file /etc/nginx/htpasswd/monitoring.htpasswd;
330+
# set proxy_pass argument as variable, this makes sure nginx will still start even if this hostname is unresolvable due to monitoring profile being disabled
331+
set $node_exporter http://node-exporter:9100;
332+
proxy_pass $node_exporter;
333+
}
334+
location /postgresql-exporter {
335+
include http.headers;
336+
include hsts_h3.headers;
337+
auth_basic "Please enter your monitoring username and password";
338+
auth_basic_user_file /etc/nginx/htpasswd/monitoring.htpasswd;
339+
# set proxy_pass argument as variable, this makes sure nginx will still start even if this hostname is unresolvable due to monitoring profile being disabled
340+
set $postgresql_exporter http://postgresql-exporter:9187/metrics;
341+
proxy_pass $postgresql_exporter;
342+
}
343+
location /redis-exporter {
344+
include http.headers;
345+
include hsts_h3.headers;
346+
auth_basic "Please enter your monitoring username and password";
347+
auth_basic_user_file /etc/nginx/htpasswd/monitoring.htpasswd;
348+
# set proxy_pass argument as variable, this makes sure nginx will still start even if this hostname is unresolvable due to monitoring profile being disabled
349+
set $redis_exporter http://redis-exporter:9121/metrics;
350+
proxy_pass $redis_exporter;
351+
}
352+
location /rabbitmq-exporter {
353+
include http.headers;
354+
include hsts_h3.headers;
355+
auth_basic "Please enter your monitoring username and password";
356+
auth_basic_user_file /etc/nginx/htpasswd/monitoring.htpasswd;
357+
# set proxy_pass argument as variable, this makes sure nginx will still start even if this hostname is unresolvable due to monitoring profile being disabled
358+
set $rabbitmq_exporter http://rabbitmq:15692/metrics;
359+
proxy_pass $rabbitmq_exporter;
360+
}
361+
location /statsd-exporter {
362+
include http.headers;
363+
include hsts_h3.headers;
364+
auth_basic "Please enter your monitoring username and password";
365+
auth_basic_user_file /etc/nginx/htpasswd/monitoring.htpasswd;
366+
# set proxy_pass argument as variable, this makes sure nginx will still start even if this hostname is unresolvable due to monitoring profile being disabled
367+
set $statsd_exporter http://statsd-exporter:9102/metrics;
368+
proxy_pass $statsd_exporter;
369+
}
370+
location /celery-exporter {
371+
include http.headers;
372+
include hsts_h3.headers;
373+
auth_basic "Please enter your monitoring username and password";
374+
auth_basic_user_file /etc/nginx/htpasswd/monitoring.htpasswd;
375+
# set proxy_pass argument as variable, this makes sure nginx will still start even if this hostname is unresolvable due to monitoring profile being disabled
376+
set $celery_exporter http://celery-exporter:9808/metrics;
377+
proxy_pass $celery_exporter;
378+
}
379+
location /docker-stats-exporter {
380+
include http.headers;
381+
include hsts_h3.headers;
382+
auth_basic "Please enter your monitoring username and password";
383+
auth_basic_user_file /etc/nginx/htpasswd/monitoring.htpasswd;
384+
# set proxy_pass argument as variable, this makes sure nginx will still start even if this hostname is unresolvable due to monitoring profile being disabled
385+
set $docker_stats_exporter http://docker_stats_exporter:9338/metrics;
386+
proxy_pass $docker_stats_exporter;
387+
}
388+
location /nginx-logs-exporter {
389+
include http.headers;
390+
include hsts_h3.headers;
391+
auth_basic "Please enter your monitoring username and password";
392+
auth_basic_user_file /etc/nginx/htpasswd/monitoring.htpasswd;
393+
# set proxy_pass argument as variable, this makes sure nginx will still start even if this hostname is unresolvable due to monitoring profile being disabled
394+
set $nginx_logs_exporter http://nginx_logs_exporter:4040/metrics;
395+
proxy_pass $nginx_logs_exporter;
396+
}
397+
324398
# routinator proxy for internal use on multi instance setups
325399
location /routinator/ {
326400
include http.headers;

0 commit comments

Comments
 (0)