---
name: axiom-control-costs
description: Analyzes Axiom query patterns to find unused data, then builds dashboards and monitors for cost optimization. Use when asked to reduce Axiom costs, find unused columns or field values, identify data waste, or track ingest spend.
title: axiom-control-costs
canonical_url: https://skilld.dev/gh/axiomhq/skills/axiom-control-costs
last_updated: 2026-11-12T02:16:32.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> Supporting files, fetch one when the Skill refers to it: [README.md](https://skilld.dev/api/skills-raw/axiomhq/skills/axiom-control-costs/README.md), [reference/analysis-report-template.md](https://skilld.dev/api/skills-raw/axiomhq/skills/axiom-control-costs/reference/analysis-report-template.md), [reference/dashboard-panels.md](https://skilld.dev/api/skills-raw/axiomhq/skills/axiom-control-costs/reference/dashboard-panels.md), [reference/monitor-strategy.md](https://skilld.dev/api/skills-raw/axiomhq/skills/axiom-control-costs/reference/monitor-strategy.md), [scripts/analyze-query-coverage](https://skilld.dev/api/skills-raw/axiomhq/skills/axiom-control-costs/scripts/analyze-query-coverage), [scripts/baseline-stats](https://skilld.dev/api/skills-raw/axiomhq/skills/axiom-control-costs/scripts/baseline-stats), [scripts/create-monitors](https://skilld.dev/api/skills-raw/axiomhq/skills/axiom-control-costs/scripts/create-monitors), [scripts/deploy-dashboard](https://skilld.dev/api/skills-raw/axiomhq/skills/axiom-control-costs/scripts/deploy-dashboard), [scripts/lib/ast-parser.jq](https://skilld.dev/api/skills-raw/axiomhq/skills/axiom-control-costs/scripts/lib/ast-parser.jq), [scripts/lib/format-bytes.sh](https://skilld.dev/api/skills-raw/axiomhq/skills/axiom-control-costs/scripts/lib/format-bytes.sh), [scripts/lib/skill-paths.sh](https://skilld.dev/api/skills-raw/axiomhq/skills/axiom-control-costs/scripts/lib/skill-paths.sh), [scripts/list-notifiers](https://skilld.dev/api/skills-raw/axiomhq/skills/axiom-control-costs/scripts/list-notifiers), [scripts/setup](https://skilld.dev/api/skills-raw/axiomhq/skills/axiom-control-costs/scripts/setup), [scripts/test-ast-parser](https://skilld.dev/api/skills-raw/axiomhq/skills/axiom-control-costs/scripts/test-ast-parser), [scripts/test-create-monitors](https://skilld.dev/api/skills-raw/axiomhq/skills/axiom-control-costs/scripts/test-create-monitors), [templates/dashboard.json](https://skilld.dev/api/skills-raw/axiomhq/skills/axiom-control-costs/templates/dashboard.json).
>
> If the user asked to install this Skill, run `npx skilld install axiomhq/skills/axiom-control-costs`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/axiom-control-costs`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/axiomhq/skills/axiom-control-costs) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/axiom-control-costs`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/axiom-control-costs --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/axiom-control-costs --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Axiom Cost Control

Dashboards, monitors, and waste identification for Axiom usage optimization.

## Before You Start

1. Load required skills:
   ```
   skill: axiom-sre
   skill: axiom-build-dashboard
   ```
   
   axiom-build-dashboard provides: `dashboard-list`, `dashboard-get`, `dashboard-create`, `dashboard-update`, `dashboard-delete`

2. Find the audit dataset. Try `axiom-audit` first:
   ```apl
   ['axiom-audit']
   | where _time > ago(1h)
   | summarize count() by action
   | where action in ('usageCalculated', 'runAPLQueryCost')
   ```
   - If not found → ask user. Common names: `axiom-audit-logs-view`, `audit-logs`
   - If found but no `usageCalculated` events → wrong dataset, ask user

3. Verify `axiom-history` access (required for Phase 4):
   ```apl
   ['axiom-history'] | where _time > ago(1h) | take 1
   ```
   If not found, Phase 4 optimization will not work.

4. Confirm with user:
   - Deployment name?
   - Audit dataset name?
   - Contract limit in TB/day? (required for Phase 3 monitors)

5. Replace `<deployment>` and `<audit-dataset>` in all commands below.

**Tips:**
- Run any script with `-h` for full usage
- Do NOT pipe script output to `head` or `tail` — causes SIGPIPE errors
- Requires `jq` for JSON parsing
- Use axiom-sre's `axiom-query` for ad-hoc APL, not direct CLI

## Which Phases to Run

| User request | Run these phases |
|--------------|------------------|
| "reduce costs" / "find waste" | 0 → 1 → 4 |
| "set up cost control" | 0 → 1 → 2 → 3 |
| "deploy dashboard" | 0 → 2 |
| "create monitors" | 0 → 3 |
| "check for drift" | 0 only |

---

## Phase 0: Check Existing Setup

```bash
# Existing dashboard?
dashboard-list <deployment> | grep -i cost

# Existing monitors?
axiom-api <deployment> GET "/v2/monitors" | jq -r '.[] | select(.name | startswith("Cost Control:")) | "\(.id)\t\(.name)"'
```

If found, fetch with `dashboard-get` and compare to `templates/dashboard.json` for drift.

---

## Phase 1: Discovery

```bash
scripts/baseline-stats -d <deployment> -a <audit-dataset>
```

Captures daily ingest stats and produces the **Analysis Queue** (needed for Phase 4).

---

## Phase 2: Dashboard

```bash
scripts/deploy-dashboard -d <deployment> -a <audit-dataset>
```

Creates dashboard with: ingest trends, burn rate, projections, waste candidates, top users. See `reference/dashboard-panels.md` for details.

---

## Phase 3: Monitors

**Contract is required.** You must have the contract limit from preflight step 4.

### Step 1: List available notifiers

```bash
scripts/list-notifiers -d <deployment>
```

Present the list to the user and ask which notifier they want for cost alerts.
If they don't want notifications, proceed without `-n`.

### Step 2: Create monitors

```bash
scripts/create-monitors -d <deployment> -a <audit-dataset> -c <contract_tb> [-n <notifier_id>]
```

Creates 3 monitors:

1. **Total Ingest Guard** — alerts when daily ingest >1.2x contract OR 7-day avg grows >15% vs baseline
2. **Per-Dataset Spike** — robust z-score detection, alerts per dataset with attribution
3. **Query Cost Spike** — hardened z-score with 30d baseline, 5d exclusion gap, persistence-based gating (median_z > 3, p25_z > 2.5)

If Axiom cannot return the monitor list, the script exits before changing anything. If any name starts with `Cost Control:`, the script lists the matches and stops. Use `--force` only to delete all matches and create the three monitors above.

The spike monitors use `notifyByGroup: true` so each dataset triggers a separate alert.

See `reference/monitor-strategy.md` for threshold derivation.

---

## Phase 4: Optimization

### Get the Analysis Queue

Run `scripts/baseline-stats` if not already done. It outputs a prioritized list:

| Priority | Meaning |
|----------|---------|
| P0⛔ | Top 3 by ingest OR >10% of total — MANDATORY |
| P1 | Never queried — strong drop candidate |
| P2 | Rarely queried (Work/GB < 100) — likely waste |

**Work/GB** = query cost (GB·ms) / ingest (GB). Lower = less value from data.

### Analyze datasets in order

Work top-to-bottom. For each dataset:

**Step 1: Column analysis**
```bash
scripts/analyze-query-coverage -d <deployment> -D <dataset> -a <audit-dataset>
```

If 0 queries → recommend DROP, move to next.

**Step 2: Field value analysis**

Pick a field from suggested list (usually `app`, `service`, or `kubernetes.labels.app`):
```bash
scripts/analyze-query-coverage -d <deployment> -D <dataset> -a <audit-dataset> -f <field>
```

Note values with high volume but never queried (⚠️ markers).

**Step 3: Handle empty values**

If `(empty)` has >5% volume, you MUST drill down with alternative field (e.g., `kubernetes.namespace_name`).

**Step 4: Record recommendation**

For each dataset, note: name, ingest volume, Work/GB, top unqueried values, action (DROP/SAMPLE/KEEP), estimated savings.

### Done when

All P0⛔ and P1 datasets analyzed. Then compile report using `reference/analysis-report-template.md`.

---

---

## Cleanup

```bash
# Delete monitors
axiom-api <deployment> GET "/v2/monitors" | jq -r '.[] | select(.name | startswith("Cost Control:")) | "\(.id)\t\(.name)"'
axiom-api <deployment> DELETE "/v2/monitors/<id>"

# Delete dashboard
dashboard-list <deployment> | grep -i cost
dashboard-delete <deployment> <id>
```

---

## Reference

### Audit Dataset Fields

| Field | Description |
|-------|-------------|
| `action` | `usageCalculated` or `runAPLQueryCost` |
| `properties.hourly_ingest_bytes` | Hourly ingest in bytes |
| `properties.hourly_billable_query_gbms` | Hourly query cost |
| `properties.dataset` | Dataset name |
| `resource.id` | Org ID |
| `actor.email` | User email |

### Common Fields for Value Analysis

| Dataset type | Primary field | Alternatives |
|--------------|---------------|--------------|
| Kubernetes logs | `kubernetes.labels.app` | `kubernetes.namespace_name`, `kubernetes.container_name` |
| Application logs | `app` or `service` | `level`, `logger`, `component` |
| Infrastructure | `host` | `region`, `instance` |
| Traces | `service.name` | `span.kind`, `http.route` |

### Units & Conversions

- Scripts use **TB/day**
- Dashboard filter uses **GB/month**

| Contract | TB/day | GB/month |
|----------|--------|----------|
| 5 PB/month | 167 | 5,000,000 |
| 10 PB/month | 333 | 10,000,000 |
| 15 PB/month | 500 | 15,000,000 |

### Optimization Actions

| Signal | Action |
|--------|--------|
| Work/GB = 0 | Drop or stop ingesting |
| High-volume unqueried values | Sample or reduce log level |
| Empty values from system namespaces | Filter at ingest or accept |
| WoW spike | Check recent deploys |
