mehr Dateien

This commit is contained in:
christian 2024-05-25 10:31:16 +02:00
parent 843d8bae39
commit 29e485b5b6
12 changed files with 971 additions and 1 deletions

View File

@ -76,7 +76,9 @@ services:
networks:
- internal
- traefik-public
environment:
- PORTS=10010,10011
#der zweite Port ist zum Testen und als Anzeige wie man zukünftig Erweiterungen macht
gitea:
image: gitea/gitea:1.21.11
container_name: gitea
@ -134,3 +136,7 @@ networks:
internal:
name: internal
external: false

View File

@ -0,0 +1,686 @@
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": {
"type": "grafana",
"uid": "-- Grafana --"
},
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"type": "dashboard"
}
]
},
"description": "Docker monitoring with Prometheus and cAdvisor",
"editable": true,
"fiscalYearStartMonth": 0,
"gnetId": 193,
"graphTooltip": 1,
"id": 3,
"links": [],
"liveNow": false,
"panels": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [
{
"options": {
"match": "null",
"result": {
"text": "N/A"
}
},
"type": "special"
}
],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
},
"unit": "none"
},
"overrides": []
},
"gridPos": {
"h": 3,
"w": 8,
"x": 0,
"y": 0
},
"id": 7,
"links": [],
"maxDataPoints": 100,
"options": {
"colorMode": "none",
"graphMode": "none",
"justifyMode": "auto",
"orientation": "horizontal",
"reduceOptions": {
"calcs": [
"mean"
],
"fields": "",
"values": false
},
"textMode": "auto"
},
"pluginVersion": "10.0.2",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "count(container_last_seen{image!=\"\"})",
"intervalFactor": 2,
"legendFormat": "",
"metric": "container_last_seen",
"refId": "A",
"step": 240
}
],
"title": "Running containers",
"transparent": true,
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [
{
"options": {
"match": "null",
"result": {
"text": "N/A"
}
},
"type": "special"
}
],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
},
"unit": "mbytes"
},
"overrides": []
},
"gridPos": {
"h": 3,
"w": 8,
"x": 8,
"y": 0
},
"id": 5,
"links": [],
"maxDataPoints": 100,
"options": {
"colorMode": "none",
"graphMode": "none",
"justifyMode": "auto",
"orientation": "horizontal",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"textMode": "auto"
},
"pluginVersion": "10.0.2",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum(container_memory_usage_bytes{image!=\"\"})/1024/1024",
"intervalFactor": 2,
"legendFormat": "",
"metric": "container_memory_usage_bytes",
"refId": "A",
"step": 240
}
],
"title": "Total Memory Usage",
"transparent": true,
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [
{
"options": {
"match": "null",
"result": {
"text": "N/A"
}
},
"type": "special"
}
],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
},
"unit": "percent"
},
"overrides": []
},
"gridPos": {
"h": 3,
"w": 8,
"x": 16,
"y": 0
},
"id": 6,
"links": [],
"maxDataPoints": 100,
"options": {
"colorMode": "none",
"graphMode": "none",
"justifyMode": "auto",
"orientation": "horizontal",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"textMode": "auto"
},
"pluginVersion": "10.0.2",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum(rate(container_cpu_user_seconds_total{image!=\"\"}[5m]) * 100)",
"intervalFactor": 2,
"legendFormat": "",
"metric": "container_memory_usage_bytes",
"refId": "A",
"step": 240
}
],
"title": "Total CPU Usage",
"transparent": true,
"type": "stat"
},
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"decimals": 2,
"editable": true,
"error": false,
"fill": 1,
"fillGradient": 0,
"grid": {},
"gridPos": {
"h": 7,
"w": 24,
"x": 0,
"y": 3
},
"hiddenSeries": false,
"id": 2,
"legend": {
"alignAsTable": true,
"avg": true,
"current": true,
"max": false,
"min": false,
"rightSide": true,
"show": true,
"total": false,
"values": true
},
"lines": true,
"linewidth": 2,
"links": [],
"nullPointMode": "connected",
"options": {
"alertThreshold": true
},
"percentage": false,
"pluginVersion": "10.0.2",
"pointradius": 5,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "rate(container_cpu_user_seconds_total{image!=\"\"}[5m]) * 100",
"intervalFactor": 2,
"legendFormat": "{{name}}",
"metric": "cpu",
"refId": "A",
"step": 10
}
],
"thresholds": [],
"timeRegions": [],
"title": "CPU Usage",
"tooltip": {
"msResolution": false,
"shared": true,
"sort": 0,
"value_type": "cumulative"
},
"type": "graph",
"xaxis": {
"mode": "time",
"show": true,
"values": []
},
"yaxes": [
{
"format": "percent",
"logBase": 1,
"show": true
},
{
"format": "short",
"logBase": 1,
"show": true
}
],
"yaxis": {
"align": false
}
},
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"decimals": 2,
"editable": true,
"error": false,
"fill": 1,
"fillGradient": 0,
"grid": {},
"gridPos": {
"h": 7,
"w": 24,
"x": 0,
"y": 10
},
"hiddenSeries": false,
"id": 1,
"legend": {
"alignAsTable": true,
"avg": true,
"current": true,
"max": false,
"min": false,
"rightSide": true,
"show": true,
"total": false,
"values": true
},
"lines": true,
"linewidth": 2,
"links": [],
"nullPointMode": "connected",
"options": {
"alertThreshold": true
},
"percentage": false,
"pluginVersion": "10.0.2",
"pointradius": 5,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "container_memory_usage_bytes{image!=\"\"}",
"hide": false,
"intervalFactor": 2,
"legendFormat": "{{name}}",
"metric": "container_memory_usage_bytes",
"refId": "A",
"step": 10
}
],
"thresholds": [],
"timeRegions": [],
"title": "Memory Usage",
"tooltip": {
"msResolution": false,
"shared": true,
"sort": 0,
"value_type": "cumulative"
},
"type": "graph",
"xaxis": {
"mode": "time",
"show": true,
"values": []
},
"yaxes": [
{
"format": "bytes",
"label": "",
"logBase": 1,
"show": true
},
{
"format": "short",
"logBase": 1,
"show": false
}
],
"yaxis": {
"align": false
}
},
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"editable": true,
"error": false,
"fill": 1,
"fillGradient": 0,
"grid": {},
"gridPos": {
"h": 7,
"w": 12,
"x": 0,
"y": 17
},
"hiddenSeries": false,
"id": 3,
"legend": {
"avg": false,
"current": false,
"max": false,
"min": false,
"show": true,
"total": false,
"values": false
},
"lines": true,
"linewidth": 2,
"links": [],
"nullPointMode": "connected",
"options": {
"alertThreshold": true
},
"percentage": false,
"pluginVersion": "10.0.2",
"pointradius": 5,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "irate(container_network_receive_bytes_total{image!=\"\"}[5m])",
"intervalFactor": 2,
"legendFormat": "{{name}}",
"metric": "container_network_receive_bytes_total",
"refId": "A",
"step": 20
}
],
"thresholds": [],
"timeRegions": [],
"title": "Network Rx",
"tooltip": {
"msResolution": false,
"shared": true,
"sort": 0,
"value_type": "cumulative"
},
"type": "graph",
"xaxis": {
"mode": "time",
"show": true,
"values": []
},
"yaxes": [
{
"format": "Bps",
"logBase": 1,
"show": true
},
{
"format": "short",
"logBase": 1,
"show": true
}
],
"yaxis": {
"align": false
}
},
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"editable": true,
"error": false,
"fill": 1,
"fillGradient": 0,
"grid": {},
"gridPos": {
"h": 7,
"w": 12,
"x": 12,
"y": 17
},
"hiddenSeries": false,
"id": 4,
"legend": {
"avg": false,
"current": false,
"max": false,
"min": false,
"show": true,
"total": false,
"values": false
},
"lines": true,
"linewidth": 2,
"links": [],
"nullPointMode": "connected",
"options": {
"alertThreshold": true
},
"percentage": false,
"pluginVersion": "10.0.2",
"pointradius": 5,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "irate(container_network_transmit_bytes_total{image!=\"\"}[5m])",
"intervalFactor": 2,
"legendFormat": "{{name}}",
"refId": "A",
"step": 20
}
],
"thresholds": [],
"timeRegions": [],
"title": "Network Tx",
"tooltip": {
"msResolution": false,
"shared": true,
"sort": 0,
"value_type": "cumulative"
},
"type": "graph",
"xaxis": {
"mode": "time",
"show": true,
"values": []
},
"yaxes": [
{
"format": "Bps",
"logBase": 1,
"show": true
},
{
"format": "short",
"logBase": 1,
"show": true
}
],
"yaxis": {
"align": false
}
}
],
"refresh": "10s",
"schemaVersion": 38,
"style": "dark",
"tags": [
"docker"
],
"templating": {
"list": []
},
"time": {
"from": "now-5m",
"to": "now"
},
"timepicker": {
"refresh_intervals": [
"5s",
"10s",
"30s",
"1m",
"5m",
"15m",
"30m",
"1h",
"2h",
"1d"
],
"time_options": [
"5m",
"15m",
"1h",
"6h",
"12h",
"24h",
"2d",
"7d",
"30d"
]
},
"timezone": "browser",
"title": "Docker Monitoring Test",
"uid": "ee75b6b8-f1c6-4ef1-9d39-fe50cc55a274",
"version": 1,
"weekStart": ""
}

View File

@ -0,0 +1,6 @@
datasources:
- name: prometheus
type: prometheus
url: http://localhost:9090
access: proxy
isDefault: true

View File

@ -0,0 +1,8 @@
apiVersion: 1
providers:
- name: Default # A uniquely identifiable name for the provider
folder: Services # The folder where to place the dashboards
type: file
options:
path: /var/lib/grafana/dashboards/dashboard.json

View File

@ -0,0 +1,59 @@
version: "3"
services:
cadvisor:
container_name: cadvisor
image: gcr.io/cadvisor/cadvisor:latest
network_mode: "host"
ports:
- "9095:9095"
command:
- '-port=9095'
volumes:
- "/:/rootfs"
- "/var/run:/var/run"
- "/sys:/sys"
- "/var/lib/docker/:/var/lib/docker"
- "/dev/disk/:/dev/disk"
privileged: true
devices:
- "/dev/kmsg"
prometheus:
container_name: prometheus
image: prom/prometheus:latest
network_mode: "host"
ports:
- "9091:9090"
volumes:
- "./prometheus.yml:/etc/prometheus/prometheus.yml"
privileged: true
depends_on:
- cadvisor
grafana:
container_name: grafana
image: grafana/grafana:latest
# network_mode: "host"
ports:
- 3000:3000
environment:
- GF_PATHS_PROVISIONING=/etc/grafana/provisioning
- DS_PROMETHEUS=prometheus
volumes:
- "grafana-data:/var/lib/grafana"
- "./datasources.yml:/etc/grafana/provisioning/datasources/datasources.yml"
- "./dashboard.json:/var/lib/grafana/dashboards/dashboard.json"
- "./default.yaml:/etc/grafana/provisioning/dashboards/default.yaml"
privileged: true
depends_on:
- prometheus
networks:
- test
volumes:
grafana-data:
networks:
test:
name: testnetwork

View File

@ -0,0 +1,50 @@
version: "3"
services:
cadvisor:
container_name: cadvisor
image: gcr.io/cadvisor/cadvisor:latest
network_mode: "host"
ports:
- "8090:8080"
volumes:
- "/:/rootfs"
- "/var/run:/var/run"
- "/sys:/sys"
- "/var/lib/docker/:/var/lib/docker"
- "/dev/disk/:/dev/disk"
privileged: true
devices:
- "/dev/kmsg"
prometheus:
container_name: prometheus
image: prom/prometheus:latest
network_mode: "host"
ports:
- "9090:9090"
volumes:
- "./prometheus.yml:/etc/prometheus/prometheus.yml"
privileged: true
depends_on:
- cadvisor
grafana:
container_name: grafana
image: grafana/grafana:latest
network_mode: "host"
ports:
- "8092:3000"
environment:
- GF_PATHS_PROVISIONING=/etc/grafana/provisioning
- DS_PROMETHEUS=prometheus
volumes:
- "grafana-data:/var/lib/grafana"
- "./datasources.yml:/etc/grafana/provisioning/datasources/datasources.yml"
- "./dashboard.json:/var/lib/grafana/dashboards/dashboard.json"
- "./default.yaml:/etc/grafana/provisioning/dashboards/default.yaml"
privileged: true
depends_on:
- prometheus
volumes:
grafana-data:

View File

@ -0,0 +1,14 @@
global:
scrape_interval: 15s #Scrape interval to every 15 seconds.
evaluation_interval: 15s #Evaluate rules every 15 seconds.
scrape_configs:
- job_name: "prometheus"
# metrics_path defaults to '/metrics'
static_configs:
- targets: ["localhost:9090"]
- job_name: "cadvisor"
static_configs:
- targets: ["localhost:9095"]

View File

@ -0,0 +1,75 @@
---
version: '3'
services:
mon_prometheus:
image: prom/prometheus:latest
container_name: mon_prometheus
restart: unless-stopped
volumes:
- /home/dockers/traefik/grafana/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
depends_on:
- mon_node-exporter
- mon_cadvisor
networks:
- private
mon_node-exporter:
image: prom/node-exporter:latest
container_name: mon_node-exporter
restart: unless-stopped
volumes:
- /proc:/host/proc:ro
- /sys:/host/sys:ro
- /:/rootfs:ro
command:
- '--path.procfs=/host/proc'
- '--path.sysfs=/host/sys'
- '--path.rootfs=/rootfs'
- '--collector.filesystem.ignored-mount-points="^(/rootfs|/host|)/(sys|proc|dev|host|etc)($$|/)"'
- '--collector.filesystem.ignored-fs-types="^(sys|proc|auto|cgroup|devpts|ns|au|fuse\.lxc|mqueue)(fs|)$$"'
networks:
- default
mon_cadvisor:
image: gcr.io/cadvisor/cadvisor
container_name: mon_cadvisor
restart: unless-stopped
volumes:
- /:/rootfs:ro
- /var/run:/var/run:rw
- /sys:/sys:ro
- /var/lib/docker/:/var/lib/docker:ro
networks:
- private
mon_grafana:
image: grafana/grafana:latest
container_name: mon_grafana
restart: unless-stopped
volumes:
- /home/dockers/traefik/grafana/grafana-plugins:/var/lib/grafana
user: "1000"
depends_on:
- mon_prometheus
labels:
- traefik.enable=true
- traefik.http.middlewares.moo-redirect-websecure.redirectscheme.scheme=https
- traefik.http.routers.grafana-web.rule=Host(`grafana.herrmann.es`)
- traefik.http.routers.grafana-web.entrypoints=web
- traefik.http.routers.grafana-web.middlewares=moo-redirect-websecure
- traefik.http.routers.grafana-websecure.entrypoints=websecure
- traefik.http.routers.grafana-websecure.rule=Host(`grafana.herrmann.es`)
- traefik.tags= traefik-public
- traefik.docker.network=traefik-public
- traefik.http.routers.grafana-websecure.tls=true
- traefik.http.routers.grafana-websecure.tls.certresolver=myresolver
- traefik.http.services.grafana-global.loadbalancer.server.port=3000
networks:
- traefik-public
- private
networks:
traefik-public:
external: true
private:

View File

@ -0,0 +1,53 @@
{{ define "__subject" }}[{{ .Status | toUpper }}{{ if eq .Status "firing" }}:{{ .Alerts.Firing | len }}{{ if gt (.Alerts.Resolved | len) 0 }}, RESOLVED:{{ .Alerts.Resolved | len }}{{ end }}{{ end }}] {{ .GroupLabels.SortedPairs.Values | join " " }} {{ if gt (len .CommonLabels) (len .GroupLabels) }}({{ with .CommonLabels.Remove .GroupLabels.Names }}{{ .Values | join " " }}{{ end }}){{ end }}{{ end }}
{{ define "__text_values_list" }}{{ if len .Values }}{{ $first := true }}{{ range $refID, $value := .Values -}}
{{ if $first }}{{ $first = false }}{{ else }}, {{ end }}{{ $refID }}={{ $value }}{{ end -}}
{{ else }}[no value]{{ end }}{{ end }}
{{ define "__text_alert_list" }}{{ range . }}
Value: {{ template "__text_values_list" . }}
Labels:
{{ range .Labels.SortedPairs }} - {{ .Name }} = {{ .Value }}
{{ end }}Annotations:
{{ range .Annotations.SortedPairs }} - {{ .Name }} = {{ .Value }}
{{ end }}{{ if gt (len .GeneratorURL) 0 }}Source: {{ .GeneratorURL }}
{{ end }}{{ if gt (len .SilenceURL) 0 }}Silence: {{ .SilenceURL }}
{{ end }}{{ if gt (len .DashboardURL) 0 }}Dashboard: {{ .DashboardURL }}
{{ end }}{{ if gt (len .PanelURL) 0 }}Panel: {{ .PanelURL }}
{{ end }}{{ end }}{{ end }}
{{ define "default.title" }}{{ template "__subject" . }}{{ end }}
{{ define "default.message" }}{{ if gt (len .Alerts.Firing) 0 }}**Firing**
{{ template "__text_alert_list" .Alerts.Firing }}{{ if gt (len .Alerts.Resolved) 0 }}
{{ end }}{{ end }}{{ if gt (len .Alerts.Resolved) 0 }}**Resolved**
{{ template "__text_alert_list" .Alerts.Resolved }}{{ end }}{{ end }}
{{ define "__teams_text_alert_list" }}{{ range . }}
Value: {{ template "__text_values_list" . }}
Labels:
{{ range .Labels.SortedPairs }} - {{ .Name }} = {{ .Value }}
{{ end }}
Annotations:
{{ range .Annotations.SortedPairs }} - {{ .Name }} = {{ .Value }}
{{ end }}
{{ if gt (len .GeneratorURL) 0 }}Source: [{{ .GeneratorURL }}]({{ .GeneratorURL }})
{{ end }}{{ if gt (len .SilenceURL) 0 }}Silence: [{{ .SilenceURL }}]({{ .SilenceURL }})
{{ end }}{{ if gt (len .DashboardURL) 0 }}Dashboard: [{{ .DashboardURL }}]({{ .DashboardURL }})
{{ end }}{{ if gt (len .PanelURL) 0 }}Panel: [{{ .PanelURL }}]({{ .PanelURL }})
{{ end }}
{{ end }}{{ end }}
{{ define "teams.default.message" }}{{ if gt (len .Alerts.Firing) 0 }}**Firing**
{{ template "__teams_text_alert_list" .Alerts.Firing }}{{ if gt (len .Alerts.Resolved) 0 }}
{{ end }}{{ end }}{{ if gt (len .Alerts.Resolved) 0 }}**Resolved**
{{ template "__teams_text_alert_list" .Alerts.Resolved }}{{ end }}{{ end }}

Binary file not shown.

View File

@ -0,0 +1,13 @@
global:
scrape_interval: 15s
evaluation_interval: 15s
rule_files:
scrape_configs:
- job_name: 'node-exporter'
static_configs:
- targets: ['mon_node-exporter:9100']
- job_name: 'cadvisor'
static_configs:
- targets: ['mon_cadvisor:8080']