Files
Obsidian-Main/05. 資料收集/Linux/架站/Grafana-prometheus.md

70 lines
1.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 要準備的檔案
```
├── data
│   ├── grafana
│   │   └── provisioning
│   │   └── datasources
│   │   └── datasources.yaml
│   └── prometheus
│   └── prometheus.yml
├── docker-compose.yml
```
- `docker-compose.yml`
- `data/grafana/provisioning/datasources/datasources.yaml`
- `data/prometheus/prometheus.yml`
# `docker-compose.yml`
```yaml highlight:"5"
services:
grafana:
image: grafana/grafana:latest
restart: always
user: "1000"
ports:
- "8082:3000"
volumes:
- ./data/grafana/data:/var/lib/grafana # data path
- ./data/grafana/grafana.ini:/etc/grafana/grafana.ini
- ./data/grafana/provisioning/dashboards:/etc/grafana/provisioning/dashboards
- ./data/grafana/provisioning/datasources:/etc/grafana/provisioning/datasources
environment:
- GF_INSTALL_PLUGINS=grafana-clock-panel,grafana-simple-json-datasource
prometheus:
image: prom/prometheus:latest
container_name: grafana-prometheus-1
restart: always
command:
- --storage.tsdb.retention.time=7d
- --config.file=/etc/prometheus/prometheus.yml
ports:
- "8083:9090"
volumes:
- ./data/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
node_exporter:
image: prom/node-exporter:latest
restart: always
ports:
- "8084:9100"
```
要注意 `user: "1000"` 這一行,這一行是你的 user ID有可能會變請用 `id -u` 確認一下。
# `datasources.yaml`
```yaml highlight:"6"
# datasources.yaml
apiVersion: 1
datasources:
- name: Prometheus
type: prometheus
url: http://192.168.1.24:8083
access: proxy
```
# `prometheus.yml`