Claude Code integration
Enabling Claude Code metrics with Analytics API or OpenTelemetry monitoring
Read more about Swarmia's other AI coding tool integrations and understanding the impact of AI tools.
There are multiple ways to run Claude Code, each with a different set of supported integration options for getting your data into Swarmia. For a quick overview of the options and compatibility, see the table below. You can just go to Settings → AI tools → Claude Code, click "Add new", and Swarmia guides you through the setup.

If you're unsure which authentication method you're using, see How do I know which authentication method I'm using? below.
Claude Console
(API-based billing)
Claude subscription
(Pro, Max, Team, Enterprise)
3rd-party platform
(Amazon Bedrock, Google Vertex AI, Microsoft Foundry, and LiteLLM)
Analytics API
✅ Recommended
❌ Not available
❌ Not available
OpenTelemetry: managed settings in Claude.ai
❌ Not available
✅ Recommended
❌ Not available
OpenTelemetry: managed settings in MDM
✔️ Available
✔️ Available
✅ Recommended (requires user email)
OpenTelemetry: shared project settings
✔️ Available
✔️ Available
❌ Not available
We recommend using Claude Code's default attribution settings for commit and PR messages, since those are used in Swarmia's automatic AI tool detection.
You can enable multiple Claude Code integration options in the same Swarmia workspace. For example, if some developers use Claude Console and others use a Claude Enterprise subscription, you can connect the Analytics API and configure Claude.ai managed OpenTelemetry settings at the same time. Swarmia deduplicates overlapping activity so the same usage is not counted twice.
Analytics API
Create a Claude Code Admin API key (note that these differ from the standard API keys) and copy it to Settings → AI tools → Claude Code in Swarmia. You need to be a Claude organization admin to create Admin API keys. We fetch 30 days of historical activity data upon connection.
The historical enabled users don't include people who had a license but got removed before you connected Claude Code to Swarmia.
OpenTelemetry monitoring
Claude Code’s OpenTelemetry monitoring lets your users send event-level data directly to Swarmia. If you already send Claude Code metrics to another destination, configure an OpenTelemetry Collector to forward them to both destinations instead.
To enable the integration, add the following JSON to all your users' Claude Code settings. There are multiple ways to distribute the settings, which are explained below. See the Claude Code's settings precedence for more information about the priority order of settings.
"OTEL_RESOURCE_ATTRIBUTES": "user.email=developer@example.com"is required only if you're using Claude Code via a 3rd-party platform (Amazon Bedrock, Google Vertex AI, Microsoft Foundry, and LiteLLM) so that Swarmia can match the activity to the right author.Replace
<AUTHORIZATION_TOKEN>with a key you can generate in Settings → AI tools → Claude Code by clicking "Add new" and "Click to reveal".
The OpenTelemetry monitoring option has these limitations:
No historical backfill: Swarmia collects the events in real time, and there's no way to fetch data from the time before you enabled the integration.
No data on idle users: Swarmia receives only usage data, so there's no visibility into people who have a license but are not using it. Consequently, enabled users only include active users.
Below are the different ways to distribute the settings.
Managed settings in Claude.ai
Add the JSON configuration to the Claude.ai managed settings.

Claude Code users will see a warning when you update the managed settings:

Claude Code usage from the Claude Desktop app is included in OpenTelemetry monitoring, but its users must first approve the Claude.ai managed settings in Claude Code CLI. If you're having problems, try re-logging in with the Claude subscription using /login.
Managed settings in MDM
Deploy the JSON configuration via device management (e.g., MDM) to all users, e.g., /Library/Application Support/ClaudeCode/managed-settings.json. Claude Code treats managed settings as the highest-precedence settings scope, so users can't override them with command line arguments, local settings, project settings, or user settings. Read more in Claude Code Docs.
You can find starter templates for Jamf, Iru, Intune, and Group Policy in Anthropic's MDM examples repository.
Shared project settings
Add the JSON configuration in shared project settings files in each repository (.claude/settings.json). The users can override these with their personal settings.
Frequently asked questions
How do I know which authentication method I'm using?
Claude Console:
You pay per API usage
You see activity at platform.claude.com/claude-code
Claude subscription:
You pay a fixed monthly fee per license and also have access to Claude.ai
You see activity at claude.ai/analytics/claude-code
3rd-party platform:
You have one of these environment variables set:
CLAUDE_CODE_USE_BEDROCK(AWS Bedrock)CLAUDE_CODE_USE_VERTEX(Google Vertex AI)CLAUDE_CODE_USE_FOUNDRY(Microsoft Foundry)ANTHROPIC_BASE_URLpointing somewhere other thanhttps://api.anthropic.com(LLM gateway, such as LiteLLM)
Can I use the Analytics API and OpenTelemetry monitoring at the same time?
Yes. You can enable multiple Claude Code integration options in the same Swarmia workspace. For example, if some developers use Claude Console and others use a Claude Enterprise subscription, you can connect the Analytics API and configure Claude.ai managed OpenTelemetry settings at the same time. Swarmia deduplicates overlapping activity so the same usage is not counted twice.
If there's AI cost data from both OpenTelemetry monitoring and the Analytics API for a user on the same day, Swarmia considers only the source that reports a higher spend.
Can I connect multiple Claude Code organizations?
Yes, if you use OpenTelemetry monitoring. Add the right OpenTelemetry configuration for each Claude Code organization or group of users. Swarmia shows OpenTelemetry monitoring only once in Settings → AI tools → Claude Code, even when multiple organizations or configurations send data to Swarmia.
The Analytics API can connect only one Claude organization to Swarmia. If you need data from more than one organization, use OpenTelemetry monitoring for the additional organizations.
Analytics API: Why do you need an admin API key? Isn't that a bit excessive?
We build our integrations with the principle of least privilege, and we'd love to ask for fewer permissions, but the Claude Code Analytics API requires an admin key. The key grants broader admin capabilities over your Anthropic organization than Swarmia uses. Swarmia only uses the read operations listed in our data access documentation, where we also describe the credential's broader scope and Anthropic's audit trail options.
If you don't want to share your admin key with Swarmia, you can use the OpenTelemetry option.
OpenTelemetry monitoring: How long does it take for the data to become visible?
The timestamp in Settings → AI tools → Claude Code → OpenTelemetry monitoring shows the latest event Swarmia has received in real time. The AI tool metrics are calculated from the events once a day, so it can take up to 24 hours for the data to become visible.

OpenTelemetry monitoring: Can I send data to Swarmia and another destination?
Yes. Claude Code can only be configured with one OpenTelemetry endpoint. Use an OpenTelemetry Collector to forward metrics to Swarmia and another destination.
OpenTelemetry monitoring: Do the metrics include the Claude desktop app?
Yes, the desktop and CLI apps share the same settings files, but there are some caveats:
Chat: ❌ Not included
Cowork: ❌ Not included
Code: Depends on how you deploy the managed settings:
Managed settings in Claude.ai: ✔️ Included, if the user has first approved the OpenTelemetry managed settings in the Claude Code CLI. If you're having problems, try re-logging in with the Claude subscription using
/login.Managed Settings in MDM: ✅ Included
Shared project settings: ✅ Included
OpenTelemetry monitoring: What happens if someone uses personal and company logins on the same device?
How Swarmia handles this depends on how you deploy the OpenTelemetry settings:
Managed settings in Claude.ai: Swarmia receives usage only while the person is signed in to the Claude subscription that your organization manages. Usage from a personal Claude subscription isn't sent.
Managed settings in MDM or shared project settings: The settings apply on the device or in the project, rather than to a Claude login. Swarmia receives usage while the settings are active, including usage from a personal login.
Swarmia primarily attributes the usage to email in the OpenTelemetry event, which is normally the email for the active Claude login. Swarmia uses the email configured in OTEL_RESOURCE_ATTRIBUTES (required for 3rd-party platforms like Amazon Bedrock, Google Vertex AI, Microsoft Foundry, and LiteLLM) only if there's no information about the active Claude login email.
This keeps personal and company usage separate. If Swarmia has merged a personal email with the person's company contributor, you can separate the identities in Contributor settings to remove the personal usage from that contributor.
OpenTelemetry monitoring: Why is a certain user not visible in Swarmia?
They can use this prompt in Claude Code to help diagnose problems with their configuration:
To see OpenTelemetry export errors, start an interactive claude --debug session and leave it running for more than 10 minutes (OTEL_METRIC_EXPORT_INTERVAL=600000). Claude Code shows the debug log destination as Debug mode enabled · logging to _____.txt. Look for [3P telemetry] errors. With a Collector, these cover only the connection to the Collector; check its service logs for forwarding errors. ([Anthropic telemetry] lines are Anthropic's own telemetry and don't indicate a problem.)
For more troubleshooting steps, see Claude Code's OpenTelemetry monitoring guide.
Last updated
Was this helpful?