🏗️」 wip: prom added :D

This commit is contained in:
2025-07-22 14:57:54 +02:00
parent e523c1710c
commit 12445e22e4
13 changed files with 115 additions and 3 deletions

View File

@ -1,5 +1,9 @@
name: ft_transcendence
include:
- ./volumes.yml
- ./monitoring/compose.yml
services:
front:
container_name: transcendence-front
@ -9,7 +13,8 @@ services:
ports:
- ${OUT_PORT}:443
environment:
SERVER_NAME: localhost
- SERVER_NAME=localhost
- TZ=Europe/Paris
depends_on:
user-api:
condition: service_started
@ -17,8 +22,6 @@ services:
condition: service_started
networks:
- front
environment:
- TZ=Europe/Paris
restart: unless-stopped
user-api:
container_name: transcendence-api-user

View File

@ -0,0 +1,6 @@
include:
- ./prometheus/compose.yml
networks:
prom:
prom-exporter:

View File

@ -0,0 +1,3 @@
FROM grafana/grafana-oss

View File

@ -0,0 +1,10 @@
services:
graphana:
container_name: transcendence-graphana
build:
dockerfile: Dockerfile
context: .
environment:
-
networks:
- prom

View File

@ -0,0 +1,11 @@
FROM prom/prometheus
ARG PROM_ADMIN_PASSWD
ARG PROM_ADMIN_PASSWD_HASH
COPY ./config/prometheus.yml /etc/prometheus/prometheus.yml
COPY ./config/web-config.yml /etc/prometheus/web-config.yml
COPY ./config/rules.yml /etc/prometheus/rules.yml
RUN sed -i "s/PROM_ADMIN_PASSWD/$(printf '%s\n' "$PROM_ADMIN_PASSWD" | sed -e 's/[\/&]/\\&/g')/g" /etc/prometheus/prometheus.yml
RUN sed -i "s/PROM_ADMIN_PASSWD_HASH/$(printf '%s\n' "$PROM_ADMIN_PASSWD_HASH" | sed -e 's/[\/&]/\\&/g')/g" /etc/prometheus/web-config.yml

View File

@ -0,0 +1,29 @@
services:
prometheus:
container_name: transcendence-prom
build:
dockerfile: Dockerfile
context: .
args:
PROM_ADMIN_PASSWD: ${PROM_PASS}
PROM_ADMIN_PASSWD_HASH: ${PROM_HASH}
environment:
- TZ=Europe/Paris
ports:
- 9090:9090
volumes:
- prometheus_data:/prometheus
depends_on:
front:
condition: service_started
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--web.config.file=/etc/prometheus/web-config.yml'
- '--web.external-url=/prometheus/'
- '--web.console.libraries=/etc/prometheus/console_libraries'
- '--web.console.templates=/etc/prometheus/consoles'
- '--web.enable-lifecycle'
networks:
- prom
restart: unless-stopped

View File

@ -0,0 +1,17 @@
global:
scrape_interval: 30s
# alerting:
# alertmanagers:
# - static_configs:
# - targets:
# - alertmanager:9093
scrape_configs:
- job_name: 'prometheus'
metrics_path: '/prometheus/metrics'
basic_auth:
username: admin
password: PROM_ADMIN_PASSWD
static_configs:
- targets: ['localhost:9090']

View File

@ -0,0 +1,12 @@
groups:
- name: AllInstances
rules:
- alert: InstanceDown
# Condition for alerting
expr: up == 0
for: 20s
annotations:
title: 'Instance {{ $labels.instance }} down'
description: '{{ $labels.instance }} of job {{ $labels.job }} has been down for more than 20 seconds.'
labels:
severity: 'critical'

View File

@ -0,0 +1,2 @@
basic_auth_users:
admin: PROM_ADMIN_PASSWD_HASH

2
docker/volumes.yml Normal file
View File

@ -0,0 +1,2 @@
volumes:
prometheus_data: