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