Configuration
Kafka Log Analyzer configuration reference
Environment Variables
Basic Configuration
| Variable | Description | Default | Required |
|---|---|---|---|
LOG_LEVEL | Log level | info | No |
NODE_ENV | Runtime environment | development | No |
Data Source Configuration (v0.3.0+)
| Variable | Description | Default | Required |
|---|---|---|---|
PROMETHEUS_URL | Prometheus API URL | http://localhost:9090 | v0.3.0+ |
KAFKA_EXPORTER_URL | Kafka Exporter URL | http://localhost:9308 | v0.3.0+ |
LOKI_URL | Loki log API URL | http://localhost:3100 | v0.3.0+ |
Hook & Push Configuration (v0.4.0+)
| Variable | Description | Default | Required |
|---|---|---|---|
GRAFANA_WEBHOOK_PORT | Hook server listen port | 3100 | v0.4.0+ |
PAGERDUTY_WEBHOOK_PORT | PagerDuty webhook port | 3101 | No |
FEISHU_WEBHOOK_URL | Feishu webhook URL | - | Feishu push |
SLACK_WEBHOOK_URL | Slack webhook URL | - | Slack push |
JIRA_URL | JIRA base URL | - | JIRA push |
JIRA_TOKEN | JIRA API token | - | JIRA push |
JIRA_PROJECT_KEY | JIRA project key | - | JIRA push |
HOOK_DEDUP_WINDOW_MS | Dedup TTL window (ms) | 300000 | No |
HOOK_MAX_MERGE_COUNT | Max merge count per fingerprint | 10 | No |
Storage Configuration (v0.5.0+)
| Variable | Description | Default | Required |
|---|---|---|---|
SQLITE_PATH | SQLite database path | ./storage/kafka-analyzer.db | v0.5.0+ |
STORAGE_RETENTION_DAYS | Data retention in days | 30 | v0.5.0+ |
STORAGE_AUTO_CLEANUP | Enable automatic daily cleanup | true | No |
User Experience Configuration (v1.1.0+)
| Variable | Description | Default | Required |
|---|---|---|---|
LOCALE | Language for i18n (en or zh) | Auto-detect from system | No |
CACHE_SESSION | Enable in-memory session cache | true | No |
CACHE_TTL | Default cache TTL in seconds | 86400 | No |
.env File Example
bash
# .env
# Phase 1 (Basic Features) - No configuration required
# Phase 2 (Data Source Integration)
PROMETHEUS_URL=http://prometheus:9090
KAFKA_EXPORTER_URL=http://kafka-exporter:9308
LOKI_URL=http://loki:3100
# Phase 3 (Hook & Push Integration)
GRAFANA_WEBHOOK_PORT=3100
PAGERDUTY_WEBHOOK_PORT=3101
FEISHU_WEBHOOK_URL=https://open.feishu.cn/open-apis/bot/v2/hook/xxx
SLACK_WEBHOOK_URL=https://hooks.slack.com/services/xxx
JIRA_URL=https://your-domain.atlassian.net
JIRA_TOKEN=your-api-token
JIRA_PROJECT_KEY=KAFKA
HOOK_DEDUP_WINDOW_MS=300000
HOOK_MAX_MERGE_COUNT=10
# Phase 4 (Historical Comparison)
SQLITE_PATH=./storage/kafka-analyzer.db
STORAGE_RETENTION_DAYS=30
STORAGE_AUTO_CLEANUP=true
# Phase 5 (User Experience)
LOCALE=en
CACHE_SESSION=true
CACHE_TTL=86400
# Log Configuration
LOG_LEVEL=info
LOG_FORMAT=json
NODE_ENV=productionConfiguration Files
plugin.json
Plugin metadata configuration:
json
{
"name": "kafka-log-analyzer",
"version": "1.0.0",
"description": "Intelligent Kafka log analysis tool for Claude Code",
"main": "dist/index.js",
"commands": ["kafka-analyze", "kafka-lag"],
"mcp": {
"server": "dist/mcp-server/index.js"
}
}Prometheus Configuration
Scrape Configuration
yaml
# prometheus.yml
scrape_configs:
- job_name: 'kafka-exporter'
static_configs:
- targets: ['kafka-exporter:9308']
scrape_interval: 15sCommon Queries
txt
# Consumer Lag
kafka_consumer_lag_records
# Producer Send Rate
kafka_producer_record_send_rate
# Broker Leader Election Count
kafka_broker_leader_election_rate
# Filter by Consumer Group
kafka_consumer_lag_records{group="order-processor"}Kafka Exporter Configuration
Docker Startup
bash
docker run -d \
--name kafka-exporter \
-p 9308:9308 \
danielqsj/kafka-exporter \
--kafka.server=kafka:9092Loki Configuration
Log Queries
txt
# Kafka error logs
{app="kafka"} |= "ERROR"
# Filter by time range
{app="kafka"} |= "ERROR" [1h]
# Producer-related errors
{app="kafka", component="producer"} |= "ERROR"Detection Rule Configuration
You can customize detection rules in config/detection-rules.json:
json
{
"rules": [
{
"name": "high_lag",
"condition": "lag > 10000",
"severity": "P1",
"recommendation": "Check consumer processing speed"
},
{
"name": "rebalance_storm",
"condition": "rebalances > 3 in 5m",
"severity": "P0",
"recommendation": "Review consumer group configuration"
}
]
}Related Documentation
- Deployment Guide — Production deployment configuration
- API Reference — MCP Tools API documentation