Plugins
ApplicationCommunity
Claude Code Stats logo

Claude Code Stats

timurdigital

Get plugin

Introduction

These docs take you from an installed plugin to a working team usage dashboard. Start with the setup on this page, which gets Claude Code telemetry into Grafana. Then read Configure to match the app to how your metrics arrive, and Features for what each tab shows.

Before you begin

Before you set up the app, ensure you have:

  • Grafana permissions: The Organization administrator role. Only organization administrators can enable and configure apps.
  • Grafana version: Grafana 13.2.0 or later.
  • A Prometheus-compatible data source: The app queries Claude Code metrics with PromQL. Grafana Cloud stacks include a Prometheus (Mimir) data source by default. Self-hosted setups can use Prometheus.
  • Claude Code with telemetry enabled: Each team member's Claude Code must export OpenTelemetry metrics, as described in Connect your data.
  • For the event-based views, a Loki data source: The Prompts, Workflow, Reliability and Security tabs and the tool performance panels on the Tools tab read Claude Code events from Loki. Grafana Cloud stacks include a Loki data source by default. For details, refer to Send events to Loki.
  • For the Traces tab, a Tempo data source: The Traces tab reads Claude Code traces from Tempo. Grafana Cloud stacks include a Tempo data source by default. For details, refer to Send traces to Tempo.

Enable the app

To enable Claude Code Stats:

  1. Click Administration > Plugins and data > Plugins in the left-side menu.
  2. Enter Claude Code Stats in the search bar.
  3. Select Claude Code Stats.
  4. Click Enable.

After you enable the app, refer to Configure for its settings.

Connect your data

Claude Code exports usage metrics over OpenTelemetry (OTLP). Choose the path that matches your setup, then set the same Metric format in the app, as described in Configure.

Send metrics directly to Grafana Cloud

To send metrics straight to the Grafana Cloud OTLP endpoint:

  1. Open your Grafana Cloud portal (opens in new tab), select your stack and click Configure in the OpenTelemetry tile.

  2. Click Generate API Token and copy the OTLP endpoint and the generated OTEL_EXPORTER_OTLP_HEADERS value. The part after Basic is the Base64 encoding of your instance ID and token, <instance-id>:<token>, not the token alone.

  3. Add these variables to each team member's shell profile, such as ~/.zshrc or ~/.bashrc:

    export CLAUDE_CODE_ENABLE_TELEMETRY=1
    export OTEL_METRICS_EXPORTER=otlp
    export OTEL_EXPORTER_OTLP_PROTOCOL="http/protobuf"
    export OTEL_EXPORTER_OTLP_ENDPOINT="https://otlp-gateway-prod-<region>.grafana.net/otlp"
    export OTEL_EXPORTER_OTLP_HEADERS="Authorization=Basic <base64-of-instance-id:token>"
    # Grafana Cloud (Mimir) needs cumulative temporality
    export OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE=cumulative
    
  4. Reload the shell and restart Claude Code.

  5. In the app's configuration, set Ingestion path to Direct OTLP.

The configuration page's Setup Guide tab builds this script for you from your endpoint, token and the features you pick. For details, refer to Setup Guide.

Send metrics through an OpenTelemetry Collector to Prometheus

To send metrics to a self-hosted OpenTelemetry Collector that writes to Prometheus:

  1. Add these variables to each team member's shell profile:

    export CLAUDE_CODE_ENABLE_TELEMETRY=1
    export OTEL_METRICS_EXPORTER=otlp
    export OTEL_EXPORTER_OTLP_PROTOCOL="http/protobuf"
    export OTEL_EXPORTER_OTLP_ENDPOINT="http://<collector-host>:4318"
    
  2. In the Collector, receive OTLP, convert delta temporality to cumulative with the deltatocumulative processor and export with prometheusremotewrite.

  3. Reload the shell and restart Claude Code.

  4. In the app's configuration, keep Ingestion path set to Prometheus / OTEL Collector, which is the default.

Check that data arrives

Claude Code exports metrics every 60 seconds by default. Use Claude Code for a few minutes, then open Explore, select your Prometheus data source and query the cost metric:

Ingestion pathQuery
Direct OTLPclaude_code_cost_usage
Prometheus / OTEL Collectorclaude_code_cost_usage_USD_total

When the query returns series, open the app. If it returns nothing, refer to Troubleshooting.

Send events to Loki

The Prompts, Workflow, Reliability and Security tabs and the tool performance panels on the Tools tab read the events Claude Code sends as OpenTelemetry logs, such as prompts, API requests and errors, refusals, tool results, subagents, hooks, permission changes and logins. To send them:

  1. Add this variable to each team member's shell profile, next to the ones above:

    export OTEL_LOGS_EXPORTER=otlp
    

    Events go to the same OTLP endpoint as the metrics.

  2. Get the events into Loki:

    • Grafana Cloud: The OTLP gateway sends logs to your stack's Loki. No other change is needed.
    • OpenTelemetry Collector: Add a logs pipeline that exports to Loki's OTLP endpoint, such as http://<loki-host>:3100/otlp, with the otlp_http exporter.
  3. Restart Claude Code.

The app expects Loki's native OTLP ingestion, which stores service.name as the service_name label and the event attributes as structured metadata. On the Prompts, Workflow, Reliability, Security and Tools tabs, pick the Loki data source in Events.

Send traces to Tempo

The Traces tab reads the traces Claude Code sends, which link each prompt to its model requests and tool calls. Tracing is a beta feature of Claude Code. To send traces:

  1. Add these variables to each team member's shell profile, next to the ones above:

    export CLAUDE_CODE_ENHANCED_TELEMETRY_BETA=1
    export OTEL_TRACES_EXPORTER=otlp
    

    Traces go to the same OTLP endpoint as the metrics.

  2. Get the traces into Tempo:

    • Grafana Cloud: The OTLP gateway sends traces to your stack's Tempo. No other change is needed.
    • OpenTelemetry Collector: Add a traces pipeline that exports to Tempo's OTLP endpoint, such as <tempo-host>:4317, with the otlp_grpc exporter.
  3. Restart Claude Code.

On the Traces tab, pick the Tempo data source in Traces.

Optional telemetry settings

Some panels need an extra Claude Code setting or a minimum Claude Code version. Set the variables in each team member's shell profile, next to the ones above, and restart Claude Code.

FeatureRequires
Every panelCLAUDE_CODE_ENABLE_TELEMETRY=1, OTEL_METRICS_EXPORTER=otlp, OTEL_EXPORTER_OTLP_PROTOCOL and OTEL_EXPORTER_OTLP_ENDPOINT, as in Connect your data. OTEL_EXPORTER_OTLP_PROTOCOL has no default: without it, Claude Code exports nothing.
Real names in Cost by Subagent, Cost by Skill, Cost by MCP Server, Cost by Plugin, Cost by MCP Tool and their token equivalentsOTEL_LOG_TOOL_DETAILS=1, Claude Code v2.1.273 or later. Without it, user-defined subagents, third-party skills and plugins, and user-configured MCP servers and their tools appear as custom or third-party.
Repository filter, Cost by Repository and Tokens by RepositoryOTEL_METRICS_INCLUDE_REPOSITORY=true, Claude Code v2.1.269 or later. For details, refer to Filter by repository.
Your own filters, such as team or cost centerThe attribute in OTEL_RESOURCE_ATTRIBUTES, and the label under Filters. For details, refer to Filter by your own attributes.
Readable names for team members who use an API key, Amazon Bedrock, Google Cloud or Microsoft Foundryenduser.id in OTEL_RESOURCE_ATTRIBUTES. For details, refer to Name team members who don't sign in with a Claude account.
The Prompts, Workflow, Reliability and Security tabs and the tool performance panels on the Tools tabOTEL_LOGS_EXPORTER=otlp and a Loki data source. For details, refer to Send events to Loki.
The Traces tabCLAUDE_CODE_ENHANCED_TELEMETRY_BETA=1, OTEL_TRACES_EXPORTER=otlp and a Tempo data source. For details, refer to Send traces to Tempo.
Team filterSessions signed in through a Claude apps gateway. For details, refer to Filter by team.
Surface on the Overview tabOTEL_METRICS_INCLUDE_ENTRYPOINT=true.
Lines of Code by ModelClaude Code v2.1.172 or later. Lines from older versions appear as unknown.

Filter by team

Sessions signed in through a Claude apps gateway carry the team member's identity-provider groups in user.groups. The app then shows a Team filter with one entry per group. Picking a group shows the usage of sessions in that group, including team members who are in several groups. No setting is needed.

The filter lists the first five groups of each session. A group that only ever appears sixth or later in a team member's list of groups isn't offered.

Filter by repository

Set OTEL_METRICS_INCLUDE_REPOSITORY=true (Claude Code v2.1.269 and later) to tag metrics with the Git repository Claude Code works in, taken from its origin remote. The app then shows a Repository filter and the Cost by Repository and Tokens by Repository panels.

Filter by your own attributes

Attributes in OTEL_RESOURCE_ATTRIBUTES, such as team.id=platform or cost_center=eng-42, reach Prometheus as labels on every metric, with dots turned into underscores. To filter by one, add it under Filters on the configuration page.

Name team members who don't sign in with a Claude account

The app names each team member by the email address of their Claude account. Sessions that use an API key, Amazon Bedrock, Google Cloud or Microsoft Foundry don't send an email, so the app falls back to the anonymous ID Claude Code generates for each machine, a long random string. To show a readable name instead, set enduser.id in each team member's shell profile:

export OTEL_RESOURCE_ATTRIBUTES="enduser.id=jdoe@example.com"

If OTEL_RESOURCE_ATTRIBUTES is already set, add enduser.id=... to it, separated by a comma. An email address from a Claude account takes precedence over enduser.id.

For every Claude Code telemetry setting, refer to Monitoring usage (opens in new tab) in the Claude Code docs.

Common tasks

Insights

  • Adoption

    Running on 816 active Grafana instances.

  • Activity

    Last updated 20 Nov 2026.

    3 releases in the past year.

Version
2.0.2
Dependencies
  • Grafana >=13.2.0
Developer
timurdigital

Grafana Cloud

Connect any plugin in Grafana Cloud.

  • 150+ data source integrations
  • Grafana Assistant - AI that correlates your data, builds queries, and answers questions
  • 10k Prometheus metrics + 50 GB logs, traces, and profiles on the free tier
  • ...and more
Create free account