From 0be22447dc456a972fbb28445e446af98236ab3a Mon Sep 17 00:00:00 2001 From: Weifeng Wang Date: Tue, 2 Apr 2024 12:48:29 +0800 Subject: [PATCH] Update Examples README.md Signed-off-by: Weifeng Wang Update README.md Signed-off-by: Weifeng Wang Better Update README.md Signed-off-by: Weifeng Wang Update README.md Signed-off-by: Weifeng Wang --- .../monolithic-mode/metrics/compose.yaml | 41 ++++++++++++- examples/README.md | 59 ++++++++++++++++--- examples/ghe-with-mixin/README.md | 53 ++++++++--------- examples/ghe-with-mixin/compose.yaml | 7 ++- examples/ghe-with-simple-dashboards/README.md | 51 ++++++++++++++++ .../ghe-with-simple-dashboards/compose.yaml | 7 ++- examples/github-exporter/README.md | 41 ++++--------- examples/github-exporter/compose.yaml | 3 +- examples/grafana-oncall/README.md | 34 ++++++++--- examples/grafana-oncall/compose.yaml | 5 +- 10 files changed, 219 insertions(+), 82 deletions(-) create mode 100644 examples/ghe-with-simple-dashboards/README.md diff --git a/docker-compose/monolithic-mode/metrics/compose.yaml b/docker-compose/monolithic-mode/metrics/compose.yaml index a4150219..1d4c1c25 100644 --- a/docker-compose/monolithic-mode/metrics/compose.yaml +++ b/docker-compose/monolithic-mode/metrics/compose.yaml @@ -10,7 +10,6 @@ version: '3.9' include: - path: ../../common/compose-include/minio.yaml - path: ../../common/compose-include/memcached.yaml - - path: ../../common/compose-include/mimir.yaml - path: ../../common/compose-include/grafana.yaml services: @@ -70,3 +69,43 @@ services: interval: 10s timeout: 5s retries: 5 + + mimir: + depends_on: + minio: + condition: service_healthy + image: ${MIMIR_IMAGE:-docker.io/grafana/mimir:2.11.0} + volumes: + - ../config/mimir:/etc/mimir + command: + - -config.file=/etc/mimir/monolithic-mode-metrics.yaml + - -target=all + - -config.expand-env=true + healthcheck: + test: [ "CMD-SHELL", "wget --no-verbose --tries=1 --spider http://localhost:8080/ready || exit 1" ] + interval: 10s + timeout: 5s + retries: 5 + # expose 38080 port so we can directly access mimir inside container + ports: + - "38080:8080" + networks: + default: + aliases: + - mimir-memberlist + + mimirtool: + labels: + metrics.agent.grafana.com/scrape: false + image: ${MIMIRTOOL_IMAGE:-docker.io/grafana/mimirtool:2.11.0} + volumes: + - ../../../monitoring-mixins/crontab:/etc/crontabs/root + - ../../../monitoring-mixins/agent-flow-mixin/deploy/agent-flow-mixin-alerts.yaml:/rules/agent-flow-mixin-alerts.yaml + - ../../../monitoring-mixins/memcached-mixin/deploy/memcached-mixin-alerts.yaml:/rules/memcached-mixin-alerts.yaml + - ../../../monitoring-mixins/mimir-mixin/deploy/mimir-mixin-rules.yaml:/rules/mimir-mixin-rules.yaml + - ../../../monitoring-mixins/mimir-mixin/deploy/mimir-mixin-alerts.yaml:/rules/mimir-mixin-alerts.yaml + environment: + - MIMIR_ADDRESS=http://gateway:8080 + - MIMIR_TENANT_ID=anonymous + entrypoint: crond -f + restart: always diff --git a/examples/README.md b/examples/README.md index 3c1b8f26..90f6f313 100644 --- a/examples/README.md +++ b/examples/README.md @@ -2,15 +2,56 @@ This directory contains examples, including: -- [github-exporter](./github-exporter/README.md) +- [github-exporter-with-mixin](./ghe-with-mixin) +- [github-exporter-with-simple-dashboards](./ghe-with-simple-dashboards) +- [github-exporter](./github-exporter) +- [grafana-oncall-integration](./grafana-oncall) -The following ports will be exposed on the host: +## Debug info -- Loki on -- Grafana on -- Grafana Agent on -- Tempo on -- Mimir on -- Pyroscope on +`grafana-agent` target scrape: -The Minio console is available at + + +## Grafana LGTMP Stack default port-mapping + +| Port-mapping | Component | Description | +| --- | --- | --- | +| `12345:12345`, `4317`, `4318`, `6831` | [Grafana Agent][1] | Eexpose `12345` port so we can directly access `grafana-agent` inside container | +| `33100:3100` | [Loki][2] | Expose `33100` port so we can directly access `loki` inside container | +| `3000:3000`, `6060` | [Grafana][3] | Expose `3000` port so we can directly access `grafana` inside container | +| `33200:3200`, `4317`, `4318` | [Tempo][4] | Expose `33200` port so we can directly access `tempo` inside container | +| `38080:8080` | [Mimir][5] | Expose `38080` port so we can directly access `mimir` inside container | +| `34040:4040` | [Pyroscope][6] | Expose `34040` port so we can directly access `pyroscope` inside container | +| `9001:9001`, `9000` | [Minio][7] | Expose `9001` port so we can access `minio` console with `MINIO_ROOT_USER=lgtmp`, `MINIO_ROOT_PASSWORD=supersecret` | +| `39000:9000`, `2500`, `1100` | [Inbucket][8] | Expose `39000` port to use for the email testing server web interface. | + +[1]: https://github.com/grafana/agent +[2]: https://github.com/grafana/loki +[3]: https://github.com/grafana/grafana +[4]: https://github.com/grafana/tempo +[5]: https://github.com/grafana/mimir +[6]: https://github.com/grafana/pyroscope +[7]: https://github.com/minio/minio +[8]: https://github.com/inbucket/inbucket + +## Resource Utilization + +```shell +COMPOSE_EXPERIMENTAL_GIT_REMOTE=true docker compose stats +``` + +```shell +CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS +613d8d5e7e30 root-grafana-agent-1 2.72% 180.7MiB / 1.889GiB 9.34% 1.46MB / 4.61MB 3.15MB / 1.56MB 11 +53443e6d4c31 root-gateway-1 0.00% 8.102MiB / 1.889GiB 0.42% 497kB / 503kB 6.45MB / 20.5kB 3 +750ace278979 root-mimir-1 1.06% 121.2MiB / 1.889GiB 6.27% 5.09MB / 888kB 111kB / 8.7MB 8 +acb81816e078 root-loki-1 1.11% 83.13MiB / 1.889GiB 4.30% 157kB / 336kB 56.2MB / 340kB 8 +f5f28089da9c root-memcached-1 0.03% 6.762MiB / 1.889GiB 0.35% 31.6kB / 128kB 0B / 0B 10 +a91be648c677 root-memcached-exporter-1 0.00% 7.125MiB / 1.889GiB 0.37% 126kB / 75.2kB 0B / 0B 5 +4f755dee256b root-minio-1 3.99% 163.3MiB / 1.889GiB 8.44% 367kB / 889kB 1.77MB / 557kB 12 +fab3799e6a97 root-grafana-1 7.37% 72.63MiB / 1.889GiB 3.76% 666kB / 790kB 1.01MB / 34.2MB 9 +d16d6664924c root-load-rules-to-mimir-1 0.00% 31.69MiB / 1.889GiB 1.64% 54.7kB / 117kB 44.9MB / 4.1kB 1 +72262bb29bd1 root-github-exporter-1 0.00% 9.906MiB / 1.889GiB 0.51% 141kB / 41.4kB 3.4MB / 0B 5 + +``` diff --git a/examples/ghe-with-mixin/README.md b/examples/ghe-with-mixin/README.md index 3143ab55..ca2f9d63 100644 --- a/examples/ghe-with-mixin/README.md +++ b/examples/ghe-with-mixin/README.md @@ -4,16 +4,38 @@ Exposes basic metrics for your repositories from the GitHub API, to a Prometheus ## Docker compose +`compose.yaml`: + ```yaml include: +# use git remote - path: https://github.com/qclaogui/codelab-monitoring.git#main:docker-compose/monolithic-mode/logs/compose.yaml +# use local path +# - path: ../../docker-compose/monolithic-mode/logs/compose.yaml services: github-exporter: + labels: + metrics.agent.grafana.com/scrape: true image: githubexporter/github-exporter:1.1.0 environment: - - REPOS=qclaogui/codelab-monitoring + - REPOS=grafana/agent +``` +`compose.override.yaml`: + +```yaml +services: + # override included service grafana for dashboards pre-provisioning + grafana: + volumes: + - ../../monitoring-mixins/github-mixin/deploy/dashboards_out:/var/lib/grafana/dashboards/github-mixin + + # override included service mimirtool for rules and alerts pre-provisioning + mimirtool: + volumes: + - ../../monitoring-mixins/github-mixin/deploy/github-mixin-rules.yaml:/rules/github-mixin-rules.yaml + - ../../monitoring-mixins/github-mixin/deploy/github-mixin-alerts.yaml:/rules/github-mixin-alerts.yaml ``` ## Try it @@ -22,37 +44,14 @@ services: COMPOSE_EXPERIMENTAL_GIT_REMOTE=true docker compose up -d --remove-orphans ``` -```shell -COMPOSE_EXPERIMENTAL_GIT_REMOTE=true docker compose down -``` - -Once all containers are up and running you can search for metrics(from Mimir) logs(from Loki) traces(from Tempo) and profiles(Pyroscope) in Grafana. +Once all containers are up and running you can search for metrics in Grafana. > In this case you can find `github-exporter` metrics and logs. Navigate to [http://localhost:3000](http://localhost:3000) -## Debug info(`grafana-agent` target scrape) - - - -## Resource Utilization - -```shell -COMPOSE_EXPERIMENTAL_GIT_REMOTE=true docker compose stats -``` +## Stop services ```shell -CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS -613d8d5e7e30 root-grafana-agent-1 2.72% 180.7MiB / 1.889GiB 9.34% 1.46MB / 4.61MB 3.15MB / 1.56MB 11 -53443e6d4c31 root-gateway-1 0.00% 8.102MiB / 1.889GiB 0.42% 497kB / 503kB 6.45MB / 20.5kB 3 -750ace278979 root-mimir-1 1.06% 121.2MiB / 1.889GiB 6.27% 5.09MB / 888kB 111kB / 8.7MB 8 -acb81816e078 root-loki-1 1.11% 83.13MiB / 1.889GiB 4.30% 157kB / 336kB 56.2MB / 340kB 8 -f5f28089da9c root-memcached-1 0.03% 6.762MiB / 1.889GiB 0.35% 31.6kB / 128kB 0B / 0B 10 -a91be648c677 root-memcached-exporter-1 0.00% 7.125MiB / 1.889GiB 0.37% 126kB / 75.2kB 0B / 0B 5 -4f755dee256b root-minio-1 3.99% 163.3MiB / 1.889GiB 8.44% 367kB / 889kB 1.77MB / 557kB 12 -fab3799e6a97 root-grafana-1 7.37% 72.63MiB / 1.889GiB 3.76% 666kB / 790kB 1.01MB / 34.2MB 9 -d16d6664924c root-load-rules-to-mimir-1 0.00% 31.69MiB / 1.889GiB 1.64% 54.7kB / 117kB 44.9MB / 4.1kB 1 -72262bb29bd1 root-github-exporter-1 0.00% 9.906MiB / 1.889GiB 0.51% 141kB / 41.4kB 3.4MB / 0B 5 - +COMPOSE_EXPERIMENTAL_GIT_REMOTE=true docker compose down ``` diff --git a/examples/ghe-with-mixin/compose.yaml b/examples/ghe-with-mixin/compose.yaml index 759981e2..c71266c1 100644 --- a/examples/ghe-with-mixin/compose.yaml +++ b/examples/ghe-with-mixin/compose.yaml @@ -10,9 +10,10 @@ # include is available in Docker Compose version 2.20 and later, and Docker Desktop version 4.22 and later. # docs: https://docs.docker.com/compose/multiple-compose-files/include/#include-and-overrides include: -# - path: https://github.com/qclaogui/codelab-monitoring.git#main:docker-compose/monolithic-mode/logs/compose.yaml -# Local -- path: ../../docker-compose/monolithic-mode/logs/compose.yaml +# use git remote +- path: https://github.com/qclaogui/codelab-monitoring.git#main:docker-compose/monolithic-mode/logs/compose.yaml +# use local path +# - path: ../../docker-compose/monolithic-mode/logs/compose.yaml services: github-exporter: diff --git a/examples/ghe-with-simple-dashboards/README.md b/examples/ghe-with-simple-dashboards/README.md new file mode 100644 index 00000000..986ca417 --- /dev/null +++ b/examples/ghe-with-simple-dashboards/README.md @@ -0,0 +1,51 @@ +# Prometheus GitHub Exporter + +Exposes basic metrics for your repositories from the GitHub API, to a Prometheus compatible endpoint. + +## Docker compose + +`compose.yaml`: + +```yaml +include: +# use git remote +- path: https://github.com/qclaogui/codelab-monitoring.git#main:docker-compose/monolithic-mode/logs/compose.yaml +# use local path +# - path: ../../docker-compose/monolithic-mode/logs/compose.yaml + +services: + github-exporter: + labels: + metrics.agent.grafana.com/scrape: true + image: githubexporter/github-exporter:1.1.0 + environment: + - REPOS=grafana/agent +``` + +`compose.override.yaml`: + +```yaml +services: + # override included service grafana for dashboards pre-provisioning + grafana: + volumes: + - ./dashboards:/var/lib/grafana/dashboards/github-mixin +``` + +## Try it + +```shell +COMPOSE_EXPERIMENTAL_GIT_REMOTE=true docker compose up -d --remove-orphans +``` + +Once all containers are up and running you can search for metrics in Grafana. + +> In this case you can find `github-exporter` metrics and logs. + +Navigate to [http://localhost:3000](http://localhost:3000) + +## Stop services + +```shell +COMPOSE_EXPERIMENTAL_GIT_REMOTE=true docker compose down +``` diff --git a/examples/ghe-with-simple-dashboards/compose.yaml b/examples/ghe-with-simple-dashboards/compose.yaml index c18a02ce..5e43b18c 100644 --- a/examples/ghe-with-simple-dashboards/compose.yaml +++ b/examples/ghe-with-simple-dashboards/compose.yaml @@ -10,9 +10,10 @@ # include is available in Docker Compose version 2.20 and later, and Docker Desktop version 4.22 and later. # docs: https://docs.docker.com/compose/multiple-compose-files/include/#include-and-overrides include: -# - path: https://github.com/qclaogui/codelab-monitoring.git#main:docker-compose/monolithic-mode/logs/compose.yaml -# Local -- path: ../../docker-compose/monolithic-mode/logs/compose.yaml +# use git remote +- path: https://github.com/qclaogui/codelab-monitoring.git#main:docker-compose/monolithic-mode/logs/compose.yaml +# use local path +# - path: ../../docker-compose/monolithic-mode/logs/compose.yaml services: github-exporter: diff --git a/examples/github-exporter/README.md b/examples/github-exporter/README.md index 24dd7939..4d7354ce 100644 --- a/examples/github-exporter/README.md +++ b/examples/github-exporter/README.md @@ -4,18 +4,22 @@ Exposes basic metrics for your repositories from the GitHub API, to a Prometheus ## Docker compose -```yaml +`compose.yaml`: +```yaml include: +# use git remote - path: https://github.com/qclaogui/codelab-monitoring.git#main:docker-compose/monolithic-mode/logs/compose.yaml +# use local path +# - path: ../../docker-compose/monolithic-mode/logs/compose.yaml -# https://github.com/qclaogui/codelab-monitoring/blob/main/docker-compose/common/config/agent-flow/modules/docker/README.md services: github-exporter: + labels: + metrics.agent.grafana.com/scrape: true image: githubexporter/github-exporter:1.1.0 environment: - - REPOS=qclaogui/codelab-monitoring - + - REPOS=grafana/agent ``` ## Try it @@ -24,37 +28,14 @@ services: COMPOSE_EXPERIMENTAL_GIT_REMOTE=true docker compose up -d --remove-orphans ``` -```shell -COMPOSE_EXPERIMENTAL_GIT_REMOTE=true docker compose down -``` - -Once all containers are up and running you can search for metrics(from Mimir) logs(from Loki) traces(from Tempo) and profiles(Pyroscope) in Grafana. +Once all containers are up and running you can search for metrics in Grafana. > In this case you can find `github-exporter` metrics and logs. Navigate to [http://localhost:3000](http://localhost:3000) -## Debug info(`grafana-agent` target scrape) - - - -## Resource Utilization +## Stop services ```shell -COMPOSE_EXPERIMENTAL_GIT_REMOTE=true docker compose stats -``` - -```shell -CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS -613d8d5e7e30 root-grafana-agent-1 2.72% 180.7MiB / 1.889GiB 9.34% 1.46MB / 4.61MB 3.15MB / 1.56MB 11 -53443e6d4c31 root-gateway-1 0.00% 8.102MiB / 1.889GiB 0.42% 497kB / 503kB 6.45MB / 20.5kB 3 -750ace278979 root-mimir-1 1.06% 121.2MiB / 1.889GiB 6.27% 5.09MB / 888kB 111kB / 8.7MB 8 -acb81816e078 root-loki-1 1.11% 83.13MiB / 1.889GiB 4.30% 157kB / 336kB 56.2MB / 340kB 8 -f5f28089da9c root-memcached-1 0.03% 6.762MiB / 1.889GiB 0.35% 31.6kB / 128kB 0B / 0B 10 -a91be648c677 root-memcached-exporter-1 0.00% 7.125MiB / 1.889GiB 0.37% 126kB / 75.2kB 0B / 0B 5 -4f755dee256b root-minio-1 3.99% 163.3MiB / 1.889GiB 8.44% 367kB / 889kB 1.77MB / 557kB 12 -fab3799e6a97 root-grafana-1 7.37% 72.63MiB / 1.889GiB 3.76% 666kB / 790kB 1.01MB / 34.2MB 9 -d16d6664924c root-load-rules-to-mimir-1 0.00% 31.69MiB / 1.889GiB 1.64% 54.7kB / 117kB 44.9MB / 4.1kB 1 -72262bb29bd1 root-github-exporter-1 0.00% 9.906MiB / 1.889GiB 0.51% 141kB / 41.4kB 3.4MB / 0B 5 - +COMPOSE_EXPERIMENTAL_GIT_REMOTE=true docker compose down ``` diff --git a/examples/github-exporter/compose.yaml b/examples/github-exporter/compose.yaml index b6481931..7f099307 100644 --- a/examples/github-exporter/compose.yaml +++ b/examples/github-exporter/compose.yaml @@ -10,13 +10,14 @@ # include is available in Docker Compose version 2.20 and later, and Docker Desktop version 4.22 and later. # docs: https://docs.docker.com/compose/multiple-compose-files/include/#include-and-overrides include: +# use git remote # - path: https://github.com/qclaogui/codelab-monitoring.git#main:docker-compose/monolithic-mode/all-in-one/compose.yaml # All in one(Logs Traces Metrics Profiles) # - path: https://github.com/qclaogui/codelab-monitoring.git#main:docker-compose/monolithic-mode/metrics/compose.yaml # Metrics # - path: https://github.com/qclaogui/codelab-monitoring.git#main:docker-compose/monolithic-mode/logs/compose.yaml # Metrics and Logs # - path: https://github.com/qclaogui/codelab-monitoring.git#main:docker-compose/monolithic-mode/traces/compose.yaml # Metrics and Traces # - path: https://github.com/qclaogui/codelab-monitoring.git#main:docker-compose/monolithic-mode/profiles/compose.yaml # Metrics and Profiles -# Local +# use local path - path: ../../docker-compose/monolithic-mode/logs/compose.yaml # - path: ../../docker-compose/read-write-mode/logs/compose.yaml # - path: ../../docker-compose/microservices-mode/logs/compose.yaml diff --git a/examples/grafana-oncall/README.md b/examples/grafana-oncall/README.md index 4d70f879..067e4bab 100644 --- a/examples/grafana-oncall/README.md +++ b/examples/grafana-oncall/README.md @@ -13,14 +13,14 @@ Developer-friendly incident response with brilliant Slack integration. ## Docker `compose.yaml` +`compose.yaml`: + ```yaml -# Note: -# include is available in Docker Compose version 2.20 and later, and Docker Desktop version 4.22 and later. -# docs: https://docs.docker.com/compose/multiple-compose-files/include/#include-and-overrides include: -- path: - - https://github.com/qclaogui/codelab-monitoring.git#main:docker-compose/monolithic-mode/logs/compose.yaml - - ./compose.override.yaml +# use git remote +- path: https://github.com/qclaogui/codelab-monitoring.git#main:docker-compose/monolithic-mode/logs/compose.yaml +# use local path +# - path: ../../docker-compose/monolithic-mode/logs/compose.yaml services: grafana-oncall: @@ -30,14 +30,34 @@ services: ``` +`compose.override.yaml`: + +```yaml + +services: + # override included service grafana environment + grafana: + volumes: + - ./config/grafana/provisioning/plugins/grafana-oncall-app.yaml:/etc/grafana/provisioning/plugins/grafana-oncall-app.yaml + - ./config/grafana/provisioning/plugins/redis-app.yaml:/etc/grafana/provisioning/plugins/redis-app.yaml + - ./config/grafana/provisioning/datasources/redis.yaml:/etc/grafana/provisioning/datasources/redis.yaml + environment: + GF_SECURITY_ADMIN_USER: oncall + GF_SECURITY_ADMIN_PASSWORD: oncall + GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS: grafana-oncall-app + GF_INSTALL_PLUGINS: grafana-oncall-app v1.3.115, redis-app v2.2.1 +``` + ## Launch services ```shell COMPOSE_EXPERIMENTAL_GIT_REMOTE=true docker compose up -d --remove-orphans ``` +Once all containers are up and running you can search for metrics in Grafana. + > [!IMPORTANT] -> 😞 Grafana OnCall is available for authorized users only, please sign in to proceed. For this example log in credentials: `oncall`/`oncall`. +> 😞 Grafana OnCall is available for authorized users only, please sign in to proceed. For this example login credentials: `oncall`/`oncall`. Navigate to [http://localhost:3000](http://localhost:3000) diff --git a/examples/grafana-oncall/compose.yaml b/examples/grafana-oncall/compose.yaml index 7a74b315..6906e2ce 100644 --- a/examples/grafana-oncall/compose.yaml +++ b/examples/grafana-oncall/compose.yaml @@ -10,7 +10,10 @@ # include is available in Docker Compose version 2.20 and later, and Docker Desktop version 4.22 and later. # docs: https://docs.docker.com/compose/multiple-compose-files/include/#include-and-overrides include: -- path: ../../docker-compose/monolithic-mode/logs/compose.yaml +# use git remote +- path: https://github.com/qclaogui/codelab-monitoring.git#main:docker-compose/monolithic-mode/logs/compose.yaml +# use local path +# - path: ../../docker-compose/monolithic-mode/logs/compose.yaml x-environment: &oncall-environment SEND_ANONYMOUS_USAGE_STATS: ${SEND_ANONYMOUS_USAGE_STATS:-false}