From ee45f83832b6a35be627c82c82c51951e89e5e97 Mon Sep 17 00:00:00 2001 From: Changyu Moon <121847433+window9u@users.noreply.github.com> Date: Wed, 4 Sep 2024 12:56:07 +0900 Subject: [PATCH 01/14] Add comment of prometheus target address --- build/docker/prometheus.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build/docker/prometheus.yml b/build/docker/prometheus.yml index 8f9792960..6e14ab159 100644 --- a/build/docker/prometheus.yml +++ b/build/docker/prometheus.yml @@ -5,4 +5,6 @@ scrape_configs: static_configs: - targets: # win/mac hosts: Use address: host.docker.internal instead of address: localhost in the line below + # linux hosts: Use address: docker bridge ip (typically 172.17.0.1) instead of address: localhost in the line below + # when using docker-compose-deploy.yml, use address: yorkie instead of address: localhost in the line below - host.docker.internal:8081 From 77841145b6ab7fcf407e33167450f98e953bd5cd Mon Sep 17 00:00:00 2001 From: Changyu Moon <121847433+window9u@users.noreply.github.com> Date: Wed, 4 Sep 2024 13:54:33 +0900 Subject: [PATCH 02/14] Add docker-compose-deploy.yml this file also launches yorkie with docker-compose-full.yml --- build/docker/docker-compose-deploy.yml | 45 ++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 build/docker/docker-compose-deploy.yml diff --git a/build/docker/docker-compose-deploy.yml b/build/docker/docker-compose-deploy.yml new file mode 100644 index 000000000..96980585f --- /dev/null +++ b/build/docker/docker-compose-deploy.yml @@ -0,0 +1,45 @@ +version: '3.3' + +services: + prometheus: + image: prom/prometheus:latest + container_name: prometheus + ports: + - '9090:9090' + command: + - --config.file=/etc/prometheus/prometheus.yml + volumes: + - ./prometheus.yml:/etc/prometheus/prometheus.yml:ro + grafana: + image: grafana/grafana:latest + container_name: grafana + ports: + - '3000:3000' + command: + - --config=/etc/grafana/grafana.ini + depends_on: + - prometheus + mongo: + image: mongo:latest + container_name: mongo + restart: always + ports: + - '27017:27017' + yorkie: + build: + context: ../../ + dockerfile: Dockerfile + container_name: 'yorkie' + command: + [ + 'server', + '--mongo-connection-uri', + 'mongodb://mongo:27017', + '--enable-pprof', + ] + restart: always + ports: + - '8080:8080' + - '8081:8081' + depends_on: + - mongo \ No newline at end of file From 12898bf3c03516e453c86daf9f45ad77b0bbd2ec Mon Sep 17 00:00:00 2001 From: Changyu Moon <121847433+window9u@users.noreply.github.com> Date: Wed, 4 Sep 2024 13:55:56 +0900 Subject: [PATCH 03/14] Set datasource to prometheus by default --- build/docker/docker-compose-deploy.yml | 2 ++ build/docker/grafana/datasources.yml | 8 ++++++++ 2 files changed, 10 insertions(+) create mode 100644 build/docker/grafana/datasources.yml diff --git a/build/docker/docker-compose-deploy.yml b/build/docker/docker-compose-deploy.yml index 96980585f..08202050a 100644 --- a/build/docker/docker-compose-deploy.yml +++ b/build/docker/docker-compose-deploy.yml @@ -17,6 +17,8 @@ services: - '3000:3000' command: - --config=/etc/grafana/grafana.ini + volumes: + - ./grafana/datasources.yml:/etc/grafana/provisioning/datasources/datasources.yml:ro depends_on: - prometheus mongo: diff --git a/build/docker/grafana/datasources.yml b/build/docker/grafana/datasources.yml new file mode 100644 index 000000000..8049912b1 --- /dev/null +++ b/build/docker/grafana/datasources.yml @@ -0,0 +1,8 @@ +apiVersion: 1 + +datasources: + - name: Prometheus + type: prometheus + access: proxy + url: http://prometheus:9090 + isDefault: true \ No newline at end of file From 34a6ace8201b877d1b5f4355c9c9722885fd7296 Mon Sep 17 00:00:00 2001 From: Changyu Moon <121847433+window9u@users.noreply.github.com> Date: Wed, 4 Sep 2024 13:56:43 +0900 Subject: [PATCH 04/14] Add grafana.ini file for configuration --- build/docker/docker-compose-deploy.yml | 1 + build/docker/grafana/grafana.ini | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 build/docker/grafana/grafana.ini diff --git a/build/docker/docker-compose-deploy.yml b/build/docker/docker-compose-deploy.yml index 08202050a..c48c8b0b4 100644 --- a/build/docker/docker-compose-deploy.yml +++ b/build/docker/docker-compose-deploy.yml @@ -18,6 +18,7 @@ services: command: - --config=/etc/grafana/grafana.ini volumes: + - ./grafana/grafana.ini:/etc/grafana/grafana.ini:ro - ./grafana/datasources.yml:/etc/grafana/provisioning/datasources/datasources.yml:ro depends_on: - prometheus diff --git a/build/docker/grafana/grafana.ini b/build/docker/grafana/grafana.ini new file mode 100644 index 000000000..f67096a44 --- /dev/null +++ b/build/docker/grafana/grafana.ini @@ -0,0 +1,21 @@ +[paths] +provisioning = /etc/grafana/provisioning + +[server] +http_port = 3000 + +[security] +admin_user = admin +admin_password = admin + +[users] +allow_sign_up = true + +[auth.anonymous] +enabled = false + +[dashboards] +versions_to_keep = 20 + +[unified_alerting] +enabled = true \ No newline at end of file From 957f0c22f6561d197dd49956e4c3320b4bcea78a Mon Sep 17 00:00:00 2001 From: Changyu Moon <121847433+window9u@users.noreply.github.com> Date: Wed, 4 Sep 2024 13:57:26 +0900 Subject: [PATCH 05/14] Add dashboard.yml for setting a default dashboard --- build/docker/docker-compose-deploy.yml | 1 + build/docker/grafana/dashboard.yml | 14 ++++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 build/docker/grafana/dashboard.yml diff --git a/build/docker/docker-compose-deploy.yml b/build/docker/docker-compose-deploy.yml index c48c8b0b4..b597ac417 100644 --- a/build/docker/docker-compose-deploy.yml +++ b/build/docker/docker-compose-deploy.yml @@ -18,6 +18,7 @@ services: command: - --config=/etc/grafana/grafana.ini volumes: + - ./grafana/dashboard.yml:/etc/grafana/provisioning/dashboards/dashboard.yml:ro - ./grafana/grafana.ini:/etc/grafana/grafana.ini:ro - ./grafana/datasources.yml:/etc/grafana/provisioning/datasources/datasources.yml:ro depends_on: diff --git a/build/docker/grafana/dashboard.yml b/build/docker/grafana/dashboard.yml new file mode 100644 index 000000000..75c533c43 --- /dev/null +++ b/build/docker/grafana/dashboard.yml @@ -0,0 +1,14 @@ +apiVersion: 1 + +providers: + - name: 'dashboards' + orgId: 1 + folder: '' + folderUid: '' + type: file + disableDeletion: true + updateIntervalSeconds: 10 + allowUiUpdates: true + options: + path: /var/lib/grafana + foldersFromFilesStructure: true \ No newline at end of file From b1e5b648e92c5f2223947976a9c122c9056ac451 Mon Sep 17 00:00:00 2001 From: Changyu Moon <121847433+window9u@users.noreply.github.com> Date: Wed, 4 Sep 2024 13:58:19 +0900 Subject: [PATCH 06/14] Add README.md of grafana setup guide --- build/docker/grafana/README.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 build/docker/grafana/README.md diff --git a/build/docker/grafana/README.md b/build/docker/grafana/README.md new file mode 100644 index 000000000..0f47f95ce --- /dev/null +++ b/build/docker/grafana/README.md @@ -0,0 +1,28 @@ +# Grafana Setup Guide + +## Importing Dashboards + +To import dashboards into Grafana, follow these steps: + +1. Open Grafana in your browser (http://localhost:3000). +2. Log in with the default credentials (admin/admin). +3. Click "Dashboards" in the left sidebar. +4. Click "New" and then "Import". +5. Use the Yorkie dashboard ID `18560` to import the dashboard. +6. Click "Load" and "Import" and the dashboard will be made. + +## Setting a Default Dashboard + +If you want to set a default dashboard, follow these steps: + +1. Open the [Yorkie dashboard](https://grafana.com/grafana/dashboards/18560). +2. Download the dashboard JSON file. +3. Paste the contents into `build/docker/grafana/yorkie_dashboard.json`. +4. Mount the docker volume to the Grafana container by adding the following line to your `docker-compose.yml` file: + + ```yaml + volumes: + - ./grafana/your_dashboard_name.json:/var/lib/grafana/your_dashboard_name.json:ro + ``` + +You can import other dashboards by following the same steps. \ No newline at end of file From 203aba8cb107ef5108698ccdf5f8398895cac169 Mon Sep 17 00:00:00 2001 From: Changyu Moon <121847433+window9u@users.noreply.github.com> Date: Wed, 4 Sep 2024 13:58:58 +0900 Subject: [PATCH 07/14] Update README.md for docker-compose-deploy.yml --- build/docker/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build/docker/README.md b/build/docker/README.md index ef18072f2..1e1fa88c9 100644 --- a/build/docker/README.md +++ b/build/docker/README.md @@ -20,3 +20,5 @@ The docker-compose files we use are as follows: runs MongoDB. - `docker-compose-full.yml`: This file launches all the applications needed to develop Yorkie. It also runs monitoring tools such as Prometheus and Grafana. +- `docker-compose-deploy.yml`: This file is used to deploy Yorkie by one command. + It runs Yorkie, MongoDB, and monitoring tools. \ No newline at end of file From d7908d5c7288c152d5d5b6e42f44754344bea663 Mon Sep 17 00:00:00 2001 From: Changyu Moon <121847433+window9u@users.noreply.github.com> Date: Wed, 4 Sep 2024 15:05:24 +0900 Subject: [PATCH 08/14] Apply coderabbit's recommendation --- build/docker/docker-compose-deploy.yml | 4 ++-- build/docker/grafana/dashboard.yml | 2 +- build/docker/grafana/datasources.yml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build/docker/docker-compose-deploy.yml b/build/docker/docker-compose-deploy.yml index b597ac417..21af6a9f8 100644 --- a/build/docker/docker-compose-deploy.yml +++ b/build/docker/docker-compose-deploy.yml @@ -31,8 +31,8 @@ services: - '27017:27017' yorkie: build: - context: ../../ - dockerfile: Dockerfile + context: ../../ + dockerfile: Dockerfile container_name: 'yorkie' command: [ diff --git a/build/docker/grafana/dashboard.yml b/build/docker/grafana/dashboard.yml index 75c533c43..4c3323506 100644 --- a/build/docker/grafana/dashboard.yml +++ b/build/docker/grafana/dashboard.yml @@ -11,4 +11,4 @@ providers: allowUiUpdates: true options: path: /var/lib/grafana - foldersFromFilesStructure: true \ No newline at end of file + foldersFromFilesStructure: true diff --git a/build/docker/grafana/datasources.yml b/build/docker/grafana/datasources.yml index 8049912b1..86fd3465e 100644 --- a/build/docker/grafana/datasources.yml +++ b/build/docker/grafana/datasources.yml @@ -5,4 +5,4 @@ datasources: type: prometheus access: proxy url: http://prometheus:9090 - isDefault: true \ No newline at end of file + isDefault: true From dd4180f374569873dfee81997926310206d15ad0 Mon Sep 17 00:00:00 2001 From: Changyu Moon <121847433+window9u@users.noreply.github.com> Date: Fri, 6 Sep 2024 13:39:59 +0900 Subject: [PATCH 09/14] Merge docker-compose files into single full version --- build/docker/README.md | 6 ++-- build/docker/docker-compose-deploy.yml | 49 -------------------------- build/docker/docker-compose-full.yml | 30 ++++++++++++++-- 3 files changed, 29 insertions(+), 56 deletions(-) delete mode 100644 build/docker/docker-compose-deploy.yml diff --git a/build/docker/README.md b/build/docker/README.md index 1e1fa88c9..28820835c 100644 --- a/build/docker/README.md +++ b/build/docker/README.md @@ -18,7 +18,5 @@ docker compose -f docker/docker-compose.yml down The docker-compose files we use are as follows: - `docker-compose.yml`: This file is used to run Yorkie's integration tests. It runs MongoDB. -- `docker-compose-full.yml`: This file launches all the applications needed to - develop Yorkie. It also runs monitoring tools such as Prometheus and Grafana. -- `docker-compose-deploy.yml`: This file is used to deploy Yorkie by one command. - It runs Yorkie, MongoDB, and monitoring tools. \ No newline at end of file +- `docker-compose-full.yml`: This file builds Yorkie and launches it. It also runs + MongoDB and monitoring tools such as Prometheus and Grafana. diff --git a/build/docker/docker-compose-deploy.yml b/build/docker/docker-compose-deploy.yml deleted file mode 100644 index 21af6a9f8..000000000 --- a/build/docker/docker-compose-deploy.yml +++ /dev/null @@ -1,49 +0,0 @@ -version: '3.3' - -services: - prometheus: - image: prom/prometheus:latest - container_name: prometheus - ports: - - '9090:9090' - command: - - --config.file=/etc/prometheus/prometheus.yml - volumes: - - ./prometheus.yml:/etc/prometheus/prometheus.yml:ro - grafana: - image: grafana/grafana:latest - container_name: grafana - ports: - - '3000:3000' - command: - - --config=/etc/grafana/grafana.ini - volumes: - - ./grafana/dashboard.yml:/etc/grafana/provisioning/dashboards/dashboard.yml:ro - - ./grafana/grafana.ini:/etc/grafana/grafana.ini:ro - - ./grafana/datasources.yml:/etc/grafana/provisioning/datasources/datasources.yml:ro - depends_on: - - prometheus - mongo: - image: mongo:latest - container_name: mongo - restart: always - ports: - - '27017:27017' - yorkie: - build: - context: ../../ - dockerfile: Dockerfile - container_name: 'yorkie' - command: - [ - 'server', - '--mongo-connection-uri', - 'mongodb://mongo:27017', - '--enable-pprof', - ] - restart: always - ports: - - '8080:8080' - - '8081:8081' - depends_on: - - mongo \ No newline at end of file diff --git a/build/docker/docker-compose-full.yml b/build/docker/docker-compose-full.yml index c6739062d..e62956dc5 100644 --- a/build/docker/docker-compose-full.yml +++ b/build/docker/docker-compose-full.yml @@ -5,16 +5,22 @@ services: image: prom/prometheus:latest container_name: prometheus ports: - - '9090:9090' + - '9090:9090' command: - - --config.file=/etc/prometheus/prometheus.yml + - --config.file=/etc/prometheus/prometheus.yml volumes: - - ./prometheus.yml:/etc/prometheus/prometheus.yml:ro + - ./prometheus.yml:/etc/prometheus/prometheus.yml:ro grafana: image: grafana/grafana:latest container_name: grafana ports: - '3000:3000' + command: + - --config=/etc/grafana/grafana.ini + volumes: + - ./grafana/dashboard.yml:/etc/grafana/provisioning/dashboards/dashboard.yml:ro + - ./grafana/grafana.ini:/etc/grafana/grafana.ini:ro + - ./grafana/datasources.yml:/etc/grafana/provisioning/datasources/datasources.yml:ro depends_on: - prometheus mongo: @@ -23,3 +29,21 @@ services: restart: always ports: - '27017:27017' + yorkie: + build: + context: ../../ + dockerfile: Dockerfile + container_name: 'yorkie' + command: + [ + 'server', + '--mongo-connection-uri', + 'mongodb://mongo:27017', + '--enable-pprof', + ] + restart: always + ports: + - '8080:8080' + - '8081:8081' + depends_on: + - mongo From 848a74c04ea364368913dcb03c709db6b4fc35f5 Mon Sep 17 00:00:00 2001 From: Changyu Moon <121847433+window9u@users.noreply.github.com> Date: Fri, 6 Sep 2024 13:46:04 +0900 Subject: [PATCH 10/14] Rename directory grafana to monitoring --- build/docker/{grafana => monitoring}/README.md | 0 build/docker/{grafana => monitoring}/dashboard.yml | 0 build/docker/{grafana => monitoring}/datasources.yml | 0 build/docker/{grafana => monitoring}/grafana.ini | 2 +- 4 files changed, 1 insertion(+), 1 deletion(-) rename build/docker/{grafana => monitoring}/README.md (100%) rename build/docker/{grafana => monitoring}/dashboard.yml (100%) rename build/docker/{grafana => monitoring}/datasources.yml (100%) rename build/docker/{grafana => monitoring}/grafana.ini (94%) diff --git a/build/docker/grafana/README.md b/build/docker/monitoring/README.md similarity index 100% rename from build/docker/grafana/README.md rename to build/docker/monitoring/README.md diff --git a/build/docker/grafana/dashboard.yml b/build/docker/monitoring/dashboard.yml similarity index 100% rename from build/docker/grafana/dashboard.yml rename to build/docker/monitoring/dashboard.yml diff --git a/build/docker/grafana/datasources.yml b/build/docker/monitoring/datasources.yml similarity index 100% rename from build/docker/grafana/datasources.yml rename to build/docker/monitoring/datasources.yml diff --git a/build/docker/grafana/grafana.ini b/build/docker/monitoring/grafana.ini similarity index 94% rename from build/docker/grafana/grafana.ini rename to build/docker/monitoring/grafana.ini index f67096a44..6145316b9 100644 --- a/build/docker/grafana/grafana.ini +++ b/build/docker/monitoring/grafana.ini @@ -18,4 +18,4 @@ enabled = false versions_to_keep = 20 [unified_alerting] -enabled = true \ No newline at end of file +enabled = true From 05908fe7342e7f144367765c878145ca73a6b83c Mon Sep 17 00:00:00 2001 From: Changyu Moon <121847433+window9u@users.noreply.github.com> Date: Fri, 6 Sep 2024 13:46:49 +0900 Subject: [PATCH 11/14] Move prometheus.yml into monitoring --- build/docker/{ => monitoring}/prometheus.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename build/docker/{ => monitoring}/prometheus.yml (100%) diff --git a/build/docker/prometheus.yml b/build/docker/monitoring/prometheus.yml similarity index 100% rename from build/docker/prometheus.yml rename to build/docker/monitoring/prometheus.yml From 6e5f2731170576a56e7308b53a0c445a1cd03026 Mon Sep 17 00:00:00 2001 From: Changyu Moon <121847433+window9u@users.noreply.github.com> Date: Fri, 6 Sep 2024 13:58:54 +0900 Subject: [PATCH 12/14] Remove setting a default dashboard --- build/docker/monitoring/README.md | 18 +----------------- build/docker/monitoring/dashboard.yml | 14 -------------- 2 files changed, 1 insertion(+), 31 deletions(-) delete mode 100644 build/docker/monitoring/dashboard.yml diff --git a/build/docker/monitoring/README.md b/build/docker/monitoring/README.md index 0f47f95ce..d49d5c0a4 100644 --- a/build/docker/monitoring/README.md +++ b/build/docker/monitoring/README.md @@ -4,25 +4,9 @@ To import dashboards into Grafana, follow these steps: -1. Open Grafana in your browser (http://localhost:3000). +1. Open Grafana in your browser ([http://localhost:3000](http://localhost:3000)). 2. Log in with the default credentials (admin/admin). 3. Click "Dashboards" in the left sidebar. 4. Click "New" and then "Import". 5. Use the Yorkie dashboard ID `18560` to import the dashboard. 6. Click "Load" and "Import" and the dashboard will be made. - -## Setting a Default Dashboard - -If you want to set a default dashboard, follow these steps: - -1. Open the [Yorkie dashboard](https://grafana.com/grafana/dashboards/18560). -2. Download the dashboard JSON file. -3. Paste the contents into `build/docker/grafana/yorkie_dashboard.json`. -4. Mount the docker volume to the Grafana container by adding the following line to your `docker-compose.yml` file: - - ```yaml - volumes: - - ./grafana/your_dashboard_name.json:/var/lib/grafana/your_dashboard_name.json:ro - ``` - -You can import other dashboards by following the same steps. \ No newline at end of file diff --git a/build/docker/monitoring/dashboard.yml b/build/docker/monitoring/dashboard.yml deleted file mode 100644 index 4c3323506..000000000 --- a/build/docker/monitoring/dashboard.yml +++ /dev/null @@ -1,14 +0,0 @@ -apiVersion: 1 - -providers: - - name: 'dashboards' - orgId: 1 - folder: '' - folderUid: '' - type: file - disableDeletion: true - updateIntervalSeconds: 10 - allowUiUpdates: true - options: - path: /var/lib/grafana - foldersFromFilesStructure: true From a11a6951b0696c2d8f9981fea8582edd9c67f0e1 Mon Sep 17 00:00:00 2001 From: Changyu Moon <121847433+window9u@users.noreply.github.com> Date: Fri, 6 Sep 2024 14:14:35 +0900 Subject: [PATCH 13/14] Refactor docker-compose-full - remove dashboard.yml volume in grafana - fix directory name --- build/docker/docker-compose-full.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/build/docker/docker-compose-full.yml b/build/docker/docker-compose-full.yml index e62956dc5..b49563f24 100644 --- a/build/docker/docker-compose-full.yml +++ b/build/docker/docker-compose-full.yml @@ -9,7 +9,7 @@ services: command: - --config.file=/etc/prometheus/prometheus.yml volumes: - - ./prometheus.yml:/etc/prometheus/prometheus.yml:ro + - ./monitoring/prometheus.yml:/etc/prometheus/prometheus.yml:ro grafana: image: grafana/grafana:latest container_name: grafana @@ -18,9 +18,8 @@ services: command: - --config=/etc/grafana/grafana.ini volumes: - - ./grafana/dashboard.yml:/etc/grafana/provisioning/dashboards/dashboard.yml:ro - - ./grafana/grafana.ini:/etc/grafana/grafana.ini:ro - - ./grafana/datasources.yml:/etc/grafana/provisioning/datasources/datasources.yml:ro + - ./monitoring/grafana.ini:/etc/grafana/grafana.ini:ro + - ./monitoring/datasources.yml:/etc/grafana/provisioning/datasources/datasources.yml:ro depends_on: - prometheus mongo: From 74ca981a976682852c4d0c9bab59d0c9513247bf Mon Sep 17 00:00:00 2001 From: Changyu Moon <121847433+window9u@users.noreply.github.com> Date: Fri, 6 Sep 2024 14:16:04 +0900 Subject: [PATCH 14/14] Refactor prometheus target --- build/docker/monitoring/prometheus.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/build/docker/monitoring/prometheus.yml b/build/docker/monitoring/prometheus.yml index 6e14ab159..9cd0205d6 100644 --- a/build/docker/monitoring/prometheus.yml +++ b/build/docker/monitoring/prometheus.yml @@ -4,7 +4,4 @@ scrape_configs: scrape_interval: 5s static_configs: - targets: - # win/mac hosts: Use address: host.docker.internal instead of address: localhost in the line below - # linux hosts: Use address: docker bridge ip (typically 172.17.0.1) instead of address: localhost in the line below - # when using docker-compose-deploy.yml, use address: yorkie instead of address: localhost in the line below - - host.docker.internal:8081 + - yorkie:8081