Initial commit
This commit is contained in:
38
skills/otel-monitoring-setup/templates/cleanup-telemetry.sh
Normal file
38
skills/otel-monitoring-setup/templates/cleanup-telemetry.sh
Normal file
@@ -0,0 +1,38 @@
|
||||
#!/bin/bash
|
||||
# Full Cleanup of Claude Code Telemetry Stack
|
||||
# WARNING: This removes all data including Docker volumes
|
||||
|
||||
echo "⚠️ WARNING: This will remove ALL telemetry data including:"
|
||||
echo " - All containers"
|
||||
echo " - All Docker volumes (Grafana, Prometheus, Loki data)"
|
||||
echo " - Network configuration"
|
||||
echo ""
|
||||
read -p "Are you sure you want to proceed? (yes/no): " -r
|
||||
echo
|
||||
|
||||
if [[ ! $REPLY =~ ^[Yy][Ee][Ss]$ ]]; then
|
||||
echo "Cleanup cancelled."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Performing full cleanup of Claude Code telemetry stack..."
|
||||
|
||||
# Navigate to telemetry directory
|
||||
cd ~/.claude/telemetry || exit 1
|
||||
|
||||
# Stop and remove containers, networks, and volumes
|
||||
docker compose down -v
|
||||
|
||||
echo ""
|
||||
echo "✅ Full cleanup complete!"
|
||||
echo ""
|
||||
echo "Removed:"
|
||||
echo " ✓ All containers (otel-collector, prometheus, loki, grafana)"
|
||||
echo " ✓ All volumes (all historical data)"
|
||||
echo " ✓ Network configuration"
|
||||
echo ""
|
||||
echo "Preserved:"
|
||||
echo " ✓ Configuration files in ~/.claude/telemetry/"
|
||||
echo " ✓ Claude Code settings in ~/.claude/settings.json"
|
||||
echo ""
|
||||
echo "To start fresh: ./start-telemetry.sh"
|
||||
74
skills/otel-monitoring-setup/templates/docker-compose.yml
Normal file
74
skills/otel-monitoring-setup/templates/docker-compose.yml
Normal file
@@ -0,0 +1,74 @@
|
||||
services:
|
||||
# OpenTelemetry Collector - receives telemetry from Claude Code
|
||||
otel-collector:
|
||||
image: otel/opentelemetry-collector-contrib:0.115.1
|
||||
container_name: claude-otel-collector
|
||||
command: ["--config=/etc/otel-collector-config.yml"]
|
||||
volumes:
|
||||
- ./otel-collector-config.yml:/etc/otel-collector-config.yml
|
||||
ports:
|
||||
- "4317:4317" # OTLP gRPC receiver
|
||||
- "4318:4318" # OTLP HTTP receiver
|
||||
- "8889:8889" # Prometheus metrics exporter
|
||||
networks:
|
||||
- claude-telemetry
|
||||
|
||||
# Prometheus - stores metrics
|
||||
prometheus:
|
||||
image: prom/prometheus:v2.55.1
|
||||
container_name: claude-prometheus
|
||||
command:
|
||||
- '--config.file=/etc/prometheus/prometheus.yml'
|
||||
- '--storage.tsdb.path=/prometheus'
|
||||
- '--web.console.libraries=/etc/prometheus/console_libraries'
|
||||
- '--web.console.templates=/etc/prometheus/consoles'
|
||||
- '--web.enable-lifecycle'
|
||||
volumes:
|
||||
- ./prometheus.yml:/etc/prometheus/prometheus.yml
|
||||
- prometheus-data:/prometheus
|
||||
ports:
|
||||
- "9090:9090"
|
||||
networks:
|
||||
- claude-telemetry
|
||||
depends_on:
|
||||
- otel-collector
|
||||
|
||||
# Loki - stores logs
|
||||
loki:
|
||||
image: grafana/loki:3.0.0
|
||||
container_name: claude-loki
|
||||
ports:
|
||||
- "3100:3100"
|
||||
command: -config.file=/etc/loki/local-config.yaml
|
||||
volumes:
|
||||
- loki-data:/loki
|
||||
networks:
|
||||
- claude-telemetry
|
||||
|
||||
# Grafana - visualization dashboards
|
||||
grafana:
|
||||
image: grafana/grafana:11.3.0
|
||||
container_name: claude-grafana
|
||||
ports:
|
||||
- "3000:3000"
|
||||
environment:
|
||||
- GF_SECURITY_ADMIN_USER=admin
|
||||
- GF_SECURITY_ADMIN_PASSWORD=admin
|
||||
- GF_USERS_ALLOW_SIGN_UP=false
|
||||
volumes:
|
||||
- grafana-data:/var/lib/grafana
|
||||
- ./grafana-datasources.yml:/etc/grafana/provisioning/datasources/datasources.yml
|
||||
networks:
|
||||
- claude-telemetry
|
||||
depends_on:
|
||||
- prometheus
|
||||
- loki
|
||||
|
||||
networks:
|
||||
claude-telemetry:
|
||||
driver: bridge
|
||||
|
||||
volumes:
|
||||
prometheus-data:
|
||||
loki-data:
|
||||
grafana-data:
|
||||
@@ -0,0 +1,19 @@
|
||||
apiVersion: 1
|
||||
|
||||
datasources:
|
||||
- name: Prometheus
|
||||
type: prometheus
|
||||
access: proxy
|
||||
url: http://prometheus:9090
|
||||
isDefault: true
|
||||
editable: true
|
||||
jsonData:
|
||||
timeInterval: "15s"
|
||||
|
||||
- name: Loki
|
||||
type: loki
|
||||
access: proxy
|
||||
url: http://loki:3100
|
||||
editable: true
|
||||
jsonData:
|
||||
maxLines: 1000
|
||||
@@ -0,0 +1,56 @@
|
||||
receivers:
|
||||
otlp:
|
||||
protocols:
|
||||
grpc:
|
||||
endpoint: 0.0.0.0:4317
|
||||
http:
|
||||
endpoint: 0.0.0.0:4318
|
||||
|
||||
processors:
|
||||
batch:
|
||||
timeout: 10s
|
||||
send_batch_size: 1024
|
||||
|
||||
resource:
|
||||
attributes:
|
||||
- key: service.name
|
||||
value: claude-code
|
||||
action: upsert
|
||||
|
||||
memory_limiter:
|
||||
check_interval: 1s
|
||||
limit_mib: 512
|
||||
|
||||
exporters:
|
||||
# Export metrics to Prometheus
|
||||
prometheus:
|
||||
endpoint: "0.0.0.0:8889"
|
||||
namespace: claude_code
|
||||
const_labels:
|
||||
source: claude_code_telemetry
|
||||
|
||||
# Export logs to Loki via OTLP HTTP
|
||||
otlphttp/loki:
|
||||
endpoint: http://loki:3100/otlp
|
||||
tls:
|
||||
insecure: true
|
||||
|
||||
# Debug exporter (outputs to console for troubleshooting)
|
||||
debug:
|
||||
verbosity: normal
|
||||
|
||||
service:
|
||||
pipelines:
|
||||
metrics:
|
||||
receivers: [otlp]
|
||||
processors: [memory_limiter, batch, resource]
|
||||
exporters: [prometheus, debug]
|
||||
|
||||
logs:
|
||||
receivers: [otlp]
|
||||
processors: [memory_limiter, batch, resource]
|
||||
exporters: [otlphttp/loki, debug]
|
||||
|
||||
telemetry:
|
||||
logs:
|
||||
level: info
|
||||
14
skills/otel-monitoring-setup/templates/prometheus.yml
Normal file
14
skills/otel-monitoring-setup/templates/prometheus.yml
Normal file
@@ -0,0 +1,14 @@
|
||||
global:
|
||||
scrape_interval: 15s
|
||||
evaluation_interval: 15s
|
||||
|
||||
scrape_configs:
|
||||
- job_name: 'otel-collector'
|
||||
static_configs:
|
||||
- targets: ['otel-collector:8889']
|
||||
labels:
|
||||
source: 'claude-code'
|
||||
|
||||
- job_name: 'prometheus'
|
||||
static_configs:
|
||||
- targets: ['localhost:9090']
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"env": {
|
||||
"CLAUDE_CODE_ENABLE_TELEMETRY": "1",
|
||||
"OTEL_METRICS_EXPORTER": "otlp",
|
||||
"OTEL_LOGS_EXPORTER": "otlp",
|
||||
"OTEL_EXPORTER_OTLP_PROTOCOL": "grpc",
|
||||
"OTEL_EXPORTER_OTLP_ENDPOINT": "https://otel.company.com:4317",
|
||||
"OTEL_EXPORTER_OTLP_HEADERS": "Authorization=Bearer YOUR_API_KEY_HERE",
|
||||
"OTEL_METRIC_EXPORT_INTERVAL": "60000",
|
||||
"OTEL_LOGS_EXPORT_INTERVAL": "5000",
|
||||
"OTEL_LOG_USER_PROMPTS": "1",
|
||||
"OTEL_METRICS_INCLUDE_SESSION_ID": "true",
|
||||
"OTEL_METRICS_INCLUDE_VERSION": "true",
|
||||
"OTEL_METRICS_INCLUDE_ACCOUNT_UUID": "true",
|
||||
"OTEL_RESOURCE_ATTRIBUTES": "team=TEAM_NAME,environment=production,deployment=enterprise"
|
||||
}
|
||||
}
|
||||
16
skills/otel-monitoring-setup/templates/settings.json.local
Normal file
16
skills/otel-monitoring-setup/templates/settings.json.local
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"env": {
|
||||
"CLAUDE_CODE_ENABLE_TELEMETRY": "1",
|
||||
"OTEL_METRICS_EXPORTER": "otlp",
|
||||
"OTEL_LOGS_EXPORTER": "otlp",
|
||||
"OTEL_EXPORTER_OTLP_PROTOCOL": "grpc",
|
||||
"OTEL_EXPORTER_OTLP_ENDPOINT": "http://localhost:4317",
|
||||
"OTEL_METRIC_EXPORT_INTERVAL": "60000",
|
||||
"OTEL_LOGS_EXPORT_INTERVAL": "5000",
|
||||
"OTEL_LOG_USER_PROMPTS": "1",
|
||||
"OTEL_METRICS_INCLUDE_SESSION_ID": "true",
|
||||
"OTEL_METRICS_INCLUDE_VERSION": "true",
|
||||
"OTEL_METRICS_INCLUDE_ACCOUNT_UUID": "true",
|
||||
"OTEL_RESOURCE_ATTRIBUTES": "environment=local,deployment=poc"
|
||||
}
|
||||
}
|
||||
39
skills/otel-monitoring-setup/templates/start-telemetry.sh
Normal file
39
skills/otel-monitoring-setup/templates/start-telemetry.sh
Normal file
@@ -0,0 +1,39 @@
|
||||
#!/bin/bash
|
||||
# Start Claude Code Telemetry Stack
|
||||
|
||||
echo "Starting Claude Code telemetry stack..."
|
||||
|
||||
# Check if Docker is running
|
||||
if ! docker info > /dev/null 2>&1; then
|
||||
echo "❌ Error: Docker is not running. Please start Docker Desktop first."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Navigate to telemetry directory
|
||||
cd ~/.claude/telemetry || exit 1
|
||||
|
||||
# Start containers
|
||||
docker compose up -d
|
||||
|
||||
# Wait for services to be ready
|
||||
echo "Waiting for services to be ready..."
|
||||
sleep 10
|
||||
|
||||
# Check container status
|
||||
echo ""
|
||||
echo "Container Status:"
|
||||
docker compose ps
|
||||
|
||||
echo ""
|
||||
echo "✅ Telemetry stack started!"
|
||||
echo ""
|
||||
echo "Access Points:"
|
||||
echo " - Grafana: http://localhost:3000 (admin/admin)"
|
||||
echo " - Prometheus: http://localhost:9090"
|
||||
echo " - Loki: http://localhost:3100"
|
||||
echo ""
|
||||
echo "OTEL Endpoints:"
|
||||
echo " - gRPC: http://localhost:4317"
|
||||
echo " - HTTP: http://localhost:4318"
|
||||
echo ""
|
||||
echo "Next: Restart Claude Code to start sending telemetry data"
|
||||
16
skills/otel-monitoring-setup/templates/stop-telemetry.sh
Normal file
16
skills/otel-monitoring-setup/templates/stop-telemetry.sh
Normal file
@@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
# Stop Claude Code Telemetry Stack
|
||||
|
||||
echo "Stopping Claude Code telemetry stack..."
|
||||
|
||||
# Navigate to telemetry directory
|
||||
cd ~/.claude/telemetry || exit 1
|
||||
|
||||
# Stop containers
|
||||
docker compose down
|
||||
|
||||
echo "✅ Telemetry stack stopped!"
|
||||
echo ""
|
||||
echo "Note: Data is preserved in Docker volumes."
|
||||
echo "To start again: ./start-telemetry.sh"
|
||||
echo "To completely remove all data: ./cleanup-telemetry.sh"
|
||||
Reference in New Issue
Block a user