From 4b3b689d33dc7a89a5a22821d3fd47d34ca2ea12 Mon Sep 17 00:00:00 2001 From: bendanzhentan <455462586@qq.com> Date: Sat, 3 Feb 2024 23:07:10 +0800 Subject: [PATCH] feat: update docker-compose files --- docker-compose.yml | 18 ------------- docker/docker-compose.yml | 43 ++++++++++++++++++++++++++++++++ docker/grafana/datasource.yml | 9 +++++++ docker/prometheus/prometheus.yml | 21 ++++++++++++++++ 4 files changed, 73 insertions(+), 18 deletions(-) delete mode 100644 docker-compose.yml create mode 100644 docker/docker-compose.yml create mode 100644 docker/grafana/datasource.yml create mode 100644 docker/prometheus/prometheus.yml diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index c4db5b3..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,18 +0,0 @@ -version: '3.8' - -services: - mysql: - image: mysql:latest - environment: - - MYSQL_ROOT_PASSWORD=db_password - - MYSQL_DATABASE=db_name - - MYSQL_USER=db_username - - MYSQL_PASSWORD=db_password - command: --default-authentication-plugin=mysql_native_password - ports: - - "3306:3306" - volumes: - - mysql_data:/var/lib/mysql - -volumes: - mysql_data: diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml new file mode 100644 index 0000000..e686168 --- /dev/null +++ b/docker/docker-compose.yml @@ -0,0 +1,43 @@ +version: '3.8' + +services: + mysql: + image: mysql:latest + environment: + - MYSQL_ROOT_PASSWORD=db_password + - MYSQL_DATABASE=db_name + - MYSQL_USER=db_username + - MYSQL_PASSWORD=db_password + command: --default-authentication-plugin=mysql_native_password + ports: + - "3306:3306" + volumes: + - mysql_data:/var/lib/mysql + + prometheus: + image: prom/prometheus + container_name: prometheus + command: + - '--config.file=/etc/prometheus/prometheus.yml' + ports: + - 9090:9090 + restart: unless-stopped + volumes: + - ./prometheus:/etc/prometheus + - prom_data:/prometheus + + grafana: + image: grafana/grafana + container_name: grafana + ports: + - 3000:3000 + restart: unless-stopped + environment: + - GF_SECURITY_ADMIN_USER=admin + - GF_SECURITY_ADMIN_PASSWORD=grafana + volumes: + - ./grafana:/etc/grafana/provisioning/datasources + +volumes: + mysql_data: + prom_data: diff --git a/docker/grafana/datasource.yml b/docker/grafana/datasource.yml new file mode 100644 index 0000000..d7b8286 --- /dev/null +++ b/docker/grafana/datasource.yml @@ -0,0 +1,9 @@ +apiVersion: 1 + +datasources: +- name: Prometheus + type: prometheus + url: http://prometheus:9090 + isDefault: true + access: proxy + editable: true diff --git a/docker/prometheus/prometheus.yml b/docker/prometheus/prometheus.yml new file mode 100644 index 0000000..f48194d --- /dev/null +++ b/docker/prometheus/prometheus.yml @@ -0,0 +1,21 @@ +global: + scrape_interval: 15s + scrape_timeout: 10s + evaluation_interval: 15s +alerting: + alertmanagers: + - static_configs: + - targets: [] + scheme: http + timeout: 10s + api_version: v1 +scrape_configs: +- job_name: prometheus + honor_timestamps: true + scrape_interval: 15s + scrape_timeout: 10s + metrics_path: /metrics + scheme: http + static_configs: + - targets: + - localhost:9090