Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion config.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ ai:
# supports_reasoning: false # Set true if model natively supports reasoning / thinking parameters

# Reference model used for counterfactual cloud spend calculations and hardware payoff.
# Defaults to gpt-4o-mini.
# Defaults to gpt-4o-mini. The two reference models price the local ledger that
# `devops ai cost` reports. The AI spend dashboard prices the local tokens of every process
# at the default reference models, in a recording rule of k8s/monitoring/prometheus-values.yaml.
reference_model: gpt-4o-mini
# Reference model that prices the tokens of local embedding requests.
# Defaults to text-embedding-3-small.
Expand Down
12 changes: 6 additions & 6 deletions docs/CLI_REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5105,7 +5105,7 @@ devops ai cost [OPTIONS] COMMAND [ARGS]...
|---|---|---|---|
| `--by`, `-b` | `string` | `server` | Breakdown grouping dimension: server, model, provider, backend, stage, all. |
| `--days`, `-d` | `integer` | - | Filter usage to the last N days (default: all lifetime). |
| `--reference-model`, `-m` | `string` | - | Reference model for counterfactual pricing (default: gpt-4o-mini). |
| `--reference-model`, `-m` | `string` | - | Reference model for counterfactual pricing (default: the ai.reference_model setting). |
| `--hardware-cost`, `-H` | `float` | - | Hardware purchase cost in USD to track pay-off against. |
| `--format`, `-f` | `string` | `table` | Output format: table, json, yaml, markdown. |
| `--json` | `boolean` | - | First-class alias for --format json. |
Expand All @@ -5124,7 +5124,7 @@ devops ai cost report [OPTIONS]
|---|---|---|---|
| `--by`, `-b` | `string` | `server` | Breakdown grouping dimension: server, model, provider, backend, stage, all. |
| `--days`, `-d` | `integer` | - | Filter usage to the last N days (default: all lifetime). |
| `--reference-model`, `-m` | `string` | - | Reference model for counterfactual pricing (default: gpt-4o-mini). |
| `--reference-model`, `-m` | `string` | - | Reference model for counterfactual pricing (default: the ai.reference_model setting). |
| `--hardware-cost`, `-H` | `float` | - | Hardware purchase cost in USD to track pay-off against. |
| `--format`, `-f` | `string` | `table` | Output format: table, json, yaml, prometheus. |
| `--json` | `boolean` | - | First-class alias for --format json. |
Expand All @@ -5142,7 +5142,7 @@ devops ai cost roi [OPTIONS]
| Option / Flag | Type | Default | Description |
|---|---|---|---|
| `--hardware-cost`, `-H` | `float` | - | Total hardware purchase cost in USD (e.g. 1599.0 for GPU/workstation). |
| `--reference-model`, `-m` | `string` | - | Reference model for counterfactual pricing (default: gpt-4o-mini). |
| `--reference-model`, `-m` | `string` | - | Reference model for counterfactual pricing (default: the ai.reference_model setting). |
| `--days`, `-d` | `integer` | - | Filter usage to the last N days (default: all lifetime). |
| `--format`, `-f` | `string` | `table` | Output format: table, json, yaml. |
| `--json` | `boolean` | - | First-class alias for --format json. |
Expand Down Expand Up @@ -5235,7 +5235,7 @@ devops ai spend [OPTIONS] COMMAND [ARGS]...
|---|---|---|---|
| `--by`, `-b` | `string` | `server` | Breakdown grouping dimension: server, model, provider, backend, stage, all. |
| `--days`, `-d` | `integer` | - | Filter usage to the last N days (default: all lifetime). |
| `--reference-model`, `-m` | `string` | - | Reference model for counterfactual pricing (default: gpt-4o-mini). |
| `--reference-model`, `-m` | `string` | - | Reference model for counterfactual pricing (default: the ai.reference_model setting). |
| `--hardware-cost`, `-H` | `float` | - | Hardware purchase cost in USD to track pay-off against. |
| `--format`, `-f` | `string` | `table` | Output format: table, json, yaml, markdown. |
| `--json` | `boolean` | - | First-class alias for --format json. |
Expand All @@ -5254,7 +5254,7 @@ devops ai spend report [OPTIONS]
|---|---|---|---|
| `--by`, `-b` | `string` | `server` | Breakdown grouping dimension: server, model, provider, backend, stage, all. |
| `--days`, `-d` | `integer` | - | Filter usage to the last N days (default: all lifetime). |
| `--reference-model`, `-m` | `string` | - | Reference model for counterfactual pricing (default: gpt-4o-mini). |
| `--reference-model`, `-m` | `string` | - | Reference model for counterfactual pricing (default: the ai.reference_model setting). |
| `--hardware-cost`, `-H` | `float` | - | Hardware purchase cost in USD to track pay-off against. |
| `--format`, `-f` | `string` | `table` | Output format: table, json, yaml, prometheus. |
| `--json` | `boolean` | - | First-class alias for --format json. |
Expand All @@ -5272,7 +5272,7 @@ devops ai spend roi [OPTIONS]
| Option / Flag | Type | Default | Description |
|---|---|---|---|
| `--hardware-cost`, `-H` | `float` | - | Total hardware purchase cost in USD (e.g. 1599.0 for GPU/workstation). |
| `--reference-model`, `-m` | `string` | - | Reference model for counterfactual pricing (default: gpt-4o-mini). |
| `--reference-model`, `-m` | `string` | - | Reference model for counterfactual pricing (default: the ai.reference_model setting). |
| `--days`, `-d` | `integer` | - | Filter usage to the last N days (default: all lifetime). |
| `--format`, `-f` | `string` | `table` | Output format: table, json, yaml. |
| `--json` | `boolean` | - | First-class alias for --format json. |
Expand Down
2 changes: 1 addition & 1 deletion docs/MCP_TOOLS.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ Generate detailed spend and token report across backend services and servers.
|---|---|---|---|---|
| `by` | `string` | No | `server` | Breakdown grouping dimension: server, model, provider, backend, stage, all. |
| `days` | `integer` | No | - | Filter usage to the last N days (default: all lifetime). |
| `reference_model` | `string` | No | - | Reference model for counterfactual pricing (default: gpt-4o-mini). |
| `reference_model` | `string` | No | - | Reference model for counterfactual pricing (default: the ai.reference_model setting). |
| `hardware_cost` | `number` | No | - | Hardware purchase cost in USD to track pay-off against. |
| `format_opt` | `string` | No | `table` | Output format: table, json, yaml, prometheus. |
| `json_flag` | `boolean` | No | `False` | First-class alias for --format json. |
Expand Down
12 changes: 10 additions & 2 deletions docs/TELEMETRY.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ native histogram under the instrument's own name, with no `_bucket`, `_sum` or
| `devops_cli_review_duration_seconds` | Histogram | `s` | Review wall time, by target type. |
| `devops_cli_findings_total` | Counter | `1` | Review findings, by producer, severity and status. |
| `devops_cli_ai_requests_total` | Counter | `1` | LLM calls and embedding requests, by operation (chat or embeddings), provider, model, server, serving backend and whether the cache answered. |
| `devops_cli_ai_tokens_total` | Counter | `1` | LLM and embedding tokens, by operation (chat or embeddings), type (prompt or completion), provider, model, server and backend. |
| `devops_cli_ai_tokens_total` | Counter | `1` | LLM and embedding tokens, by operation (chat or embeddings), type (prompt or completion), provider, model, server, backend and local: true when a local model ran them. The AI spend dashboard prices local tokens as savings at the reference price that the Prometheus recording rule devops_cli:ai_reference_price_usd_per_token holds for their operation and type. |
| `devops_cli_ai_spend_usd_total` | Counter | `USD` | Approximate LLM and embedding spend, by operation, provider, model, server and backend. Each request that a model answers adds to it, and a local request adds 0. |
| `devops_cli_ai_local_cost_equivalent_usd_total` | Counter | `USD` | Equivalent hosted cloud spend avoided by local model execution, by operation, at the reference model of the operation. |
| `devops_cli_ai_json_repairs_total` | Counter | `1` | LLM JSON replies repaired after strict parsing failed, by entry point source. |
| `devops_cli_ai_gateway_slot_wait_seconds` | Histogram | `s` | Time a chat call to the LLM gateway waited in this process for one of the gateway's backend slots, by outcome: ok once it held one, or timeout. |
| `devops_cli_rag_query_duration_ms` | Histogram | `ms` | RAG retrieval time, by stage: embedding, search, ranking, or total for the whole query. |
Expand All @@ -61,6 +60,15 @@ native histogram under the instrument's own name, with no `_bucket`, `_sum` or
| `devops_cli_upstream_service_status` | Gauge | `1` | Upstream cloud service operational status severity code (0=none/operational, 1=minor, 2=major, 3=critical) by service and indicator. |
| `devops_cli_upstream_component_status` | Gauge | `1` | Upstream cloud service component status code (0=operational, 1=degraded, 2=partial_outage, 3=major_outage) by service and component. |

No process sends local savings in USD. `devops_cli_ai_tokens_total{local="true"}`
counts the tokens that a local model ran, and the AI spend dashboard multiplies them
by the Prometheus recording rule `devops_cli:ai_reference_price_usd_per_token` in
`k8s/monitoring/prometheus-values.yaml`. The rule holds genai-prices' price of the
default reference model for each operation and token type, so the workstation and
the Service are priced at one reference. `ai.reference_model` and
`ai.reference_embedding_model` price only the local ledger that `devops ai cost`
reports.

---

## Distributed Tracing & W3C Context Propagation
Expand Down
12 changes: 6 additions & 6 deletions docs/commands/ai.md
Original file line number Diff line number Diff line change
Expand Up @@ -1899,7 +1899,7 @@ devops ai cost [OPTIONS] COMMAND [ARGS]...
|---|---|---|---|
| `--by`, `-b` | `string` | `server` | Breakdown grouping dimension: server, model, provider, backend, stage, all. |
| `--days`, `-d` | `integer` | - | Filter usage to the last N days (default: all lifetime). |
| `--reference-model`, `-m` | `string` | - | Reference model for counterfactual pricing (default: gpt-4o-mini). |
| `--reference-model`, `-m` | `string` | - | Reference model for counterfactual pricing (default: the ai.reference_model setting). |
| `--hardware-cost`, `-H` | `float` | - | Hardware purchase cost in USD to track pay-off against. |
| `--format`, `-f` | `string` | `table` | Output format: table, json, yaml, markdown. |
| `--json` | `boolean` | - | First-class alias for --format json. |
Expand All @@ -1918,7 +1918,7 @@ devops ai cost report [OPTIONS]
|---|---|---|---|
| `--by`, `-b` | `string` | `server` | Breakdown grouping dimension: server, model, provider, backend, stage, all. |
| `--days`, `-d` | `integer` | - | Filter usage to the last N days (default: all lifetime). |
| `--reference-model`, `-m` | `string` | - | Reference model for counterfactual pricing (default: gpt-4o-mini). |
| `--reference-model`, `-m` | `string` | - | Reference model for counterfactual pricing (default: the ai.reference_model setting). |
| `--hardware-cost`, `-H` | `float` | - | Hardware purchase cost in USD to track pay-off against. |
| `--format`, `-f` | `string` | `table` | Output format: table, json, yaml, prometheus. |
| `--json` | `boolean` | - | First-class alias for --format json. |
Expand All @@ -1936,7 +1936,7 @@ devops ai cost roi [OPTIONS]
| Option / Flag | Type | Default | Description |
|---|---|---|---|
| `--hardware-cost`, `-H` | `float` | - | Total hardware purchase cost in USD (e.g. 1599.0 for GPU/workstation). |
| `--reference-model`, `-m` | `string` | - | Reference model for counterfactual pricing (default: gpt-4o-mini). |
| `--reference-model`, `-m` | `string` | - | Reference model for counterfactual pricing (default: the ai.reference_model setting). |
| `--days`, `-d` | `integer` | - | Filter usage to the last N days (default: all lifetime). |
| `--format`, `-f` | `string` | `table` | Output format: table, json, yaml. |
| `--json` | `boolean` | - | First-class alias for --format json. |
Expand Down Expand Up @@ -2031,7 +2031,7 @@ devops ai spend [OPTIONS] COMMAND [ARGS]...
|---|---|---|---|
| `--by`, `-b` | `string` | `server` | Breakdown grouping dimension: server, model, provider, backend, stage, all. |
| `--days`, `-d` | `integer` | - | Filter usage to the last N days (default: all lifetime). |
| `--reference-model`, `-m` | `string` | - | Reference model for counterfactual pricing (default: gpt-4o-mini). |
| `--reference-model`, `-m` | `string` | - | Reference model for counterfactual pricing (default: the ai.reference_model setting). |
| `--hardware-cost`, `-H` | `float` | - | Hardware purchase cost in USD to track pay-off against. |
| `--format`, `-f` | `string` | `table` | Output format: table, json, yaml, markdown. |
| `--json` | `boolean` | - | First-class alias for --format json. |
Expand All @@ -2050,7 +2050,7 @@ devops ai spend report [OPTIONS]
|---|---|---|---|
| `--by`, `-b` | `string` | `server` | Breakdown grouping dimension: server, model, provider, backend, stage, all. |
| `--days`, `-d` | `integer` | - | Filter usage to the last N days (default: all lifetime). |
| `--reference-model`, `-m` | `string` | - | Reference model for counterfactual pricing (default: gpt-4o-mini). |
| `--reference-model`, `-m` | `string` | - | Reference model for counterfactual pricing (default: the ai.reference_model setting). |
| `--hardware-cost`, `-H` | `float` | - | Hardware purchase cost in USD to track pay-off against. |
| `--format`, `-f` | `string` | `table` | Output format: table, json, yaml, prometheus. |
| `--json` | `boolean` | - | First-class alias for --format json. |
Expand All @@ -2068,7 +2068,7 @@ devops ai spend roi [OPTIONS]
| Option / Flag | Type | Default | Description |
|---|---|---|---|
| `--hardware-cost`, `-H` | `float` | - | Total hardware purchase cost in USD (e.g. 1599.0 for GPU/workstation). |
| `--reference-model`, `-m` | `string` | - | Reference model for counterfactual pricing (default: gpt-4o-mini). |
| `--reference-model`, `-m` | `string` | - | Reference model for counterfactual pricing (default: the ai.reference_model setting). |
| `--days`, `-d` | `integer` | - | Filter usage to the last N days (default: all lifetime). |
| `--format`, `-f` | `string` | `table` | Output format: table, json, yaml. |
| `--json` | `boolean` | - | First-class alias for --format json. |
Expand Down
2 changes: 2 additions & 0 deletions k8s/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ Dashboards live in `monitoring/dashboards/`. Its `kustomization.yaml` generates

On a cluster Argo CD manages, its `monitoring` Application applies them; the root kustomization leaves them out, so the `base` Application does not own them as well. Without Argo CD, `devops k8s deploy-stack --stack infra` (or `all`) applies the `monitoring` kustomization, which lists the namespace's perimeter and `dashboards`, right after the root kustomization creates the `monitoring` namespace, and `teardown-stack` removes them with that namespace. Grafana holds these dashboards as provisioned and refuses to save over them, so change the JSON file and deploy again. To provision another dashboard, add it to a generator entry; each ConfigMap must stay under the 262,144 bytes kubectl's last-applied annotation allows.

The AI spend dashboard (`ai-spend.json`) prices local savings in Prometheus. It multiplies the tokens that a local model ran (`devops_cli_ai_tokens_total{local="true"}`) by the recording rule `devops_cli:ai_reference_price_usd_per_token` under `serverFiles.recording_rules.yml` in `monitoring/prometheus-values.yaml`. The rule holds genai-prices' price of the default reference model for each operation and token type, so every process that sends tokens is priced at one reference. `tests/test_k8s_monitoring_dashboards.py` fails when a committed price differs from genai-prices.

The stack dashboards chart the cluster workloads and infrastructure services:

| Dashboard | Exporter / Sources | How Prometheus / Loki gets its series |
Expand Down
Loading
Loading