Compare commits

...

7 Commits

13 changed files with 26748 additions and 6 deletions

View File

@ -1,3 +1,8 @@
############# Grafana #############
GRAFANA_DOMAIN=
GRAFANA_CRT=
GRAFANA_KEY=
############# Gitea #############
GITEA_DOMAIN=
GITEA_CRT=

View File

@ -1,5 +1,28 @@
{
admin off
metrics {
per_host
}
}
:2019 {
metrics
}
############## grafana ##############
{$GRAFANA_DOMAIN} {
tls /etc/ssl/custom/{$GRAFANA_CRT} /etc/ssl/custom/{$GRAFANA_KEY}
request_body {
max_size 2048MB
}
reverse_proxy http://grafana:3000 {
header_up X-Real-IP {http.request.header.Cf-Connecting-Ip}
header_up X-Forwarded-For {http.request.header.Cf-Connecting-Ip}
header_up X-Country-Code {http.request.header.Cf-Ipcountry}
header_up -CF-*
}
}
############## gitea ##############

View File

@ -1,3 +1,9 @@
networks:
caddy:
name: caddy
driver: bridge
external: true
services:
caddy:
image: caddy:2.9.1
@ -17,9 +23,3 @@ services:
- ./data/config:/config
env_file:
- ./.env
networks:
caddy:
name: caddy
driver: bridge
external: true

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,774 @@
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": {
"type": "datasource",
"uid": "grafana"
},
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"type": "dashboard"
}
]
},
"description": "Simple exporter for cadvisor only",
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 0,
"id": 4,
"links": [],
"panels": [
{
"collapsed": false,
"gridPos": {
"h": 1,
"w": 24,
"x": 0,
"y": 0
},
"id": 8,
"panels": [],
"title": "CPU",
"type": "row"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheusdatasource"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisBorderShow": false,
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"barWidthFactor": 0.6,
"drawStyle": "line",
"fillOpacity": 10,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"insertNulls": false,
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "never",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "normal"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green"
},
{
"color": "red",
"value": 80
}
]
},
"unit": "percent"
},
"overrides": []
},
"gridPos": {
"h": 7,
"w": 24,
"x": 0,
"y": 1
},
"id": 15,
"options": {
"alertThreshold": true,
"legend": {
"calcs": [
"mean",
"max"
],
"displayMode": "table",
"placement": "right",
"showLegend": true
},
"tooltip": {
"hideZeros": false,
"mode": "multi",
"sort": "none"
}
},
"pluginVersion": "11.6.0",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheusdatasource"
},
"expr": "sum(rate(container_cpu_usage_seconds_total{instance=~\"$host\",name=~\"$container\",name=~\".+\"}[5m])) by (name) *100",
"hide": false,
"interval": "",
"legendFormat": "{{name}}",
"refId": "A"
}
],
"title": "CPU Usage",
"type": "timeseries"
},
{
"collapsed": false,
"gridPos": {
"h": 1,
"w": 24,
"x": 0,
"y": 8
},
"id": 11,
"panels": [],
"title": "Memory",
"type": "row"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheusdatasource"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisBorderShow": false,
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"barWidthFactor": 0.6,
"drawStyle": "line",
"fillOpacity": 10,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"insertNulls": false,
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "never",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "normal"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green"
},
{
"color": "red",
"value": 80
}
]
},
"unit": "bytes"
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 9
},
"id": 9,
"options": {
"alertThreshold": true,
"legend": {
"calcs": [
"mean",
"max"
],
"displayMode": "table",
"placement": "right",
"showLegend": true
},
"tooltip": {
"hideZeros": false,
"mode": "multi",
"sort": "none"
}
},
"pluginVersion": "11.6.0",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheusdatasource"
},
"expr": "sum(container_memory_rss{instance=~\"$host\",name=~\"$container\",name=~\".+\"}) by (name)",
"hide": false,
"interval": "",
"legendFormat": "{{name}}",
"refId": "A"
}
],
"title": "Memory Usage",
"type": "timeseries"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheusdatasource"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisBorderShow": false,
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"barWidthFactor": 0.6,
"drawStyle": "line",
"fillOpacity": 10,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"insertNulls": false,
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "never",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "normal"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green"
},
{
"color": "red",
"value": 80
}
]
},
"unit": "bytes"
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 9
},
"id": 14,
"options": {
"alertThreshold": true,
"legend": {
"calcs": [
"mean",
"max"
],
"displayMode": "table",
"placement": "right",
"showLegend": true
},
"tooltip": {
"hideZeros": false,
"mode": "multi",
"sort": "none"
}
},
"pluginVersion": "11.6.0",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheusdatasource"
},
"expr": "sum(container_memory_cache{instance=~\"$host\",name=~\"$container\",name=~\".+\"}) by (name)",
"hide": false,
"interval": "",
"legendFormat": "{{name}}",
"refId": "A"
}
],
"title": "Memory Cached",
"type": "timeseries"
},
{
"collapsed": false,
"gridPos": {
"h": 1,
"w": 24,
"x": 0,
"y": 17
},
"id": 2,
"panels": [],
"title": "Network",
"type": "row"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheusdatasource"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisBorderShow": false,
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"barWidthFactor": 0.6,
"drawStyle": "line",
"fillOpacity": 10,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"insertNulls": false,
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "never",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green"
},
{
"color": "red",
"value": 80
}
]
},
"unit": "Bps"
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 18
},
"id": 4,
"options": {
"alertThreshold": true,
"legend": {
"calcs": [
"mean",
"max"
],
"displayMode": "table",
"placement": "right",
"showLegend": true
},
"tooltip": {
"hideZeros": false,
"mode": "multi",
"sort": "none"
}
},
"pluginVersion": "11.6.0",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheusdatasource"
},
"expr": "sum(rate(container_network_receive_bytes_total{instance=~\"$host\",name=~\"$container\",name=~\".+\"}[5m])) by (name)",
"hide": false,
"interval": "",
"legendFormat": "{{name}}",
"refId": "A"
}
],
"title": "Received Network Traffic",
"type": "timeseries"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheusdatasource"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisBorderShow": false,
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"barWidthFactor": 0.6,
"drawStyle": "line",
"fillOpacity": 10,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"insertNulls": false,
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "never",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green"
},
{
"color": "red",
"value": 80
}
]
},
"unit": "Bps"
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 18
},
"id": 6,
"options": {
"alertThreshold": true,
"legend": {
"calcs": [
"mean",
"max"
],
"displayMode": "table",
"placement": "right",
"showLegend": true
},
"tooltip": {
"hideZeros": false,
"mode": "multi",
"sort": "none"
}
},
"pluginVersion": "11.6.0",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheusdatasource"
},
"expr": "sum(rate(container_network_transmit_bytes_total{instance=~\"$host\",name=~\"$container\",name=~\".+\"}[5m])) by (name)",
"interval": "",
"legendFormat": "{{name}}",
"refId": "A"
}
],
"title": "Sent Network Traffic",
"type": "timeseries"
},
{
"collapsed": false,
"gridPos": {
"h": 1,
"w": 24,
"x": 0,
"y": 26
},
"id": 19,
"panels": [],
"title": "Misc",
"type": "row"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheusdatasource"
},
"fieldConfig": {
"defaults": {
"custom": {
"filterable": false
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green"
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": [
{
"matcher": {
"id": "byName",
"options": "id"
},
"properties": [
{
"id": "custom.width",
"value": 260
}
]
},
{
"matcher": {
"id": "byName",
"options": "Running"
},
"properties": [
{
"id": "unit",
"value": "d"
},
{
"id": "decimals",
"value": 1
},
{
"id": "custom.cellOptions",
"value": {
"type": "color-text"
}
},
{
"id": "color",
"value": {
"fixedColor": "dark-green",
"mode": "fixed"
}
}
]
}
]
},
"gridPos": {
"h": 10,
"w": 24,
"x": 0,
"y": 27
},
"id": 17,
"options": {
"showHeader": true,
"sortBy": []
},
"pluginVersion": "7.4.5",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheusdatasource"
},
"expr": "(time() - container_start_time_seconds{instance=~\"$host\",name=~\"$container\",name=~\".+\"})/86400",
"format": "table",
"instant": true,
"interval": "",
"legendFormat": "{{name}}",
"refId": "A"
}
],
"title": "Containers Info",
"transformations": [
{
"id": "filterFieldsByName",
"options": {
"include": {
"names": [
"container_label_com_docker_compose_project",
"container_label_com_docker_compose_project_working_dir",
"image",
"instance",
"name",
"Value",
"container_label_com_docker_compose_service"
]
}
}
},
{
"id": "organize",
"options": {
"excludeByName": {},
"indexByName": {},
"renameByName": {
"Value": "Running",
"container_label_com_docker_compose_project": "Label",
"container_label_com_docker_compose_project_working_dir": "Working dir",
"container_label_com_docker_compose_service": "Service",
"image": "Registry Image",
"instance": "Instance",
"name": "Name"
}
}
}
],
"type": "table"
}
],
"preload": false,
"refresh": "",
"schemaVersion": 41,
"tags": [
"cadvisor",
"docker"
],
"templating": {
"list": [
{
"allValue": ".*",
"current": {
"text": "All",
"value": "$__all"
},
"datasource": "prometheusdatasource",
"definition": "label_values({__name__=~\"container.*\"},instance)",
"includeAll": true,
"label": "Host",
"name": "host",
"options": [],
"query": {
"query": "label_values({__name__=~\"container.*\"},instance)",
"refId": "Prometheus-host-Variable-Query"
},
"refresh": 1,
"regex": "",
"sort": 5,
"type": "query"
},
{
"allValue": ".*",
"current": {
"text": "All",
"value": "$__all"
},
"datasource": "prometheusdatasource",
"definition": "label_values({__name__=~\"container.*\", instance=~\"$host\"},name)",
"includeAll": true,
"label": "Container",
"name": "container",
"options": [],
"query": {
"query": "label_values({__name__=~\"container.*\", instance=~\"$host\"},name)",
"refId": "Prometheus-container-Variable-Query"
},
"refresh": 1,
"regex": "",
"type": "query"
}
]
},
"time": {
"from": "now-6h",
"to": "now"
},
"timepicker": {},
"timezone": "",
"title": "Cadvisor exporter",
"uid": "pMEd7m0Mz",
"version": 1
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,27 @@
apiVersion: 1
providers:
# Unique name for the provider
- name: 'general'
# Organization ID. 1 usually corresponds to the default 'Main Org.'
orgId: 1
# Optional: Assign dashboards to a specific folder in Grafana UI
folder: ''
# Provider type: 'file' means loading from filesystem
type: file
# Optional: Prevents deletion of dashboards from Grafana UI
# (they will reappear on restart if deleted)
disableDeletion: false
# Optional: Allow users to edit dashboards in the Grafana UI.
# Changes will be overwritten on restart unless you save them elsewhere.
editable: true
updateIntervalSeconds: 10
allowUiUpdates: true
# Options specific to the 'file' type provider
options:
# Path inside the container where Grafana should look for dashboard JSON files.
# This MUST match the target path of your dashboard JSON volume mount below.
path: /var/lib/grafana/dashboards
# Optional: Set to true to automatically update dashboards based on file changes
# without restarting Grafana (requires polling).
# updateIntervalSeconds: 10

View File

@ -0,0 +1,9 @@
apiVersion: 1
datasources:
- name: Prometheus
uid: prometheusdatasource
type: prometheus
access: proxy
url: http://prometheus:9090
isDefault: true

View File

@ -0,0 +1,25 @@
networks:
grafana:
name: grafana
driver: bridge
external: true
caddy:
name: caddy
driver: bridge
external: true
services:
grafana:
image: grafana/grafana-enterprise:11.6.0
container_name: grafana
networks:
- grafana
- caddy
volumes:
- grafana-data:/var/lib/grafana
- ./data/grafana/dashboards:/var/lib/grafana/dashboards
- ./data/provisioning/dashboard.yaml:/etc/grafana/provisioning/dashboards/dashboard.yaml
- ./data/provisioning/datasource.yaml:/etc/grafana/provisioning/datasources/datasource.yaml
volumes:
grafana-data:

57
main.sh
View File

@ -63,11 +63,41 @@ generate_env_files() {
cp --update=none ./blinko/.env.example ./blinko/.env
cp --update=none ./caddy/Caddyfile.private.example ./caddy/Caddyfile.private
# cp --update=none ./slash/.env.example ./slash/.env
# cp --update=none ./grafana/.env.example ./grafana/.env
# cp --update=none ./prometheus/.env.example ./prometheus/.env
print_success ".env files generated."
}
start_services() {
docker network create caddy 2>/dev/null
docker network create grafana 2>/dev/null
echo "Starting prometheus..."
$DOCKER_COMPOSE_COMMAND -f ./prometheus/docker-compose.yml up -d
if [ $? -eq 0 ]; then
print_success "Prometheus started successfully."
else
print_error "failed to start Prometheus!"
exit 1
fi
echo "Starting Grafana..."
$DOCKER_COMPOSE_COMMAND -f ./grafana/docker-compose.yml up -d
if [ $? -eq 0 ]; then
print_success "Grafana started successfully."
else
print_error "failed to start Grafana!"
exit 1
fi
echo "Starting Gitea..."
$DOCKER_COMPOSE_COMMAND -f ./gitea/docker-compose.yml up -d
if [ $? -eq 0 ]; then
print_success "Gitea started successfully."
else
print_error "failed to start Gitea!"
exit 1
fi
echo "Starting gitea..."
$DOCKER_COMPOSE_COMMAND -f ./gitea/docker-compose.yml up -d
@ -143,6 +173,33 @@ start_services() {
}
stop_services() {
echo "Stopping grafana..."
$DOCKER_COMPOSE_COMMAND -f ./grafana/docker-compose.yml down
if [ $? -eq 0 ]; then
print_success "Grafana stopped successfully."
else
print_error "failed to stop Grafana!"
exit 1
fi
echo "Stopping prometheus..."
$DOCKER_COMPOSE_COMMAND -f ./prometheus/docker-compose.yml down
if [ $? -eq 0 ]; then
print_success "Prometheus stopped successfully."
else
print_error "failed to stop Prometheus!"
exit 1
fi
echo "Stopping gitea..."
$DOCKER_COMPOSE_COMMAND -f ./gitea/docker-compose.yml down
if [ $? -eq 0 ]; then
print_success "Gitea stopped successfully."
else
print_error "failed to stop Gitea!"
exit 1
fi
echo "Stopping gitea..."
$DOCKER_COMPOSE_COMMAND -f ./gitea/docker-compose.yml down
if [ $? -eq 0 ]; then

2
prometheus/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/data/*
!/data/config

View File

@ -0,0 +1,18 @@
global:
scrape_interval: 10s
scrape_configs:
- job_name: "node_exporter"
scrape_interval: 2s
static_configs:
- targets: ["node_exporter:9100"]
- job_name: "cadvisor"
scrape_interval: 2s
static_configs:
- targets: ["cadvisor:8080"]
- job_name: caddy
scrape_interval: 2s
static_configs:
- targets: ["caddy:2019"]

View File

@ -0,0 +1,53 @@
networks:
prometheus:
external: false
grafana:
name: grafana
driver: bridge
external: true
caddy:
name: caddy
driver: bridge
external: true
services:
prometheus:
image: prom/prometheus:v3.2.1
container_name: prometheus
networks:
- prometheus
- grafana
- caddy
command: "--config.file=/etc/prometheus/prometheus.yaml --storage.tsdb.retention.time=10d --storage.tsdb.retention.size=5GB"
volumes:
- ./data/config/prometheus.yaml:/etc/prometheus/prometheus.yaml:ro
- prometheus-data:/prometheus
node_exporter:
image: quay.io/prometheus/node-exporter:v1.9.1
container_name: node_exporter
networks:
- prometheus
command:
- "--path.rootfs=/host"
pid: host
volumes:
- "/:/host:ro,rslave"
cadvisor:
image: gcr.io/cadvisor/cadvisor:v0.49.1
container_name: cadvisor
networks:
- prometheus
volumes:
- "/:/rootfs:ro"
- "/var/run:/var/run:ro"
- "/sys:/sys:ro"
- "/var/lib/docker/:/var/lib/docker:ro"
- "/dev/disk/:/dev/disk:ro"
privileged: true
devices:
- "/dev/kmsg:/dev/kmsg"
volumes:
prometheus-data: