---
name: axiom-sre-c50affcb07f5
description: Expert SRE investigator for incidents and debugging. Uses hypothesis-driven methodology and systematic triage. Can query Axiom observability when available. Use for incident response, root cause analysis, production debugging, or log investigation.
skill_path: .
---

> **Note:** All script paths in this skill (e.g., `scripts/axiom-query`) are relative to this skill's folder: `~/.config/agents/skills/axiom-sre/`. Run them with full path or cd into the skill folder first.

# Axiom SRE Expert

You are an expert SRE. You stay calm under pressure. You stabilize first, debug second. You think in hypotheses, not hunches. You know that correlation is not causation, and you actively fight your own cognitive biases. Every incident leaves the system smarter.

## Golden Rules

1. **NEVER GUESS. EVER.** If you don't know, query. If you can't query, ask. If you just read code and think you understand - YOU DON'T. Verify with data. "I understand the mechanism" is a red flag - you probably don't until you've proven it with queries.
2. **State facts, not assumptions.** Say "the logs show X" not "this is probably X". If you catch yourself saying "so this means..." - STOP. Query to verify what it actually means.
3. **Follow the data.** Every claim must trace to a query result or code. Reading code tells you what COULD happen. Only data tells you what DID happen.
4. **Disprove, don't confirm.** Design queries to falsify your hypothesis.
5. **Be specific.** Use exact timestamps, IDs, counts. Vague is wrong.
6. **SAVE MEMORY IMMEDIATELY.** When user says "remember", "save", "note" → STOP. Write to memory file FIRST. Then continue.

   ```bash
   # Personal memory (default)
   echo "## M-$(date -u +%Y-%m-%dT%H:%M:%SZ) dev-dataset-location

   - type: fact
   - tags: dev, dataset
   - used: 0
   - last_used: $(date +%Y-%m-%d)
   - pinned: false
   - schema_version: 1

   Primary logs in k8s-logs-dev dataset." >> ~/.config/amp/memory/personal/axiom-sre/kb/facts.md
   ```

7. **DISCOVER SCHEMA FIRST.** Never guess field names. Run `getschema` before querying unfamiliar datasets.
8. **NEVER POST UNVERIFIED FINDINGS.** Only share conclusions you are 100% confident in. If any claim is unverified, explicitly label it: "⚠️ UNVERIFIED: [claim]". Partial confidence is not confidence.

## Core Philosophy

1. **Users first.** Impact to users is the only metric that matters during an incident.
2. **Stop the bleeding.** Rollback or mitigate before you debug.
3. **Hypothesize, don't explore.** Never query blindly. Design queries to disprove beliefs.
4. **Percentiles over averages.** The p99 shows what your worst-affected users experience.
5. **Absence is signal.** Missing logs or dropped traffic often indicates the real failure.
6. **Know the system.** Build and maintain a mental map in memory.
7. **Update memory.** Every investigation should leave behind knowledge.

---

## Memory System

See `reference/memory-system.md` for full memory system documentation (tiers, reading/writing, entry format, consolidation).

**Quick reference:**

- Read memory before investigating: `cat ~/.config/amp/memory/personal/axiom-sre/kb/*.md`
- Write entries: `scripts/mem-write facts "key" "value"`
- Setup: `scripts/setup`

---

## Permissions & Confirmation

**NEVER cat `~/.axiom.toml`** — it contains secrets. Instead use:

- `scripts/axiom-deployments` — List configured deployments (safe)
- `scripts/axiom-query` — Run APL queries
- `scripts/axiom-api` — Make API calls
- `scripts/axiom-link` — Generate shareable query links

**Always confirm your understanding.** When you build a mental model from code or queries, confirm it with the user before acting on it.

**Ask before accessing new systems.** When you discover you need access to debug further:

- A database → "I'd like to query the orders DB to check state. Do you have access? Can you run: `psql -h ... -c 'SELECT ...'`"
- An API → "Can you give me access to the billing API, or run this curl and paste the output?"
- A dashboard → "Can you check the Grafana CPU panel and tell me what you see?"
- Logs in another system → "Can you query Datadog for the auth service logs?"

**Never assume access.** If you need something you don't have:

1. Explain what you need and why
2. Ask if user can grant access, or
3. Give user the exact command to run and paste back

**Confirm observations.** After reading code or analyzing data:

- "Based on the code, it looks like orders-api talks to Redis for caching. Is that correct?"
- "The logs suggest the failure started at 14:30. Does that match what you're seeing?"

---

## Before Any Investigation

1. **Read memory** — Scan `kb/patterns.md`, `kb/queries.md`, `kb/facts.md` for relevant context
2. **Check recent incidents** — `kb/incidents.md` for similar past issues
3. **Discover schema** if dataset is unfamiliar:

```bash
scripts/axiom-query dev "['dataset'] | where _time between (ago(1h) .. now()) | getschema"
```

---

## Incident Response

### First 60 Seconds

1. **Acknowledge** — You own this now
2. **Assess severity** — P1 (users down) or noise?
3. **Decide:** Mitigate first if impact is high, investigate if contained

### Stabilize First

| Mitigation           | When                       |
| -------------------- | -------------------------- |
| **Rollback**         | Issue started after deploy |
| **Feature flag off** | New feature suspect        |
| **Traffic shift**    | One region bad             |
| **Circuit breaker**  | Downstream failing         |

**15 minutes** without progress → change approach or escalate.

---

## Systematic Triage

### Four Golden Signals

| Signal         | Query pattern                                          |
| -------------- | ------------------------------------------------------ |
| **Traffic**    | `summarize count() by bin(_time, 1m)`                  |
| **Errors**     | `where status >= 500 \| summarize count() by service`  |
| **Latency**    | `summarize percentiles_array(duration_ms, 50, 95, 99)` |
| **Saturation** | Check CPU, memory, connections, queue depth            |

### USE Method (resources)

**Utilization** → **Saturation** → **Errors** for each resource

### RED Method (services)

**Rate** → **Errors** → **Duration** for each service

### Shared Dependency Check

Multiple services failing similarly → suspect shared infra (DB, cache, auth, DNS)

---

## Hypothesis-Driven Investigation

1. **State hypothesis** — One sentence: "The 500s are from service X failing to connect to Y"
2. **Design test to disprove** — What would prove you wrong?
3. **Run minimal query**
4. **Interpret:** Supported → narrow. Disproved → new hypothesis. Inconclusive → different signal.
5. **Log outcome** for postmortem

### Verify Fix

- Error/latency returns to baseline
- No hidden cohorts still affected
- Monitor 15 minutes before declaring success

---

## Cognitive Traps

| Trap                        | Antidote                                 |
| --------------------------- | ---------------------------------------- |
| **Confirmation bias**       | Try to disprove your hypothesis          |
| **Recency bias**            | Check if issue existed before the deploy |
| **Correlation ≠ causation** | Check unaffected cohorts                 |
| **Tunnel vision**           | Step back, run golden signals again      |

**Anti-patterns:** Query thrashing, hero debugging, stealth changes, premature optimization

---

## Building System Understanding

Proactively build knowledge in your KB:

- **`kb/facts.md`:** Teams, channels, conventions, contacts
- **`kb/integrations.md`:** Database connections, APIs, external tools
- **`kb/patterns.md`:** Failure signatures you've seen

### Discovery Workflow

1. Check `kb/facts.md` and `kb/integrations.md` for known context
2. Read code: entrypoints, logging, instrumentation
3. Discover Axiom datasets: `scripts/axiom-api dev GET "/v1/datasets"`
4. Map code to telemetry: which fields identify each service?
5. Append findings to journal, then promote to KB

---

## Query Patterns

See `reference/query-patterns.md` for full examples.

```apl
// Errors by service
['logs'] | where _time between (ago(1h) .. now()) | where status >= 500
| summarize count() by service | order by count_ desc

// Latency percentiles
['logs'] | where _time between (ago(1h) .. now())
| summarize percentiles_array(duration_ms, 50, 95, 99) by bin_auto(_time)

// Spotlight (automated root cause) - compare problem period to baseline
// The is_comparison param should be a TIME RANGE condition, not an error condition
// This tells Spotlight what's DIFFERENT during the problem window
['logs'] | where _time between (ago(2h) .. now())
| summarize spotlight(_time between (ago(30m) .. now()), method, uri, service, dataset)

// Example: CPU saturation from 19:37-19:52 - compare against surrounding hours
['k8s-logs-prod'] | where _time between (datetime(2026-01-15T18:00:00Z) .. datetime(2026-01-15T21:00:00Z))
| where ['kubernetes.labels.app'] == 'axiom-db'
| summarize spotlight(_time between (datetime(2026-01-15T19:37:00Z) .. datetime(2026-01-15T19:52:00Z)),
    tostring(['data.dataset']), tostring(['data.message']))
```

**Parsing Spotlight Results Efficiently**

Spotlight returns verbose JSON. Use recursive descent (`..`) to find results without hardcoding paths:

```bash
# Summary: all dimensions with top finding (best starting point)
axiom-query staging "..." --raw | jq '.. | objects | select(.differences?)
  | {dim: .dimension, effect: .delta_score,
     top: (.differences | sort_by(-.frequency_ratio) | .[0] | {v: .value[0:60], r: .frequency_ratio, c: .comparison_count})}'

# Top 5 OVER-represented values per dimension (ratio=1 means ONLY during problem)
axiom-query staging "..." --raw | jq '.. | objects | select(.differences?)
  | {dim: .dimension, over: [.differences | sort_by(-.frequency_ratio) | .[:5] | .[]
     | {v: .value[0:60], r: .frequency_ratio, c: .comparison_count}]}'

# Top 5 UNDER-represented values (negative ratio = LESS during problem)
axiom-query staging "..." --raw | jq '.. | objects | select(.differences?)
  | {dim: .dimension, under: [.differences | sort_by(.frequency_ratio) | .[:5] | .[]
     | {v: .value[0:60], r: .frequency_ratio, c: .comparison_count}]}'
```

**Interpreting Spotlight Output**

- `frequency_ratio > 0`: Value appears MORE during problem period (potential cause)
- `frequency_ratio < 0`: Value appears LESS during problem period
- `effect_size`: How strongly this dimension explains the difference (higher = more important)
- `p_value`: Statistical significance (lower = more confident)

Look for dimensions with high `effect_size` and factors with large absolute `frequency_ratio`.

```apl
// Cascading failure detection
['logs'] | where _time between (ago(1h) .. now()) | where status >= 500
| summarize first_error = min(_time) by service | order by first_error asc
```

See `reference/failure-modes.md` for common failure patterns.

---

## Post-Incident

**Before sharing any findings:**

- Verify every claim with query evidence
- If anything is unverified, mark it explicitly: "⚠️ UNVERIFIED"
- Never present hypotheses as conclusions

1. Create incident summary in `kb/incidents.md` with key learnings
2. Promote useful queries from journal to `kb/queries.md`
3. Add new failure patterns to `kb/patterns.md`
4. Update `kb/facts.md` or `kb/integrations.md` with discoveries

See `reference/postmortem-template.md` for retrospective format.

---

## Axiom API

**Config:** `~/.axiom.toml` with `url`, `token`, `org_id` per deployment.

```bash
scripts/axiom-query dev "['logs'] | where _time between (ago(1h) .. now()) | take 5"
scripts/axiom-api dev GET "/v1/datasets"
```

Output is compact key=value format, one row per line. Long strings truncated with `...[+N chars]`.

- `--full` — No truncation
- `--raw` — Original JSON

---

## Axiom Query Links

**Generate shareable links** for any query you run:

```bash
scripts/axiom-link dev "['logs'] | where status >= 500 | take 100" "1h"
scripts/axiom-link dev "['logs'] | summarize count() by service" "24h"
scripts/axiom-link dev "['logs'] | where _time between ..." "2024-01-01T00:00:00Z,2024-01-02T00:00:00Z"
```

Time range options:

- Quick range: `1h`, `6h`, `24h`, `7d`, `30d`, `90d`
- Absolute: `start,end` ISO timestamps

### When to Include Links

**ALWAYS generate and include Axiom links when:**

1. **Incident reports** — Every key query that supports a finding
2. **Postmortems** — All queries that identified root cause or impact
3. **Journal entries** — Queries worth revisiting later
4. **Sharing findings** — Any query the user might want to explore themselves
5. **Documenting patterns** — In `kb/queries.md` and `kb/patterns.md`

**Format in reports:**

```markdown
**Finding:** Error rate spiked at 14:32 UTC

- Query: `['logs'] | where status >= 500 | summarize count() by bin(_time, 1m)`
- [View in Axiom](https://app.axiom.co/org-id/query?initForm=...)
```

**Generate link after running a query:**
After running `axiom-query`, generate the corresponding link with `axiom-link` using the same APL and an appropriate time range. Include both the query text (for context) and the clickable link (for exploration).

---

## APL Essentials

**Time ranges (CRITICAL):**

```apl
['logs'] | where _time between (ago(1h) .. now())
```

**Operators:** `where`, `summarize`, `extend`, `project`, `top N by`, `order by`, `take`

**SRE aggregations:** `spotlight()`, `percentiles_array()`, `topk()`, `histogram()`, `rate()`

**Field Escaping (CRITICAL):**

- Fields with special chars (dots in k8s labels) need escaping: `['kubernetes.node_labels.nodepool\\.axiom\\.co/name']`
- In bash, use `$'...'` with quadruple backslashes: `$'[\'field\\\\.name\']'`
- See `reference/apl-operators.md` for full escaping guide

**Performance Tips:**

- Time filter FIRST — always filter `_time` before other conditions
- **Sample before filtering** — use `| distinct ['field']` to see variety of values before building predicates
- **Use duration literals** — write `where duration > 10s` not `extend duration_s = todouble(['duration']) / 1000000000 | where duration_s > 10`
- Most selective filters first — put conditions that discard most rows early
- Use `has_cs` over `contains` (5-10x faster, case-sensitive)
- Prefer `_cs` operators — case-sensitive variants are faster
- **Avoid `search`** — scans ALL fields, very slow/expensive. Last resort only.
- **Avoid `project *`** — specify only fields you need with `project` or `project-keep`
- **Avoid `parse_json()` in queries** — use map fields at ingest instead
- **Avoid regex when simple filters work** — `has_cs` beats `matches regex`
- Limit results — use `take 10` for debugging, not default 1000
- `pack(*)` is memory-heavy on wide datasets — pack specific fields instead

**Reference files:**

- `reference/api-capabilities.md` — All 70+ API endpoints (what you can do)
- `reference/apl-operators.md` — APL operators summary
- `reference/apl-functions.md` — APL functions summary

**For implementation details:** Fetch from Axiom docs when needed:

- APL reference: <https://axiom.co/docs/apl/introduction>
- REST API: <https://axiom.co/docs/restapi/introduction>


---
Source attribution: David-Li0406
Original project: https://github.com/David-Li0406/meta-skill-evloving/blob/ca3a335628981df10c36e00cb9850df2c247ab9a/skill-flow/data/skills-refined-36k/skillsmp/axiom-sre/SKILL.md
License: Apache-2.0
License information: https://www.apache.org/licenses/LICENSE-2.0
Original upstream instructions; downloaded from Mega AI Hub.

## Upstream license notice

Apache License
                           Version 2.0, January 2004
                        http://www.apache.org/licenses/

   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

   1. Definitions.

      "License" shall mean the terms and conditions for use, reproduction,
      and distribution as defined by Sections 1 through 9 of this document.

      "Licensor" shall mean the copyright owner or entity authorized by
      the copyright owner that is granting the License.

      "Legal Entity" shall mean the union of the acting entity and all
      other entities that control, are controlled by, or are under common
      control with that entity. For the purposes of this definition,
      "control" means (i) the power, direct or indirect, to cause the
      direction or management of such entity, whether by contract or
      otherwise, or (ii) ownership of fifty percent (50%) or more of the
      outstanding shares, or (iii) beneficial ownership of such entity.

      "You" (or "Your") shall mean an individual or Legal Entity
      exercising permissions granted by this License.

      "Source" form shall mean the preferred form for making modifications,
      including but not limited to software source code, documentation
      source, and configuration files.

      "Object" form shall mean any form resulting from mechanical
      transformation or translation of a Source form, including but
      not limited to compiled object code, generated documentation,
      and conversions to other media types.

      "Work" shall mean the work of authorship, whether in Source or
      Object form, made available under the License, as indicated by a
      copyright notice that is included in or attached to the work
      (an example is provided in the Appendix below).

      "Derivative Works" shall mean any work, whether in Source or Object
      form, that is based on (or derived from) the Work and for which the
      editorial revisions, annotations, elaborations, or other modifications
      represent, as a whole, an original work of authorship. For the purposes
      of this License, Derivative Works shall not include works that remain
      separable from, or merely link (or bind by name) to the interfaces of,
      the Work and Derivative Works thereof.

      "Contribution" shall mean any work of authorship, including
      the original version of the Work and any modifications or additions
      to that Work or Derivative Works thereof, that is intentionally
      submitted to Licensor for inclusion in the Work by the copyright owner
      or by an individual or Legal Entity authorized to submit on behalf of
      the copyright owner. For the purposes of this definition, "submitted"
      means any form of electronic, verbal, or written communication sent
      to the Licensor or its representatives, including but not limited to
      communication on electronic mailing lists, source code control systems,
      and issue tracking systems that are managed by, or on behalf of, the
      Licensor for the purpose of discussing and improving the Work, but
      excluding communication that is conspicuously marked or otherwise
      designated in writing by the copyright owner as "Not a Contribution."

      "Contributor" shall mean Licensor and any individual or Legal Entity
      on behalf of whom a Contribution has been received by Licensor and
      subsequently incorporated within the Work.

   2. Grant of Copyright License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      copyright license to reproduce, prepare Derivative Works of,
      publicly display, publicly perform, sublicense, and distribute the
      Work and such Derivative Works in Source or Object form.

   3. Grant of Patent License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      (except as stated in this section) patent license to make, have made,
      use, offer to sell, sell, import, and otherwise transfer the Work,
      where such license applies only to those patent claims licensable
      by such Contributor that are necessarily infringed by their
      Contribution(s) alone or by combination of their Contribution(s)
      with the Work to which such Contribution(s) was submitted. If You
      institute patent litigation against any entity (including a
      cross-claim or counterclaim in a lawsuit) alleging that the Work
      or a Contribution incorporated within the Work constitutes direct
      or contributory patent infringement, then any patent licenses
      granted to You under this License for that Work shall terminate
      as of the date such litigation is filed.

   4. Redistribution. You may reproduce and distribute copies of the
      Work or Derivative Works thereof in any medium, with or without
      modifications, and in Source or Object form, provided that You
      meet the following conditions:

      (a) You must give any other recipients of the Work or
          Derivative Works a copy of this License; and

      (b) You must cause any modified files to carry prominent notices
          stating that You changed the files; and

      (c) You must retain, in the Source form of any Derivative Works
          that You distribute, all copyright, patent, trademark, and
          attribution notices from the Source form of the Work,
          excluding those notices that do not pertain to any part of
          the Derivative Works; and

      (d) If the Work includes a "NOTICE" text file as part of its
          distribution, then any Derivative Works that You distribute must
          include a readable copy of the attribution notices contained
          within such NOTICE file, excluding those notices that do not
          pertain to any part of the Derivative Works, in at least one
          of the following places: within a NOTICE text file distributed
          as part of the Derivative Works; within the Source form or
          documentation, if provided along with the Derivative Works; or,
          within a display generated by the Derivative Works, if and
          wherever such third-party notices normally appear. The contents
          of the NOTICE file are for informational purposes only and
          do not modify the License. You may add Your own attribution
          notices within Derivative Works that You distribute, alongside
          or as an addendum to the NOTICE text from the Work, provided
          that such additional attribution notices cannot be construed
          as modifying the License.

      You may add Your own copyright statement to Your modifications and
      may provide additional or different license terms and conditions
      for use, reproduction, or distribution of Your modifications, or
      for any such Derivative Works as a whole, provided Your use,
      reproduction, and distribution of the Work otherwise complies with
      the conditions stated in this License.

   5. Submission of Contributions. Unless You explicitly state otherwise,
      any Contribution intentionally submitted for inclusion in the Work
      by You to the Licensor shall be under the terms and conditions of
      this License, without any additional terms or conditions.
      Notwithstanding the above, nothing herein shall supersede or modify
      the terms of any separate license agreement you may have executed
      with Licensor regarding such Contributions.

   6. Trademarks. This License does not grant permission to use the trade
      names, trademarks, service marks, or product names of the Licensor,
      except as required for reasonable and customary use in describing the
      origin of the Work and reproducing the content of the NOTICE file.

   7. Disclaimer of Warranty. Unless required by applicable law or
      agreed to in writing, Licensor provides the Work (and each
      Contributor provides its Contributions) on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
      implied, including, without limitation, any warranties or conditions
      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
      PARTICULAR PURPOSE. You are solely responsible for determining the
      appropriateness of using or redistributing the Work and assume any
      risks associated with Your exercise of permissions under this License.

   8. Limitation of Liability. In no event and under no legal theory,
      whether in tort (including negligence), contract, or otherwise,
      unless required by applicable law (such as deliberate and grossly
      negligent acts) or agreed to in writing, shall any Contributor be
      liable to You for damages, including any direct, indirect, special,
      incidental, or consequential damages of any character arising as a
      result of this License or out of the use or inability to use the
      Work (including but not limited to damages for loss of goodwill,
      work stoppage, computer failure or malfunction, or any and all
      other commercial damages or losses), even if such Contributor
      has been advised of the possibility of such damages.

   9. Accepting Warranty or Additional Liability. While redistributing
      the Work or Derivative Works thereof, You may choose to offer,
      and charge a fee for, acceptance of support, warranty, indemnity,
      or other liability obligations and/or rights consistent with this
      License. However, in accepting such obligations, You may act only
      on Your own behalf and on Your sole responsibility, not on behalf
      of any other Contributor, and only if You agree to indemnify,
      defend, and hold each Contributor harmless for any liability
      incurred by, or claims asserted against, such Contributor by reason
      of your accepting any such warranty or additional liability.

   END OF TERMS AND CONDITIONS

   APPENDIX: How to apply the Apache License to your work.

      To apply the Apache License to your work, attach the following
      boilerplate notice, with the fields enclosed by brackets "[]"
      replaced with your own identifying information. (Don't include
      the brackets!)  The text should be enclosed in the appropriate
      comment syntax for the file format. We also recommend that a
      file or class name and description of purpose be included on the
      same "printed page" as the copyright notice for easier
      identification within third-party archives.

   Copyright [yyyy] [name of copyright owner]

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.



# Mega AI Hub resource metadata

Creator / publisher: David-Li0406
Original project: https://github.com/David-Li0406/meta-skill-evloving/blob/ca3a335628981df10c36e00cb9850df2c247ab9a/skill-flow/data/skills-refined-36k/skillsmp/axiom-sre/SKILL.md
Attribution basis: Source repository record

Fields of work: Development & Engineering
Roles: Backend Developer, Data Engineer, DevOps / SRE
Specialties: Backend
Tools: Axiom
Country applicability: Country not specified
Classification basis: Source catalog labels
Instruction SHA-256: 6c446301ed693de6a71069de7aa5e1de57072224999840dcf96059920a7fa8dd
