Logging Module (Graylog)
Complete guide to deploying and managing Graylog centralized logging with search, analysis, and alerting capabilities.
🏗️ Overview
Section titled “🏗️ Overview”The Graylog module provides enterprise-grade centralized logging with powerful search, analysis, and alerting capabilities. It enables comprehensive log management, real-time monitoring, and intelligent alerting for distributed applications.
Architecture Components
Section titled “Architecture Components”Graylog Deployment:├── Graylog Server Pods├── Elasticsearch Backend├── MongoDB Metadata Store├── Web Interface├── Input Collectors├── Stream Processing└── Alerting System
🚀 Features
Section titled “🚀 Features”Centralized Logging
Section titled “Centralized Logging”- Log Aggregation: Collect logs from multiple sources and applications
- Real-time Processing: Process and index logs in real-time
- Structured Data: Support for structured and unstructured log data
- Multiple Inputs: Syslog, GELF, Beats, and custom inputs
Search & Analysis
Section titled “Search & Analysis”- Powerful Search: Full-text search with Lucene query syntax
- Field Analysis: Extract and analyze specific log fields
- Dashboards: Customizable dashboards for log visualization
- Saved Searches: Reusable search queries and filters
Alerting & Monitoring
Section titled “Alerting & Monitoring”- Conditional Alerts: Alert based on log patterns and thresholds
- Notification Channels: Email, Slack, webhooks, and custom integrations
- Alert History: Track and manage alert occurrences
- Escalation Rules: Automated escalation for critical issues
Security & Compliance
Section titled “Security & Compliance”- Role-based Access: Granular permissions and user management
- Audit Logging: Track user actions and system changes
- Data Retention: Configurable log retention policies
- Encryption: Encrypted data in transit and at rest
📦 Deployment Configuration
Section titled “📦 Deployment Configuration”Helmfile Configuration
Section titled “Helmfile Configuration”The Graylog deployment uses Helmfile for environment management:
releases: - name: graylog namespace: logging createNamespace: true chart: kongz/graylog values: - values.yaml
Core Configuration Values
Section titled “Core Configuration Values”# Basic configurationreplicaCount: 1
# MongoDB configurationmongodb: enabled: true auth: enabled: false
# Elasticsearch configurationelasticsearch: enabled: true replicas: 1
# Graylog configurationgraylog: image: repository: graylog/graylog tag: "5.3"
service: type: ClusterIP
ingress: enabled: false
resources: requests: memory: "512Mi" cpu: "250m" limits: memory: "1Gi" cpu: "500m"
Advanced Configuration Options
Section titled “Advanced Configuration Options”# High-availability configurationreplicaCount: 3
# Performance tuningresources: requests: memory: "2Gi" cpu: "1000m" limits: memory: "4Gi" cpu: "2000m"
# Security configurationgraylog: auth: enabled: true password: "secure-password"
# Monitoringmetrics: enabled: true serviceMonitor: enabled: true
# Web interfaceingress: enabled: true hostname: logs.theratap.de tls: true annotations: cert-manager.io/cluster-issuer: letsencrypt
🔧 Graylog Configuration
Section titled “🔧 Graylog Configuration”Input Configuration
Section titled “Input Configuration”# Syslog inputinputs: - name: "Syslog UDP" type: "org.graylog2.inputs.syslog.udp.SyslogUDPInput" configuration: bind_address: "0.0.0.0" port: 514 recv_buffer_size: 262144
# GELF input - name: "GELF UDP" type: "org.graylog2.inputs.gelf.udp.GELFUDPInput" configuration: bind_address: "0.0.0.0" port: 12201 recv_buffer_size: 262144
# Beats input - name: "Filebeat" type: "org.graylog2.inputs.beats.BeatsInput" configuration: bind_address: "0.0.0.0" port: 5044 tls_enabled: true
Stream Configuration
Section titled “Stream Configuration”# Stream definitionsstreams: - name: "Application Logs" description: "All application logs" rules: - field: "source" type: "EXACT" value: "application" inverted: false
- name: "Error Logs" description: "Error and warning logs" rules: - field: "level" type: "GREATER_OR_EQUAL" value: "ERROR" inverted: false
Alert Configuration
Section titled “Alert Configuration”# Alert definitionsalerts: - name: "High Error Rate" description: "Alert when error rate exceeds threshold" condition: type: "field_value" field: "level" value: "ERROR" threshold: 10 time_window: 300 notifications: - type: "email" - type: "slack" webhook_url: "https://hooks.slack.com/services/..."
📊 Monitoring & Metrics
Section titled “📊 Monitoring & Metrics”Health Checks
Section titled “Health Checks”# Check Graylog service statuskubectl get pods -n logging -l app.kubernetes.io/name=graylog
# Check service endpointskubectl get endpoints -n logging -l app.kubernetes.io/name=graylog
# Test Graylog connectivitykubectl exec -it graylog-0 -n logging -- curl -u admin:password http://localhost:9000/api/system/overview
Performance Monitoring
Section titled “Performance Monitoring”# Check resource usagekubectl top pods -n logging -l app.kubernetes.io/name=graylog
# Monitor log ingestion ratekubectl exec -it graylog-0 -n logging -- curl -u admin:password http://localhost:9000/api/system/stats
# Check Elasticsearch healthkubectl exec -it graylog-0 -n logging -- curl -u admin:password http://localhost:9000/api/system/indices/index_sets
# Monitor MongoDB statuskubectl exec -it graylog-0 -n logging -- curl -u admin:password http://localhost:9000/api/system/stats
Key Metrics
Section titled “Key Metrics”# Log ingestion ratekubectl exec -it graylog-0 -n logging -- curl -s -u admin:password http://localhost:9000/api/system/stats | jq '.ingest_rate'
# Total messageskubectl exec -it graylog-0 -n logging -- curl -s -u admin:password http://localhost:9000/api/system/stats | jq '.total_messages'
# Index sizekubectl exec -it graylog-0 -n logging -- curl -s -u admin:password http://localhost:9000/api/system/stats | jq '.indices_size'
# JVM metricskubectl exec -it graylog-0 -n logging -- curl -s -u admin:password http://localhost:9000/api/system/stats | jq '.jvm'
Web Interface
Section titled “Web Interface”# Port forward web interfacekubectl port-forward -n logging svc/graylog 9000:9000
# Access web interfaceopen http://localhost:9000
# Default credentials# Username: admin# Password: (from graylog.auth.password in values.yaml)
Log Analysis
Section titled “Log Analysis”# View Graylog logskubectl logs -n logging -l app.kubernetes.io/name=graylog
# Follow logs in real-timekubectl logs -f -n logging deployment/graylog
# Check for errorskubectl logs -n logging -l app.kubernetes.io/name=graylog | grep ERROR
🚀 Deployment
Section titled “🚀 Deployment”Deploy Graylog Module
Section titled “Deploy Graylog Module”# Navigate to module directorycd iac/modules/graylog
# Deploy using Helmfilehelmfile apply
# Verify deploymentkubectl get pods -n loggingkubectl get services -n logging
Verify Deployment
Section titled “Verify Deployment”# Check pod statuskubectl get pods -n logging -l app.kubernetes.io/name=graylog
# Test Graylog APIkubectl exec -it graylog-0 -n logging -- curl -u admin:password http://localhost:9000/api/system/overview
# Check cluster healthkubectl exec -it graylog-0 -n logging -- curl -u admin:password http://localhost:9000/api/system/stats
Post-Deployment Setup
Section titled “Post-Deployment Setup”# Port forward for local accesskubectl port-forward -n logging svc/graylog 9000:9000
# Test log ingestionecho '{"version": "1.1","host":"test","short_message":"Test message","level":1}' | \ nc -w 1 localhost 12201
# Verify log receivedcurl -u admin:password "http://localhost:9000/api/search/universal/relative?query=*&range=300"
🔧 Maintenance Operations
Section titled “🔧 Maintenance Operations”Input Management
Section titled “Input Management”# List inputscurl -u admin:password http://localhost:9000/api/system/inputs
# Create syslog inputcurl -X POST -u admin:password -H "Content-Type: application/json" \ -d '{"title":"Syslog UDP","type":"org.graylog2.inputs.syslog.udp.SyslogUDPInput","global":true,"configuration":{"bind_address":"0.0.0.0","port":514}}' \ http://localhost:9000/api/system/inputs
# Start inputcurl -X POST -u admin:password http://localhost:9000/api/system/inputs/INPUT_ID/start
Stream Management
Section titled “Stream Management”# List streamscurl -u admin:password http://localhost:9000/api/streams
# Create streamcurl -X POST -u admin:password -H "Content-Type: application/json" \ -d '{"title":"Error Logs","description":"Error and warning logs","rules":[{"type":"EXACT","field":"level","value":"ERROR","inverted":false}]}' \ http://localhost:9000/api/streams
# Start streamcurl -X POST -u admin:password http://localhost:9000/api/streams/STREAM_ID/start
User Management
Section titled “User Management”# List userscurl -u admin:password http://localhost:9000/api/users
# Create usercurl -X POST -u admin:password -H "Content-Type: application/json" \ -d '{"username":"appuser","email":"[email protected]","password":"password","full_name":"Application User","roles":["Reader"]}' \ http://localhost:9000/api/users
# Update user permissionscurl -X PUT -u admin:password -H "Content-Type: application/json" \ -d '{"roles":["Reader","Streams"]}' \ http://localhost:9000/api/users/USER_ID
Scaling Operations
Section titled “Scaling Operations”# Scale Graylog replicaskubectl scale deployment graylog -n logging --replicas=3
# Scale Elasticsearchkubectl scale statefulset elasticsearch -n logging --replicas=3
# Verify scalingkubectl get pods -n logging
Update Operations
Section titled “Update Operations”# Update Graylog versionhelmfile apply
# Monitor update progresskubectl rollout status deployment/graylog -n logging
# Rollback if neededkubectl rollout undo deployment/graylog -n logging
🚨 Troubleshooting
Section titled “🚨 Troubleshooting”Common Issues
Section titled “Common Issues”1. Connection Problems
Section titled “1. Connection Problems”# Check service connectivitykubectl get services -n logging
# Test network connectivitykubectl exec -it graylog-0 -n logging -- nc -zv graylog 9000
# Verify DNS resolutionkubectl exec -it graylog-0 -n logging -- nslookup graylog
2. Elasticsearch Issues
Section titled “2. Elasticsearch Issues”# Check Elasticsearch healthkubectl exec -it graylog-0 -n logging -- curl -u admin:password http://localhost:9000/api/system/indices/index_sets
# Check Elasticsearch cluster statuskubectl exec -it elasticsearch-0 -n logging -- curl -s http://localhost:9200/_cluster/health
# Verify index creationkubectl exec -it graylog-0 -n logging -- curl -u admin:password http://localhost:9000/api/system/indices/index_sets
3. MongoDB Issues
Section titled “3. MongoDB Issues”# Check MongoDB connectivitykubectl exec -it graylog-0 -n logging -- curl -u admin:password http://localhost:9000/api/system/stats
# Check MongoDB logskubectl logs -n logging -l app.kubernetes.io/name=mongodb
# Verify MongoDB datakubectl exec -it mongodb-0 -n logging -- mongo --eval "db.stats()"
4. Log Ingestion Issues
Section titled “4. Log Ingestion Issues”# Check input statuscurl -u admin:password http://localhost:9000/api/system/inputs
# Test log ingestionecho '{"version": "1.1","host":"test","short_message":"Test message"}' | \ nc -w 1 localhost 12201
# Check for parsing errorscurl -u admin:password "http://localhost:9000/api/search/universal/relative?query=*&range=300"
Recovery Procedures
Section titled “Recovery Procedures”Emergency Recovery
Section titled “Emergency Recovery”# Force delete stuck podskubectl delete pod graylog-0 -n logging --grace-period=0 --force
# Restart Graylog servicekubectl rollout restart deployment/graylog -n logging
# Verify recoverykubectl exec -it graylog-0 -n logging -- curl -u admin:password http://localhost:9000/api/system/overview
🔒 Security Configuration
Section titled “🔒 Security Configuration”Authentication
Section titled “Authentication”# Enable authenticationgraylog: auth: enabled: true password: "secure-password"
# Network securitynetworkPolicy: enabled: true allowExternal: false ingressRules: primaryAccessOnlyFrom: enabled: true namespaceSelector: matchLabels: name: production podSelector: matchLabels: app.kubernetes.io/name: backend
SSL/TLS Configuration
Section titled “SSL/TLS Configuration”# TLS configurationtls: enabled: true secretName: graylog-tls
# Certificate configurationcertificatesSecret: "graylog-certs"
Access Control
Section titled “Access Control”# User roles and permissionsroles: - name: "Admin" permissions: - "users:list" - "users:edit" - "streams:read" - "streams:write" - "inputs:read" - "inputs:write"
- name: "Reader" permissions: - "streams:read" - "messages:read"
📝 Configuration Examples
Section titled “📝 Configuration Examples”High-Performance Configuration
Section titled “High-Performance Configuration”# High-performance valuesresources: requests: memory: 4Gi cpu: 2000m limits: memory: 8Gi cpu: 4000m
# Performance tuninggraylog: configuration: |- elasticsearch_max_docs_per_index = 20000000 elasticsearch_max_time_per_index = 1d elasticsearch_max_number_of_indices = 20 elasticsearch_shards = 1 elasticsearch_replicas = 0
High-Availability Configuration
Section titled “High-Availability Configuration”# High-availability setupreplicaCount: 3
elasticsearch: replicas: 3 resources: requests: memory: 2Gi cpu: 1000m limits: memory: 4Gi cpu: 2000m
mongodb: replicas: 3
Monitoring-Optimized Configuration
Section titled “Monitoring-Optimized Configuration”# Enhanced monitoringmetrics: enabled: true serviceMonitor: enabled: true interval: 30s
# Custom dashboardsdashboards: - name: "System Overview" description: "System health and performance" widgets: - type: "search_result_chart" query: "*" timerange: "5m"
🔄 Maintenance Schedule
Section titled “🔄 Maintenance Schedule”Daily Tasks
Section titled “Daily Tasks”- Monitor log ingestion rates
- Check alert status
- Review error logs
- Verify cluster health
Weekly Tasks
Section titled “Weekly Tasks”- Analyze performance metrics
- Review log retention
- Update user permissions
- Check for updates
Monthly Tasks
Section titled “Monthly Tasks”- Capacity planning review
- Performance optimization
- Security audit
- Disaster recovery testing
📋 Operational Checklist
Section titled “📋 Operational Checklist”Pre-Deployment
Section titled “Pre-Deployment”- Storage classes configured
- Persistent volumes available
- Network policies defined
- Authentication configured
- Input sources identified
Post-Deployment
Section titled “Post-Deployment”- Graylog service accessible
- Web interface functional
- Inputs configured
- Monitoring configured
- Application connectivity tested
Regular Maintenance
Section titled “Regular Maintenance”- Log retention optimized
- Performance metrics reviewed
- Security updates applied
- Capacity planning updated
- Disaster recovery tested
🔗 Related Documentation
Section titled “🔗 Related Documentation”- Backend Application - Logging integration
- Configuration Guide - Log configuration
- Security Guide - Log security
- Monitoring Guide - Log monitoring
The Graylog logging module provides enterprise-grade centralized logging with powerful search, analysis, and alerting capabilities.