add convert caddy logs to gource script
This commit is contained in:
parent
c1a9c7b724
commit
3bb7af4758
1 changed files with 24 additions and 0 deletions
24
convert_caddy_logs_to_gource.sh
Executable file
24
convert_caddy_logs_to_gource.sh
Executable file
|
@ -0,0 +1,24 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Pfad zur Caddy-Logdatei
|
||||||
|
CADDY_LOG_FILE="$1"
|
||||||
|
|
||||||
|
# Überprüfen, ob die Logdatei existiert
|
||||||
|
if [ ! -f "$CADDY_LOG_FILE" ]; then
|
||||||
|
echo "Die Datei $CADDY_LOG_FILE existiert nicht."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Konvertierung der Logs ins Gource-Format mit Farben für HTTP-Statuscodes
|
||||||
|
echo "Konvertiere Caddy-Logs in Gource-kompatibles Format..."
|
||||||
|
jq -r '
|
||||||
|
.[] |
|
||||||
|
select(.msg.request.remote_ip and .msg.request.host and .msg.request.uri and .timestamp and .msg.status) |
|
||||||
|
"\(.timestamp)|\(.msg.request.remote_ip)|A|\(.msg.request.host)\(.msg.request.uri)|\(
|
||||||
|
if .msg.status >= 200 and .msg.status < 300 then "00FF00" # Grün für 2xx (Erfolg)
|
||||||
|
elif .msg.status >= 300 and .msg.status < 400 then "FFFF00" # Gelb für 3xx (Weiterleitung)
|
||||||
|
elif .msg.status >= 400 and .msg.status < 500 then "FF4500" # Orange für 4xx (Clientfehler)
|
||||||
|
elif .msg.status >= 500 then "FF0000" # Rot für 5xx (Serverfehler)
|
||||||
|
else "FFFFFF" # Weiß für unbekannte Statuscodes
|
||||||
|
end)"
|
||||||
|
' "$CADDY_LOG_FILE" | gource --realtime --log-format custom -
|
Loading…
Add table
Reference in a new issue