> For the complete documentation index, see [llms.txt](https://docs.groundcover.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.groundcover.com/integrations/data-sources/ai-tools-observability/claude-code-metrics.md).

# Claude Code Metrics

The metrics groundcover collects from Claude Code via its built-in OpenTelemetry export. Each metric is listed under its exact name: search or query by that name, or link directly to its anchor.

Anthropic's [monitoring reference](https://code.claude.com/docs/en/monitoring-usage) documents these metrics with OTel dot names (for example `claude_code.token.usage`); groundcover stores them in the Prometheus form shown here (dots become underscores, with the unit and `_total` suffixes appended).

**Labels** are the dimensions you can slice these metrics by. Every metric carries the standard set: `session_id`, `organization_id`, `user_id`, `user_email`, `user_account_id`, `user_account_uuid`, `service_name`, `service_version` (the Claude Code version), `os_type`, `os_version`, `host_arch`, `terminal_type`, `claude_deployment_mode`. Metrics with additional labels:

| Label                                                                                   | Description                                                    | On metrics                                           | Example values                                                       |
| --------------------------------------------------------------------------------------- | -------------------------------------------------------------- | ---------------------------------------------------- | -------------------------------------------------------------------- |
| `type`                                                                                  | Breakdown dimension                                            | token usage (token type), lines of code, active time | `input`, `output`, `cacheRead`, `cacheCreation` / `added`, `removed` |
| `model`                                                                                 | Model that served the request                                  | token usage, cost                                    | `claude-sonnet-4-6`                                                  |
| `query_source`                                                                          | Where the request originated                                   | token usage, cost                                    |                                                                      |
| `agent_name`, `skill_name`, `plugin_name`, `mcp_server_name`, `mcp_tool_name`, `effort` | Active subagent / skill / plugin / MCP context when applicable | token usage, cost                                    |                                                                      |
| `start_type`                                                                            | How the session started                                        | session count                                        | `fresh`, `resume`, `continue`                                        |
| `decision`                                                                              | Permission decision                                            | code-edit-tool decisions                             | `accept`, `reject`                                                   |
| `tool_name`                                                                             | Editing tool the decision applies to                           | code-edit-tool decisions                             | `Edit`, `Write`, `NotebookEdit`                                      |
| `language`                                                                              | Language of the edited file                                    | code-edit-tool decisions                             |                                                                      |
| `source`                                                                                | What triggered the decision                                    | code-edit-tool decisions                             |                                                                      |

### claude\_code\_session\_count\_total

Count of CLI sessions started

**Unit:** Number · **Type:** Counter

### claude\_code\_lines\_of\_code\_count\_total

Count of lines of code modified

**Unit:** Number · **Type:** Counter

### claude\_code\_pull\_request\_count\_total

Number of pull requests created

**Unit:** Number · **Type:** Counter

### claude\_code\_commit\_count\_total

Number of git commits created

**Unit:** Number · **Type:** Counter

### claude\_code\_cost\_usage\_USD\_total

Cost of the Claude Code session

**Unit:** $ · **Type:** Counter

### claude\_code\_token\_usage\_tokens\_total

Number of tokens used

**Unit:** Number · **Type:** Counter

### claude\_code\_code\_edit\_tool\_decision\_total

Count of code editing tool permission decisions

**Unit:** Number · **Type:** Counter

### claude\_code\_active\_time\_seconds\_total

Total active time in seconds

**Unit:** Seconds · **Type:** Counter


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.groundcover.com/integrations/data-sources/ai-tools-observability/claude-code-metrics.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
