Auto-sync: 20260116-152013
This commit is contained in:
@@ -98,7 +98,11 @@ Monitors Claude Code token usage across all machines to track subscription consu
|
||||
```
|
||||
Claude Code (MacBook/Mac Mini)
|
||||
│
|
||||
▼ (OpenTelemetry Prometheus exporter :9464)
|
||||
▼ (OTLP HTTP push)
|
||||
│
|
||||
OTEL Collector (docker-host:4318)
|
||||
│
|
||||
▼ (Remote Write)
|
||||
│
|
||||
Prometheus (docker-host:9090)
|
||||
│
|
||||
@@ -108,10 +112,7 @@ Prometheus (docker-host:9090)
|
||||
```
|
||||
|
||||
**Monitored Devices**:
|
||||
| Device | IP Address | Metrics Port |
|
||||
|--------|------------|--------------|
|
||||
| MacBook | 10.10.10.147 | 9464 |
|
||||
| Mac Mini | 10.10.10.123 | 9464 |
|
||||
All Claude Code sessions on any device automatically push metrics via OTLP.
|
||||
|
||||
**What's monitored**:
|
||||
- Token usage (input/output/cache) over time
|
||||
@@ -131,8 +132,8 @@ Prometheus (docker-host:9090)
|
||||
| No Metrics | Scrape fails for 5min | Info |
|
||||
|
||||
**Configuration Files**:
|
||||
- Claude settings: `~/.claude/settings.json` (on each Mac)
|
||||
- Prometheus scrape: `/opt/monitoring/prometheus/prometheus.yml` (docker-host)
|
||||
- Claude settings: `~/.claude/settings.json` (on each Mac - synced via Syncthing)
|
||||
- OTEL Collector: `/opt/monitoring/otel-collector/config.yaml` (docker-host)
|
||||
- Alert rules: `/opt/monitoring/prometheus/rules/claude-code.yml` (docker-host)
|
||||
|
||||
**Claude Code Settings** (in `~/.claude/settings.json`):
|
||||
@@ -140,24 +141,38 @@ Prometheus (docker-host:9090)
|
||||
{
|
||||
"env": {
|
||||
"CLAUDE_CODE_ENABLE_TELEMETRY": "1",
|
||||
"OTEL_METRICS_EXPORTER": "prometheus",
|
||||
"OTEL_EXPORTER_PROMETHEUS_PORT": "9464",
|
||||
"OTEL_METRICS_EXPORTER": "otlp",
|
||||
"OTEL_EXPORTER_OTLP_ENDPOINT": "http://10.10.10.206:4318",
|
||||
"OTEL_EXPORTER_OTLP_PROTOCOL": "http/protobuf",
|
||||
"OTEL_METRIC_EXPORT_INTERVAL": "60000"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Prometheus Scrape Config**:
|
||||
**OTEL Collector Config** (`/opt/monitoring/otel-collector/config.yaml`):
|
||||
```yaml
|
||||
- job_name: "claude-code"
|
||||
scrape_interval: 60s
|
||||
static_configs:
|
||||
- targets: ["10.10.10.147:9464"]
|
||||
labels:
|
||||
device: "macbook"
|
||||
- targets: ["10.10.10.123:9464"]
|
||||
labels:
|
||||
device: "mac-mini"
|
||||
receivers:
|
||||
otlp:
|
||||
protocols:
|
||||
grpc:
|
||||
endpoint: 0.0.0.0:4317
|
||||
http:
|
||||
endpoint: 0.0.0.0:4318
|
||||
|
||||
processors:
|
||||
batch:
|
||||
timeout: 10s
|
||||
|
||||
exporters:
|
||||
prometheusremotewrite:
|
||||
endpoint: "http://prometheus:9090/api/v1/write"
|
||||
|
||||
service:
|
||||
pipelines:
|
||||
metrics:
|
||||
receivers: [otlp]
|
||||
processors: [batch]
|
||||
exporters: [prometheusremotewrite]
|
||||
```
|
||||
|
||||
**Useful PromQL Queries**:
|
||||
|
||||
Reference in New Issue
Block a user