Merge pull request 'feat: enable request-level logging for bandwidth/traffic incident tracing' (#37) from emily/nixos:feat/emily-incident-logging into main
Reviewed-on: #37
This commit was merged in pull request #37.
This commit is contained in:
@@ -101,6 +101,19 @@
|
|||||||
# Enable the OpenSSH daemon for remote control
|
# Enable the OpenSSH daemon for remote control
|
||||||
services = {
|
services = {
|
||||||
locate.enable = true;
|
locate.enable = true;
|
||||||
|
|
||||||
|
# Defensive rate-limit: cap any single misbehaving service's journal
|
||||||
|
# output fleet-wide. Discovered live on kuma (uptime-kuma logging a
|
||||||
|
# Prometheus-label validation error on every monitor beat, ~100k
|
||||||
|
# lines/hour) that a runaway logger can itself become the obstacle to
|
||||||
|
# incident investigation — journalctl becomes slow/unresponsive and
|
||||||
|
# disk fills — on top of drowning out genuinely useful log signal.
|
||||||
|
# This doesn't fix a specific app's bug, but bounds the blast radius.
|
||||||
|
journald.extraConfig = ''
|
||||||
|
RateLimitIntervalSec=30s
|
||||||
|
RateLimitBurst=2000
|
||||||
|
'';
|
||||||
|
|
||||||
niks3-auto-upload = {
|
niks3-auto-upload = {
|
||||||
enable = config.greg.nix.cache;
|
enable = config.greg.nix.cache;
|
||||||
authTokenFile = config.age.secrets.niks3-api-token.path;
|
authTokenFile = config.age.secrets.niks3-api-token.path;
|
||||||
|
|||||||
@@ -49,6 +49,14 @@ in
|
|||||||
pkgs'.upgrade-pg-cluster
|
pkgs'.upgrade-pg-cluster
|
||||||
];
|
];
|
||||||
|
|
||||||
|
# Historical per-interface bandwidth tracking (5-min granularity, kept for
|
||||||
|
# months). This is what's actually missing when diagnosing "traffic was
|
||||||
|
# high for the past several hours" reports after the fact — journalctl
|
||||||
|
# timestamps only tell you what else was happening, not the traffic curve
|
||||||
|
# itself. `vnstat -h`/`vnstat --json h` gives an immediate confirm/deny of
|
||||||
|
# a reported window without waiting on live sampling.
|
||||||
|
services.vnstat.enable = true;
|
||||||
|
|
||||||
greg = {
|
greg = {
|
||||||
backup.jobs = {
|
backup.jobs = {
|
||||||
nextcloud-bkup = {
|
nextcloud-bkup = {
|
||||||
@@ -164,6 +172,7 @@ in
|
|||||||
log /dev/log local0
|
log /dev/log local0
|
||||||
|
|
||||||
defaults
|
defaults
|
||||||
|
log global
|
||||||
timeout connect 500s
|
timeout connect 500s
|
||||||
timeout client 500s
|
timeout client 500s
|
||||||
timeout server 1h
|
timeout server 1h
|
||||||
@@ -176,6 +185,12 @@ in
|
|||||||
server git-jeremiah jeremiah.thehellings.lan:32222
|
server git-jeremiah jeremiah.thehellings.lan:32222
|
||||||
server git-zeke zeke.thehellings.lan:32222
|
server git-zeke zeke.thehellings.lan:32222
|
||||||
|
|
||||||
|
listen stats
|
||||||
|
bind 127.0.0.1:8404
|
||||||
|
stats enable
|
||||||
|
stats uri /
|
||||||
|
stats refresh 10s
|
||||||
|
|
||||||
frontend https
|
frontend https
|
||||||
bind *:80
|
bind *:80
|
||||||
bind *:443 ssl crt ${config.security.acme.certs."thehellings.com".directory}/full.pem
|
bind *:443 ssl crt ${config.security.acme.certs."thehellings.com".directory}/full.pem
|
||||||
@@ -187,8 +202,8 @@ in
|
|||||||
|
|
||||||
option http-server-close
|
option http-server-close
|
||||||
option http-keep-alive
|
option http-keep-alive
|
||||||
|
option httplog
|
||||||
|
|
||||||
#option httplog
|
|
||||||
#declare capture response len 80
|
#declare capture response len 80
|
||||||
#http-response capture res.hdr(Location) id 0
|
#http-response capture res.hdr(Location) id 0
|
||||||
|
|
||||||
@@ -300,13 +315,23 @@ in
|
|||||||
};
|
};
|
||||||
|
|
||||||
# Move to :8080 so that we can run haproxy as the primary HTTP service
|
# Move to :8080 so that we can run haproxy as the primary HTTP service
|
||||||
nginx.virtualHosts."${config.services.nextcloud.hostName}".listen = [
|
nginx = {
|
||||||
|
virtualHosts."${config.services.nextcloud.hostName}".listen = [
|
||||||
{
|
{
|
||||||
addr = "127.0.0.1";
|
addr = "127.0.0.1";
|
||||||
port = nextcloudPort;
|
port = nextcloudPort;
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
# Route nginx access logs through syslog/journald (rather than only to
|
||||||
|
# /var/log/nginx/access.log, which the read-only monitoring account
|
||||||
|
# can't read) so `journalctl -t nginx-access` gives visibility into
|
||||||
|
# Nextcloud request traffic during bandwidth investigations.
|
||||||
|
appendHttpConfig = ''
|
||||||
|
access_log syslog:server=unix:/dev/log,tag=nginx-access combined;
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
openssh.settings.PasswordAuthentication = false;
|
openssh.settings.PasswordAuthentication = false;
|
||||||
|
|
||||||
postgresql = {
|
postgresql = {
|
||||||
|
|||||||
@@ -10,6 +10,16 @@ spec:
|
|||||||
- "--api.dashboard=true"
|
- "--api.dashboard=true"
|
||||||
- "--api.insecure=true"
|
- "--api.insecure=true"
|
||||||
- "--log.level=DEBUG"
|
- "--log.level=DEBUG"
|
||||||
|
# Access logging: gives per-request visibility (client IP, host,
|
||||||
|
# path, bytes, duration) for every ingress route Traefik terminates
|
||||||
|
# (git.k3s.thehellings.lan, matrix.k3s.thehellings.lan, immich, etc).
|
||||||
|
# This is the layer HAProxy on linode forwards :80 traffic to, so
|
||||||
|
# having request-level logs here is essential for tracing bandwidth
|
||||||
|
# spikes back to a specific host/path/client rather than just a
|
||||||
|
# backend-level byte count.
|
||||||
|
- "--accesslog=true"
|
||||||
|
- "--accesslog.format=json"
|
||||||
|
- "--accesslog.fields.headers.defaultmode=keep"
|
||||||
ports:
|
ports:
|
||||||
postgres:
|
postgres:
|
||||||
expose:
|
expose:
|
||||||
@@ -20,3 +30,4 @@ spec:
|
|||||||
traefik:
|
traefik:
|
||||||
expose:
|
expose:
|
||||||
default: true
|
default: true
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user