improving config
This commit is contained in:
16
config_test.yaml
Normal file
16
config_test.yaml
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
# Test LogBull configuration
|
||||||
|
logbull:
|
||||||
|
host: "http://192.168.0.252:4005"
|
||||||
|
project_id: "778e67d7-5ec6-4c48-b199-cfbded605557"
|
||||||
|
flush_interval: 2 # seconds
|
||||||
|
|
||||||
|
# Test log file paths to monitor
|
||||||
|
log_files:
|
||||||
|
- "dummy_access.log"
|
||||||
|
- "dummy_error.log"
|
||||||
|
|
||||||
|
# Service settings
|
||||||
|
service:
|
||||||
|
poll_interval: 1 # seconds between log file checks
|
||||||
|
max_lines_per_batch: 10 # maximum lines to process at once
|
||||||
|
log_level: "DEBUG" # DEBUG, INFO, WARNING, ERROR
|
||||||
6
dummy_access.log
Normal file
6
dummy_access.log
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
45.153.34.68 - - [02/Mar/2026:21:22:38 +0000] "GET / HTTP/1.1" 444 0 "-" "Mozilla/5.0"
|
||||||
|
176.65.134.20 - - [02/Mar/2026:21:30:25 +0000] "PROPFIND / HTTP/1.1" 444 0 "http://89.47.50.242:443/" "-"
|
||||||
|
176.65.149.233 - - [02/Mar/2026:21:34:35 +0000] "GET / HTTP/1.1" 444 0 "-" "Mozilla/1.0"
|
||||||
|
20.64.104.237 - - [02/Mar/2026:21:48:03 +0000] "GET /login HTTP/1.1" 444 0 "-" "Mozilla/5.0 zgrab/0.x"
|
||||||
|
79.124.40.174 - - [02/Mar/2026:21:53:05 +0000] "GET /?XDEBUG_SESSION_START=phpstorm HTTP/1.1" 444 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
|
||||||
|
192.168.1.100 - - [02/Mar/2026:23:50:00 +0000] "GET /test HTTP/1.1" 200 1234 "-" "Test Agent"
|
||||||
3
dummy_error.log
Normal file
3
dummy_error.log
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
2026/03/02 04:11:13 [error] 1083281#1083281: *3381930 connect() failed (113: No route to host) while connecting to upstream, client: 185.71.113.95, server: jellyfin.nussnougate.net, request: "POST /Sessions/Playing/Progress HTTP/1.1", upstream: "http://192.168.100.101:8096/Sessions/Playing/Progress", host: "jellyfin.nussnougate.net"
|
||||||
|
2026/03/02 04:11:21 [error] 1083281#1083281: *3383437 connect() failed (113: No route to host) while connecting to upstream, client: 185.143.100.163, server: jellyfin.nussnougate.net, request: "GET / HTTP/1.1", upstream: "http://192.168.100.101:8096/", host: "jellyfin.nussnougate.net"
|
||||||
|
2026/03/02 14:13:56 [error] 1083281#1083281: *3426455 {"ip":"192.253.248.11","server":"jellyfin.nussnougate.net","uri":"/","config":"block","rid":"a3da57ce31e7a5489d0625abe261f6e0","cscore0":"$UWA","score0":8,"zone0":"HEADERS","id0":10000034,"var_name0":"user-agent"}, client: 192.253.248.11, server: jellyfin.nussnougate.net, request: "GET / HTTP/1.1", host: "jellyfin.nussnougate.net", referrer: "http://jellyfin.nussnougate.net//.git/HEAD"
|
||||||
11
main.py
11
main.py
@@ -1,6 +1,7 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
import time
|
import time
|
||||||
import logging
|
import logging
|
||||||
import yaml
|
import yaml
|
||||||
@@ -234,8 +235,16 @@ class LogFileHandler(FileSystemEventHandler):
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
try:
|
try:
|
||||||
|
# Parse command line arguments
|
||||||
|
config_path = "config.yaml"
|
||||||
|
if len(sys.argv) > 1:
|
||||||
|
if sys.argv[1] == '--config' and len(sys.argv) > 2:
|
||||||
|
config_path = sys.argv[2]
|
||||||
|
elif sys.argv[1].endswith('.yaml') or sys.argv[1].endswith('.yml'):
|
||||||
|
config_path = sys.argv[1]
|
||||||
|
|
||||||
# Load configuration
|
# Load configuration
|
||||||
config = Config()
|
config = Config(config_path)
|
||||||
|
|
||||||
# Set log level from config
|
# Set log level from config
|
||||||
service_config = config.get_service_config()
|
service_config = config.get_service_config()
|
||||||
|
|||||||
35
run_test.sh
Executable file
35
run_test.sh
Executable file
@@ -0,0 +1,35 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo "Starting proxy-to-logbull test with dummy log files..."
|
||||||
|
echo "====================================================="
|
||||||
|
|
||||||
|
# Create dummy log files if they don't exist
|
||||||
|
if [ ! -f "dummy_access.log" ]; then
|
||||||
|
echo "Creating dummy access log..."
|
||||||
|
cat > dummy_access.log << 'EOF'
|
||||||
|
45.153.34.68 - - [02/Mar/2026:21:22:38 +0000] "GET / HTTP/1.1" 444 0 "-" "Mozilla/5.0"
|
||||||
|
176.65.134.20 - - [02/Mar/2026:21:30:25 +0000] "PROPFIND / HTTP/1.1" 444 0 "http://89.47.50.242:443/" "-"
|
||||||
|
176.65.149.233 - - [02/Mar/2026:21:34:35 +0000] "GET / HTTP/1.1" 444 0 "-" "Mozilla/1.0"
|
||||||
|
20.64.104.237 - - [02/Mar/2026:21:48:03 +0000] "GET /login HTTP/1.1" 444 0 "-" "Mozilla/5.0 zgrab/0.x"
|
||||||
|
79.124.40.174 - - [02/Mar/2026:21:53:05 +0000] "GET /?XDEBUG_SESSION_START=phpstorm HTTP/1.1" 444 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -f "dummy_error.log" ]; then
|
||||||
|
echo "Creating dummy error log..."
|
||||||
|
cat > dummy_error.log << 'EOF'
|
||||||
|
2026/03/02 04:11:13 [error] 1083281#1083281: *3381930 connect() failed (113: No route to host) while connecting to upstream, client: 185.71.113.95, server: jellyfin.nussnougate.net, request: "POST /Sessions/Playing/Progress HTTP/1.1", upstream: "http://192.168.100.101:8096/Sessions/Playing/Progress", host: "jellyfin.nussnougate.net"
|
||||||
|
2026/03/02 04:11:21 [error] 1083281#1083281: *3383437 connect() failed (113: No route to host) while connecting to upstream, client: 185.143.100.163, server: jellyfin.nussnougate.net, request: "GET / HTTP/1.1", upstream: "http://192.168.100.101:8096/", host: "jellyfin.nussnougate.net"
|
||||||
|
2026/03/02 14:13:56 [error] 1083281#1083281: *3426455 {"ip":"192.253.248.11","server":"jellyfin.nussnougate.net","uri":"/","config":"block","rid":"a3da57ce31e7a5489d0625abe261f6e0","cscore0":"$UWA","score0":8,"zone0":"HEADERS","id0":10000034,"var_name0":"user-agent"}, client: 192.253.248.11, server: jellyfin.nussnougate.net, request: "GET / HTTP/1.1", host: "jellyfin.nussnougate.net", referrer: "http://jellyfin.nussnougate.net//.git/HEAD"
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Run the service with test configuration for 10 seconds
|
||||||
|
echo "Running proxy-to-logbull with test configuration for 10 seconds..."
|
||||||
|
echo "Press Ctrl+C to stop early"
|
||||||
|
|
||||||
|
timeout 10s uv run main.py config_test.yaml
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "Test completed! The logs should now be visible in Logbull."
|
||||||
|
echo "You can check the dummy log files: dummy_access.log and dummy_error.log"
|
||||||
Reference in New Issue
Block a user