From 94c9a56a6a41c862bf89faf12cbecc7d94271d61 Mon Sep 17 00:00:00 2001 From: tuanvu Date: Fri, 13 Feb 2026 18:07:33 +0100 Subject: [PATCH 1/3] add prometheus and grafana but still have to find templates dashboard for prometheus and munin --- dockercompose/docker-compose.yml | 31 +++++++++++++++++++ .../provisioning/datasources/datasource.yml | 11 +++++++ prometheus/prometheus.yml | 8 +++++ 3 files changed, 50 insertions(+) create mode 100644 grafana/provisioning/datasources/datasource.yml create mode 100644 prometheus/prometheus.yml diff --git a/dockercompose/docker-compose.yml b/dockercompose/docker-compose.yml index 981c221..466b8ff 100644 --- a/dockercompose/docker-compose.yml +++ b/dockercompose/docker-compose.yml @@ -1,4 +1,35 @@ services: + #https://dev.to/rafi021/how-to-set-up-a-monitoring-stack-with-prometheus-grafana-and-node-exporter-using-docker-compose-17cc + #https://belginux.com/monitoring-docker-grafana-prometheus-cadvisor/ + #https://github.com/Einsteinish/Docker-Compose-Prometheus-and-Grafana/tree/master + prometheus: + image: prom/prometheus:latest + container_name: prometheus + restart: unless-stopped + ports: + - "9090:9090" + volumes: + - ../prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro + command: + - "--config.file=/etc/prometheus/prometheus.yml" + networks: + - app-network + + grafana: + image: grafana/grafana:latest + container_name: grafana + restart: unless-stopped + volumes: + - grafana-data:/var/lib/grafana + - ../grafana/provisioning:/etc/grafana/provisioning + depends_on: + - prometheus + environment: + - GF_SECURITY_ADMIN_USER=tlc + - GF_SECURITY_ADMIN_PASSWORD=tlc + networks: + - app-network + front: build: context: .. diff --git a/grafana/provisioning/datasources/datasource.yml b/grafana/provisioning/datasources/datasource.yml new file mode 100644 index 0000000..bb37f13 --- /dev/null +++ b/grafana/provisioning/datasources/datasource.yml @@ -0,0 +1,11 @@ +apiVersion: 1 + +datasources: + - name: Prometheus + type: prometheus + access: proxy + orgId: 1 + url: http://prometheus:9090 + basicAuth: false + isDefault: true + editable: true \ No newline at end of file diff --git a/prometheus/prometheus.yml b/prometheus/prometheus.yml new file mode 100644 index 0000000..6486a38 --- /dev/null +++ b/prometheus/prometheus.yml @@ -0,0 +1,8 @@ +global: + scrape_interval: 15s + +scrape_configs: + - job_name: "backend_quarkus" + metrics_path: /q/metrics + static_configs: + - targets: ["back:8080"] From eb4d3caa8dc2268542767670851702cfff1d7dbd Mon Sep 17 00:00:00 2001 From: tuanvu Date: Fri, 13 Feb 2026 20:04:15 +0100 Subject: [PATCH 2/3] change grafana to dockerfile to add munin after --- dockercompose/docker-compose.yml | 7 ++++++- dockerfiles/grafana/Dockerfile | 2 ++ prometheus/prometheus.yml | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 dockerfiles/grafana/Dockerfile diff --git a/dockercompose/docker-compose.yml b/dockercompose/docker-compose.yml index 466b8ff..e5ea944 100644 --- a/dockercompose/docker-compose.yml +++ b/dockercompose/docker-compose.yml @@ -12,11 +12,16 @@ services: - ../prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro command: - "--config.file=/etc/prometheus/prometheus.yml" + depends_on: + - back + - db networks: - app-network grafana: - image: grafana/grafana:latest + build: + context: .. + dockerfile: dockerfiles/grafana/Dockerfile container_name: grafana restart: unless-stopped volumes: diff --git a/dockerfiles/grafana/Dockerfile b/dockerfiles/grafana/Dockerfile new file mode 100644 index 0000000..c0fae39 --- /dev/null +++ b/dockerfiles/grafana/Dockerfile @@ -0,0 +1,2 @@ +FROM grafana/grafana:latest +RUN grafana-cli plugins install grafana-munin-datasource \ No newline at end of file diff --git a/prometheus/prometheus.yml b/prometheus/prometheus.yml index 6486a38..a8e5997 100644 --- a/prometheus/prometheus.yml +++ b/prometheus/prometheus.yml @@ -5,4 +5,4 @@ scrape_configs: - job_name: "backend_quarkus" metrics_path: /q/metrics static_configs: - - targets: ["back:8080"] + - targets: ["back:8080"] \ No newline at end of file From 0976663ea60870ea0225e17c030177ad0854189b Mon Sep 17 00:00:00 2001 From: tuanvu Date: Fri, 13 Feb 2026 21:26:13 +0100 Subject: [PATCH 3/3] add 127.0.0.1 to munin node to see it works or not --- ansible/playbook.yml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/ansible/playbook.yml b/ansible/playbook.yml index ebb7569..02d9e71 100755 --- a/ansible/playbook.yml +++ b/ansible/playbook.yml @@ -16,7 +16,7 @@ #Apache Configuration - name: Install LAMP Packages apt: - name: [ 'apache2', 'python3-pip', 'mysql-server', 'php', 'php-mysql', 'libapache2-mod-php' ] + name: [ 'apache2', 'python3-pip', 'mysql-server', 'php', 'php-mysql', 'libapache2-mod-php', 'munin-node' ] state: present - name: Make sure pymysql is present @@ -76,6 +76,19 @@ port: "{{ http_port }}" proto: tcp + # Munin Configuration + #https://stackoverflow.com/questions/77941169/ansible-add-line-update-etc-hosts-when-outdated + - name: Install Munin Node + ansible.builtin.lineinfile: + path: /etc/munin/munin-node.conf + regexp: '^allow' + line: "allow ^127\\.0\\.0\\.1$" + + - name: Restart munin-node + systemd: + name: munin-node + state: restarted + enabled: yes - name : configure docker-compose copy: