From cbd5989707209baba0447124c183d1335c1140ef Mon Sep 17 00:00:00 2001 From: Claudio Maradonna Date: Fri, 25 Jun 2021 18:33:09 +0200 Subject: [PATCH 1/2] feature: custom files for prometheus exporters --- prometheus/exporters/apache.conf | 1 + prometheus/exporters/apache.service | 15 +++++++++++++++ prometheus/exporters/mysqld.service | 15 +++++++++++++++ prometheus/exporters/nginx.conf | 1 + prometheus/exporters/postgresql.conf | 2 ++ 5 files changed, 34 insertions(+) create mode 100644 prometheus/exporters/apache.conf create mode 100644 prometheus/exporters/apache.service create mode 100644 prometheus/exporters/mysqld.service create mode 100644 prometheus/exporters/nginx.conf create mode 100644 prometheus/exporters/postgresql.conf diff --git a/prometheus/exporters/apache.conf b/prometheus/exporters/apache.conf new file mode 100644 index 0000000..a8e2ad2 --- /dev/null +++ b/prometheus/exporters/apache.conf @@ -0,0 +1 @@ +ARGS='--scrape_uri="http://127.0.0.1/server-status?auto"' diff --git a/prometheus/exporters/apache.service b/prometheus/exporters/apache.service new file mode 100644 index 0000000..fbf05b1 --- /dev/null +++ b/prometheus/exporters/apache.service @@ -0,0 +1,15 @@ +[Unit] +Description=Prometheus exporter for Apache +Documentation=https://github.com/Lusitaniae/apache_exporter +Wants=network-online.target +After=network-online.target + +[Service] +User=root +Group=root +Type=simple +EnvironmentFile=/etc/default/prometheus-apache-exporter +ExecStart=/usr/bin/apache_exporter $ARGS + +[Install] +WantedBy=multi-user.target diff --git a/prometheus/exporters/mysqld.service b/prometheus/exporters/mysqld.service new file mode 100644 index 0000000..0b9436c --- /dev/null +++ b/prometheus/exporters/mysqld.service @@ -0,0 +1,15 @@ +[Unit] +Description=Prometheus exporter for MariaDB +Documentation=https://github.com/prometheus/mysqld_exporter +Wants=network-online.target +After=network-online.target + +[Service] +User=root +Group=root +Type=simple +EnvironmentFile=/etc/default/prometheus-mariadb-exporter +ExecStart=/usr/bin/mysqld_exporter $ARGS + +[Install] +WantedBy=multi-user.target diff --git a/prometheus/exporters/nginx.conf b/prometheus/exporters/nginx.conf new file mode 100644 index 0000000..3068016 --- /dev/null +++ b/prometheus/exporters/nginx.conf @@ -0,0 +1 @@ +ARGS="-nginx.scrape-uri http://127.0.0.1:80/stub_status" diff --git a/prometheus/exporters/postgresql.conf b/prometheus/exporters/postgresql.conf new file mode 100644 index 0000000..afb72f4 --- /dev/null +++ b/prometheus/exporters/postgresql.conf @@ -0,0 +1,2 @@ +# peer mode +DATA_SOURCE_NAME='host=/var/run/postgresql sslmode=disable' From fedc82cee30eb6d15d90b071ecd568ef8c0d276d Mon Sep 17 00:00:00 2001 From: Claudio Maradonna Date: Sat, 26 Jun 2021 12:45:58 +0200 Subject: [PATCH 2/2] fix: adjusted all configuration as described in README --- .../httpd/conf.d/virtualhost-example.conf} | 3 +++ apache/etc/httpd/conf/httpd-maintenance.conf | 7 +++++++ apache/etc/httpd/conf/httpd-no-signature.conf | 4 ++++ apache/etc/httpd/conf/httpd-server-status.conf | 8 ++++++++ .../www/maintenance/index.html} | 2 +- .../www/maintenance/index.png} | Bin postgresql/{ => etc/postgresql}/pg_hba.conf | 0 .../postgresql/postgresql.conf} | 4 ++-- .../default/prometheus-apache-exporter.conf} | 0 .../default/prometheus-nginx-exporter.conf} | 0 .../default/prometheus-postgresql-exporter.conf} | 0 .../systemd/prometheus-apache-exporter.service} | 0 .../systemd/prometheus-mysqld-exporter.service} | 0 13 files changed, 25 insertions(+), 3 deletions(-) rename apache/{maintenance.conf => etc/httpd/conf.d/virtualhost-example.conf} (97%) create mode 100644 apache/etc/httpd/conf/httpd-maintenance.conf create mode 100644 apache/etc/httpd/conf/httpd-no-signature.conf create mode 100644 apache/etc/httpd/conf/httpd-server-status.conf rename apache/{maintenance.html => var/www/maintenance/index.html} (92%) rename apache/{maintenance.png => var/www/maintenance/index.png} (100%) rename postgresql/{ => etc/postgresql}/pg_hba.conf (100%) rename postgresql/{postgresql_custom.conf => etc/postgresql/postgresql.conf} (55%) rename prometheus/exporters/{apache.conf => etc/default/prometheus-apache-exporter.conf} (100%) rename prometheus/exporters/{nginx.conf => etc/default/prometheus-nginx-exporter.conf} (100%) rename prometheus/exporters/{postgresql.conf => etc/default/prometheus-postgresql-exporter.conf} (100%) rename prometheus/exporters/{apache.service => etc/systemd/systemd/prometheus-apache-exporter.service} (100%) rename prometheus/exporters/{mysqld.service => etc/systemd/systemd/prometheus-mysqld-exporter.service} (100%) diff --git a/apache/maintenance.conf b/apache/etc/httpd/conf.d/virtualhost-example.conf similarity index 97% rename from apache/maintenance.conf rename to apache/etc/httpd/conf.d/virtualhost-example.conf index 6576a7f..e08d0f4 100644 --- a/apache/maintenance.conf +++ b/apache/etc/httpd/conf.d/virtualhost-example.conf @@ -1,4 +1,6 @@ + # YOUR CONFIG + # Redirect all request to a 503 return code when in maintenance mode ErrorDocument 503 /maintenance/index.html RewriteEngine on @@ -12,4 +14,5 @@ RewriteCond /var/www/maintenance/ALL !-f RewriteCond /var/www/maintenance/%{SERVER_NAME} !-f RewriteRule ^/maintenance/index.html$ / [R,L] + diff --git a/apache/etc/httpd/conf/httpd-maintenance.conf b/apache/etc/httpd/conf/httpd-maintenance.conf new file mode 100644 index 0000000..d3fbced --- /dev/null +++ b/apache/etc/httpd/conf/httpd-maintenance.conf @@ -0,0 +1,7 @@ +## YOUR CONFIG HERE + + + ## OTHER CONFIG HERE + + Alias "/maintenance" "/var/www/maintenance" + diff --git a/apache/etc/httpd/conf/httpd-no-signature.conf b/apache/etc/httpd/conf/httpd-no-signature.conf new file mode 100644 index 0000000..09cafd0 --- /dev/null +++ b/apache/etc/httpd/conf/httpd-no-signature.conf @@ -0,0 +1,4 @@ +## MAIN CONFIG HERE + +ServerTokens Prod +ServerSignature Off diff --git a/apache/etc/httpd/conf/httpd-server-status.conf b/apache/etc/httpd/conf/httpd-server-status.conf new file mode 100644 index 0000000..8a8a49d --- /dev/null +++ b/apache/etc/httpd/conf/httpd-server-status.conf @@ -0,0 +1,8 @@ +## MAIN CONFIG HERE + + + SetHandler server-status + Order deny,allow + Deny from all + Allow from 127.0.0.1 + diff --git a/apache/maintenance.html b/apache/var/www/maintenance/index.html similarity index 92% rename from apache/maintenance.html rename to apache/var/www/maintenance/index.html index d0058ee..16fe47f 100644 --- a/apache/maintenance.html +++ b/apache/var/www/maintenance/index.html @@ -10,7 +10,7 @@
- +

We’ll be back soon!

We’re performing some hacks at the moment. diff --git a/apache/maintenance.png b/apache/var/www/maintenance/index.png similarity index 100% rename from apache/maintenance.png rename to apache/var/www/maintenance/index.png diff --git a/postgresql/pg_hba.conf b/postgresql/etc/postgresql/pg_hba.conf similarity index 100% rename from postgresql/pg_hba.conf rename to postgresql/etc/postgresql/pg_hba.conf diff --git a/postgresql/postgresql_custom.conf b/postgresql/etc/postgresql/postgresql.conf similarity index 55% rename from postgresql/postgresql_custom.conf rename to postgresql/etc/postgresql/postgresql.conf index 65c2e9f..e9efbc1 100644 --- a/postgresql/postgresql_custom.conf +++ b/postgresql/etc/postgresql/postgresql.conf @@ -1,5 +1,5 @@ -... +## OTHER CONFIG password_encryption = scram-sha-256 -... +## END CONFIG diff --git a/prometheus/exporters/apache.conf b/prometheus/exporters/etc/default/prometheus-apache-exporter.conf similarity index 100% rename from prometheus/exporters/apache.conf rename to prometheus/exporters/etc/default/prometheus-apache-exporter.conf diff --git a/prometheus/exporters/nginx.conf b/prometheus/exporters/etc/default/prometheus-nginx-exporter.conf similarity index 100% rename from prometheus/exporters/nginx.conf rename to prometheus/exporters/etc/default/prometheus-nginx-exporter.conf diff --git a/prometheus/exporters/postgresql.conf b/prometheus/exporters/etc/default/prometheus-postgresql-exporter.conf similarity index 100% rename from prometheus/exporters/postgresql.conf rename to prometheus/exporters/etc/default/prometheus-postgresql-exporter.conf diff --git a/prometheus/exporters/apache.service b/prometheus/exporters/etc/systemd/systemd/prometheus-apache-exporter.service similarity index 100% rename from prometheus/exporters/apache.service rename to prometheus/exporters/etc/systemd/systemd/prometheus-apache-exporter.service diff --git a/prometheus/exporters/mysqld.service b/prometheus/exporters/etc/systemd/systemd/prometheus-mysqld-exporter.service similarity index 100% rename from prometheus/exporters/mysqld.service rename to prometheus/exporters/etc/systemd/systemd/prometheus-mysqld-exporter.service