Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add all-in-one Docker Compose and Grafana configuration #997

Merged
merged 14 commits into from
Sep 6, 2024
Merged
2 changes: 2 additions & 0 deletions build/docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clarify the deployment process in the new section.

The addition of the docker-compose-deploy.yml file is well-documented. However, to enhance clarity and usability:

  • It might be helpful to include more details about what "deploy Yorkie by one command" entails. Specifically, what configurations or setups are handled automatically by this compose file?
  • Consider adding a brief example or command snippet that illustrates how to use this new compose file, similar to the examples provided for the other compose files.

Additionally, address the punctuation issue flagged by the static analysis tool:

  • The dash before "docker-compose-deploy.yml" could be replaced with a colon for better readability and to match the style of documentation.

Would you like me to draft a more detailed explanation or example usage for this section?

Tools
LanguageTool

[uncategorized] ~23-~23: Loose punctuation mark.
Context: ...d Grafana. - docker-compose-deploy.yml: This file is used to deploy Yorkie by o...

(UNLIKELY_OPENING_PUNCTUATION)

49 changes: 49 additions & 0 deletions build/docker/docker-compose-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
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
krapie marked this conversation as resolved.
Show resolved Hide resolved
28 changes: 28 additions & 0 deletions build/docker/grafana/README.md
Original file line number Diff line number Diff line change
@@ -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.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clarify and enhance dashboard import instructions.

The instructions for importing dashboards are clear and concise. However, to comply with Markdown best practices, consider linking the URL text instead of using a bare URL. This enhancement improves readability and user experience.

Suggested change for the bare URL:

-1. Open Grafana in your browser (http://localhost:3000).
+1. Open Grafana in your browser ([http://localhost:3000](http://localhost:3000)).
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
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.
To import dashboards into Grafana, follow these steps:
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.
Tools
Markdownlint

7-7: null
Bare URL used

(MD034, no-bare-urls)

## 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.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enhance instructions for setting a default dashboard.

The steps for setting a default dashboard are well-detailed. However, to avoid confusion, consider specifying the exact location of the docker-compose.yml file and clarifying the example volume path. This will help users correctly implement the changes without ambiguity.

Suggested improvements:

-4. Mount the docker volume to the Grafana container by adding the following line to your `docker-compose.yml` file:
+4. Mount the docker volume to the Grafana container by adding the following line to your `docker-compose.yml` file located at `build/docker/`:

   ```yaml
   volumes:
-    - ./grafana/your_dashboard_name.json:/var/lib/grafana/your_dashboard_name.json:ro
+    - ./grafana/yorkie_dashboard.json:/var/lib/grafana/yorkie_dashboard.json:ro

<!-- This is an auto-generated comment by CodeRabbit -->

14 changes: 14 additions & 0 deletions build/docker/grafana/dashboard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: 1
krapie marked this conversation as resolved.
Show resolved Hide resolved

providers:
- name: 'dashboards'
orgId: 1
folder: ''
folderUid: ''
type: file
disableDeletion: true
updateIntervalSeconds: 10
allowUiUpdates: true
options:
path: /var/lib/grafana
foldersFromFilesStructure: true
8 changes: 8 additions & 0 deletions build/docker/grafana/datasources.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: 1

datasources:
- name: Prometheus
type: prometheus
access: proxy
url: http://prometheus:9090
isDefault: true
21 changes: 21 additions & 0 deletions build/docker/grafana/grafana.ini
Original file line number Diff line number Diff line change
@@ -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
krapie marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 2 additions & 0 deletions build/docker/prometheus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading