commit 65c38391855f4495a5121f0874f56ea7593245d4 Author: oliver Date: Sat Oct 5 18:20:25 2024 +0000 init diff --git a/Caddyfile b/Caddyfile new file mode 100644 index 0000000..2bd2f52 --- /dev/null +++ b/Caddyfile @@ -0,0 +1,23 @@ +{ + admin :2019 + + servers :80 { + name static_site + metrics + } + + servers :3000 { + name grafana + metrics + } +} + +:80 { + root * /path/to/html + file_server +} + +:3000 { + reverse_proxy grafana:3000 +} + diff --git a/README.md b/README.md new file mode 100644 index 0000000..d843c77 --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +# Host visability +I would recommend using [this dashboard](https://grafana.com/grafana/dashboards/1860-node-exporter-full/). + +Use `docker compose -f node.yml up` on the devices you are monitoring + +Use `docker compose up` for the server that's collecting all the logs. + diff --git a/compose-node.yml b/compose-node.yml new file mode 100644 index 0000000..fb79024 --- /dev/null +++ b/compose-node.yml @@ -0,0 +1,12 @@ +services: + # monitor the host + node_exporter: + image: quay.io/prometheus/node-exporter:latest + command: + - '--path.rootfs=/host' + network_mode: host + # uses port 9100 + pid: host + restart: unless-stopped + volumes: + - '/:/host:ro' diff --git a/compose-server.yml b/compose-server.yml new file mode 100644 index 0000000..8d2a960 --- /dev/null +++ b/compose-server.yml @@ -0,0 +1,35 @@ +services: + # r-proxy + caddy: + image: caddy:latest + restart: unless-stopped + ports: + - 80:80 + - 443:443 + - '443:443/udp' + - 3000:3000 + volumes: + - ./Caddyfile:/etc/caddy/Caddyfile + + # metrics collector + prometheus: + image: prom/prometheus:latest + expose: + - 9090 + volumes: + - ./prometheus.yaml:/etc/prometheus/prometheus.yml + depends_on: + - caddy + + # log viewer + grafana: + image: grafana/grafana:latest + volumes: + - ./grafana.yaml:/etc/grafana/provisioning/datasources/datasources.yaml + environment: + - GF_AUTH_ANONYMOUS_ENABLED=true + - GF_AUTH_ANONYMOUS_ORG_ROLE=Admin + - GF_AUTH_DISABLE_LOGIN_FORM=true + - GF_FEATURE_TOGGLES_ENABLE=traceqlEditor + depends_on: + - prometheus diff --git a/grafana.yaml b/grafana.yaml new file mode 100644 index 0000000..8073556 --- /dev/null +++ b/grafana.yaml @@ -0,0 +1,15 @@ +apiVersion: 1 + +datasources: +- name: Prometheus + type: prometheus + uid: prometheus + access: proxy + orgId: 1 + url: http://prometheus:9090 + basicAuth: false + isDefault: true + version: 1 + editable: false + jsonData: + httpMethod: GET diff --git a/prometheus.yaml b/prometheus.yaml new file mode 100644 index 0000000..b1ad982 --- /dev/null +++ b/prometheus.yaml @@ -0,0 +1,15 @@ +global: + scrape_interval: 15s + query_log_file: /etc/prometheus/query.log + +scrape_configs: + - job_name: caddy + static_configs: + - targets: ['caddy:2019'] + - job_name: node + static_configs: + # put a list of all the nodes you are monitoring + - targets: ['10.0.0.92:9100'] + - job_name: prometheus + static_configs: + - targets: ['localhost:9090']