pull/35/head
DoTheEvo 2 years ago
parent a1d4afca30
commit 70830ac867

@ -4,12 +4,15 @@
![logo](https://i.imgur.com/e03aF8d.png) ![logo](https://i.imgur.com/e03aF8d.png)
WORK IN PROGRESS<br>
Loki and caddy monitoring parts are not finished yet
# Purpose # Purpose
Monitoring of the host and the running cointaners. Monitoring of the host and the running cointaners.
* [Official Prometheus site](https://prometheus.io/) * [Official Prometheus site](https://prometheus.io/)
* [Github](https://github.com/prometheus) * [Official Grafana site](https://grafana.com/)
Most of the stuff here is based off the magnificent Most of the stuff here is based off the magnificent
[stefanprodan/dockprom.](https://github.com/stefanprodan/dockprom)</br> [stefanprodan/dockprom.](https://github.com/stefanprodan/dockprom)</br>
@ -17,13 +20,11 @@ So maybe just go play with that.
# Chapters # Chapters
Setup here starts off with the basics and then theres chapters how to add features
* **[Core prometheus+grafana](#Overview)** - to get nice dashboards with metrics from docker host and containers * **[Core prometheus+grafana](#Overview)** - to get nice dashboards with metrics from docker host and containers
* **[Pushgateway](#Pushgateway)** - how to use it to allow pushing metrics in to prometheus from anywhere * **[Pushgateway](#Pushgateway)** - how to use it to allow pushing metrics in to prometheus from anywhere
* **[Alertmanager](#Alertmanager)** - how to use it for notifications * **[Alertmanager](#Alertmanager)** - how to use it for notifications
* **Loki** - how to do the above things but for logs, not just metrics * **[Loki](#Loki)** - how to do the above things but for logs, not just metrics
* **Caddy** - adding dashboard for reverse proxy info * **[Caddy monitoring](#Caddy_monitoring)** - adding dashboard for reverse proxy info
# Overview # Overview
@ -110,8 +111,8 @@ services:
image: prom/prometheus:v2.42.0 image: prom/prometheus:v2.42.0
container_name: prometheus container_name: prometheus
hostname: prometheus hostname: prometheus
restart: unless-stopped
user: root user: root
restart: unless-stopped
depends_on: depends_on:
- cadvisor - cadvisor
command: command:
@ -134,9 +135,9 @@ services:
image: grafana/grafana:9.3.6 image: grafana/grafana:9.3.6
container_name: grafana container_name: grafana
hostname: grafana hostname: grafana
user: root
restart: unless-stopped restart: unless-stopped
env_file: .env env_file: .env
user: root
volumes: volumes:
- ./grafana_data:/var/lib/grafana - ./grafana_data:/var/lib/grafana
expose: expose:
@ -320,8 +321,8 @@ Including pushing information from windows powershell.
image: prom/prometheus:v2.42.0 image: prom/prometheus:v2.42.0
container_name: prometheus container_name: prometheus
hostname: prometheus hostname: prometheus
restart: unless-stopped
user: root user: root
restart: unless-stopped
depends_on: depends_on:
- cadvisor - cadvisor
command: command:
@ -345,9 +346,9 @@ Including pushing information from windows powershell.
image: grafana/grafana:9.3.6 image: grafana/grafana:9.3.6
container_name: grafana container_name: grafana
hostname: grafana hostname: grafana
user: root
restart: unless-stopped restart: unless-stopped
env_file: .env env_file: .env
user: root
volumes: volumes:
- ./grafana_data:/var/lib/grafana - ./grafana_data:/var/lib/grafana
expose: expose:
@ -507,16 +508,27 @@ Including pushing information from windows powershell.
<details> <details>
<summary><h1>Loki</h1></summary> <summary><h1>Loki</h1></summary>
Loki is made by grafana team, who call it Prometheus for logs.<br>
It is a **push** type monitoring, where an agent(**promtail**)
pushes logs on to a Loki instance.
What this example will set out to do is monitor logs of a
[minecraft server.](https://github.com/DoTheEvo/selfhosted-apps-docker/tree/master/minecraft)
Have some dashboards about logs and have an alert when a player joins.
To add to the existing setup:
- New container - `loki` added to the compose file. It stores logs and makes - New container - `loki` added to the compose file. It stores logs and makes
them available for grafana to visualize. them available for grafana to visualize.
- New container - `promtail` added to the compose file. Agent that pushes - New container - `promtail` added to the compose file. Agent that pushes
logs content to loki. logs content to loki. This container needs access to logs to be pushed
and so docker host `/var/lib/docker/containers` directory is bind mounted.
- New file - `loki-docker-config.yml` bind mounted in the loki container.<br> - New file - `loki-docker-config.yml` bind mounted in the loki container.<br>
The file is [all default](https://github.com/grafana/loki/tree/main/cmd/loki), The file is [all default](https://github.com/grafana/loki/tree/main/cmd/loki),
except for alertmanager url.<br> except for alertmanager url.<br>
- New file - `promtail-config.yml` mounted in to promtail container<br> - New file - `promtail-config.yml` mounted in to promtail container<br>
This files defines source of logs. Any such source much be accessible This files defines source of logs. In here a minecraft container is set,
by the promtail container. with some added labels for easier targeting of logs.
<details> <details>
<summary>docker-compose.yml</summary> <summary>docker-compose.yml</summary>
@ -529,8 +541,8 @@ Including pushing information from windows powershell.
image: prom/prometheus:v2.42.0 image: prom/prometheus:v2.42.0
container_name: prometheus container_name: prometheus
hostname: prometheus hostname: prometheus
restart: unless-stopped
user: root user: root
restart: unless-stopped
depends_on: depends_on:
- cadvisor - cadvisor
command: command:
@ -554,9 +566,9 @@ Including pushing information from windows powershell.
image: grafana/grafana:9.3.6 image: grafana/grafana:9.3.6
container_name: grafana container_name: grafana
hostname: grafana hostname: grafana
user: root
restart: unless-stopped restart: unless-stopped
env_file: .env env_file: .env
user: root
volumes: volumes:
- ./grafana_data:/var/lib/grafana - ./grafana_data:/var/lib/grafana
expose: expose:
@ -626,6 +638,7 @@ Including pushing information from windows powershell.
image: grafana/loki:2.7.3 image: grafana/loki:2.7.3
container_name: loki container_name: loki
hostname: loki hostname: loki
user: root
restart: unless-stopped restart: unless-stopped
volumes: volumes:
- ./loki_data:/loki - ./loki_data:/loki
@ -642,8 +655,8 @@ Including pushing information from windows powershell.
image: grafana/promtail:2.7.3 image: grafana/promtail:2.7.3
container_name: promtail container_name: promtail
hostname: promtail hostname: promtail
restart: unless-stopped
user: root user: root
restart: unless-stopped
volumes: volumes:
- /var/log:/var/log:ro - /var/log:/var/log:ro
- /var/lib/docker/containers:/var/lib/docker/containers:ro - /var/lib/docker/containers:/var/lib/docker/containers:ro
@ -724,8 +737,28 @@ Including pushing information from windows powershell.
``` ```
</details> </details>
There was also an option to use loki logging driver to just get docker containers.
But any container re-recreated with that setting set took always long time to down.<br>
Anyway, now with these files in place..
* Loki needs to be added to in grafana as a datasource.<br>
If everything works as it should, there should be no notice, down left side:<br>
`Data source connected and labels found.`
</details>
---
---
<details>
<summary><h1>Caddy monitoring</h1></summary>
</details> </details>
---
---
# Update # Update
Manual image update: Manual image update:

Loading…
Cancel
Save