Compare commits
2 Commits
master
...
weather-st
Author | SHA1 | Date | |
---|---|---|---|
d2ad5c31a8 | |||
addd3f4e52 |
@ -1,7 +0,0 @@
|
|||||||
# 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.
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
|||||||
local.file_match "caddy" {
|
|
||||||
path_targets = [{"__path__" = "/tmp/app-logs/debug.log"}]
|
|
||||||
sync_period = "5s"
|
|
||||||
}
|
|
||||||
|
|
||||||
loki.write "remote_loki" {
|
|
||||||
endpoint {
|
|
||||||
url = "http://10.50.50.x/loki/api/v1/push"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
loki.source.file "local_files" {
|
|
||||||
targets = local.file_match.caddy.targets
|
|
||||||
forward_to = [loki.write.local.loki.reciever]
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
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'
|
|
||||||
alloy:
|
|
||||||
image: grafana/alloy:latest
|
|
||||||
ports:
|
|
||||||
- 12345:12345
|
|
||||||
volumes:
|
|
||||||
- ./alloy-config.alloy:/etc/alloy/config.alloy
|
|
||||||
- ./logs:/tmp/app-logs/
|
|
||||||
command: run --server.http.listen-addr=0.0.0.0:12345 --storage.path=/var/lib/alloy/data /etc/alloy/config.alloy
|
|
@ -1,20 +1,4 @@
|
|||||||
services:
|
services:
|
||||||
# r-proxy
|
|
||||||
caddy:
|
|
||||||
image: caddy:latest
|
|
||||||
restart: unless-stopped
|
|
||||||
ports:
|
|
||||||
# HTTP
|
|
||||||
- 80:80
|
|
||||||
- 443:443
|
|
||||||
- '443:443/udp'
|
|
||||||
# Grafana
|
|
||||||
- 3000:3000
|
|
||||||
# Loki
|
|
||||||
- 3100:3100
|
|
||||||
volumes:
|
|
||||||
- ./Caddyfile:/etc/caddy/Caddyfile
|
|
||||||
|
|
||||||
# Metrics collector
|
# Metrics collector
|
||||||
prometheus:
|
prometheus:
|
||||||
image: prom/prometheus:latest
|
image: prom/prometheus:latest
|
||||||
@ -24,20 +8,9 @@ services:
|
|||||||
- ./prometheus.yaml:/etc/prometheus/prometheus.yml
|
- ./prometheus.yaml:/etc/prometheus/prometheus.yml
|
||||||
# persist data
|
# persist data
|
||||||
- prometheus_storage:/prometheus
|
- prometheus_storage:/prometheus
|
||||||
depends_on:
|
|
||||||
- caddy
|
|
||||||
command: --web.enable-lifecycle --config.file=/etc/prometheus/prometheus.yml
|
command: --web.enable-lifecycle --config.file=/etc/prometheus/prometheus.yml
|
||||||
|
|
||||||
# Logs
|
# log viewer
|
||||||
loki:
|
|
||||||
image: grafana/loki:2.9.2
|
|
||||||
expose:
|
|
||||||
- 3100
|
|
||||||
command: -config.file=/etc/loki/local-config.yaml
|
|
||||||
volumes:
|
|
||||||
- ./loki.yaml:/etc/loki/local-config.yaml
|
|
||||||
|
|
||||||
# Everything viewer
|
|
||||||
grafana:
|
grafana:
|
||||||
image: grafana/grafana:latest
|
image: grafana/grafana:latest
|
||||||
volumes:
|
volumes:
|
||||||
@ -48,8 +21,8 @@ services:
|
|||||||
- GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
|
- GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
|
||||||
- GF_AUTH_DISABLE_LOGIN_FORM=true
|
- GF_AUTH_DISABLE_LOGIN_FORM=true
|
||||||
- GF_FEATURE_TOGGLES_ENABLE=traceqlEditor
|
- GF_FEATURE_TOGGLES_ENABLE=traceqlEditor
|
||||||
expose:
|
ports:
|
||||||
- 3000
|
- 3000:3000
|
||||||
depends_on:
|
depends_on:
|
||||||
- prometheus
|
- prometheus
|
||||||
|
|
@ -1,3 +0,0 @@
|
|||||||
wget https://git.oliveratkinson.net/Oliver/linux-node-visability/raw/branch/master/compose-node.yml
|
|
||||||
sudo ufw allow from 10.50.50.0/24 to any port 9100
|
|
||||||
docker compose -f compose-node.yml up -d
|
|
@ -13,12 +13,3 @@ datasources:
|
|||||||
editable: false
|
editable: false
|
||||||
jsonData:
|
jsonData:
|
||||||
httpMethod: GET
|
httpMethod: GET
|
||||||
- name: Loki
|
|
||||||
type: loki
|
|
||||||
access: proxy
|
|
||||||
orgId: 1
|
|
||||||
url: http://loki:3100
|
|
||||||
basicAuth: false
|
|
||||||
isDefault: false
|
|
||||||
version: 1
|
|
||||||
editable: false
|
|
46
main.py
Normal file
46
main.py
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
import time
|
||||||
|
import board
|
||||||
|
import adafruit_dht
|
||||||
|
from http.server import BaseHTTPRequestHandler, HTTPServer
|
||||||
|
|
||||||
|
sensor = adafruit_dht.DHT22(board.D21)
|
||||||
|
|
||||||
|
hostName = "0.0.0.0"
|
||||||
|
serverPort = 7070
|
||||||
|
|
||||||
|
class MyServer(BaseHTTPRequestHandler):
|
||||||
|
def do_GET(self):
|
||||||
|
try:
|
||||||
|
# Print the values to the serial port
|
||||||
|
temperature_c = sensor.temperature
|
||||||
|
temperature_f = temperature_c * (9 / 5) + 32
|
||||||
|
humidity = sensor.humidity
|
||||||
|
self.send_response(200)
|
||||||
|
self.send_header("Content-type", "text/plain")
|
||||||
|
self.end_headers()
|
||||||
|
self.wfile.write(bytes("# TYPE target_info gauge\n", "utf-8"))
|
||||||
|
self.wfile.write(bytes("humidity{{location=\"beddroom\"}} {}\n".format(humidity), "utf-8"))
|
||||||
|
|
||||||
|
self.wfile.write(bytes("# TYPE temperature gauge\n", "utf-8"))
|
||||||
|
self.wfile.write(bytes("temperature{{location=\"beddroom\"}} {}\n".format(temperature_f), "utf-8"))
|
||||||
|
|
||||||
|
except RuntimeError as error:
|
||||||
|
# Errors happen fairly often, DHT's are hard to read, just keep going
|
||||||
|
self.send_response(500)
|
||||||
|
print(error.args[0])
|
||||||
|
except Exception as error:
|
||||||
|
self.send_response(500)
|
||||||
|
sensor.exit()
|
||||||
|
raise error
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
webServer = HTTPServer((hostName, serverPort), MyServer)
|
||||||
|
print("Server started http://%s:%s" % (hostName, serverPort))
|
||||||
|
|
||||||
|
try:
|
||||||
|
webServer.serve_forever()
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
pass
|
||||||
|
|
||||||
|
webServer.server_close()
|
||||||
|
print("Server stopped.")
|
9
prometheus.yaml
Normal file
9
prometheus.yaml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
global:
|
||||||
|
scrape_interval: 15s
|
||||||
|
query_log_file: /etc/prometheus/query.log
|
||||||
|
|
||||||
|
scrape_configs:
|
||||||
|
- job_name: bedroom
|
||||||
|
static_configs:
|
||||||
|
- targets: ['192.168.8.79:7070']
|
||||||
|
|
@ -1,26 +0,0 @@
|
|||||||
{
|
|
||||||
admin :2019
|
|
||||||
|
|
||||||
servers :3000 {
|
|
||||||
name grafana
|
|
||||||
metrics
|
|
||||||
}
|
|
||||||
|
|
||||||
servers :3001 {
|
|
||||||
name loki
|
|
||||||
metrics
|
|
||||||
}
|
|
||||||
|
|
||||||
log debug {
|
|
||||||
level debug
|
|
||||||
output file /var/log/caddy/debug.log
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
:3000 {
|
|
||||||
reverse_proxy grafana:3000
|
|
||||||
}
|
|
||||||
|
|
||||||
:3100 {
|
|
||||||
reverse_proxy loki:3100
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
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']
|
|
Loading…
x
Reference in New Issue
Block a user