Automate OpenTelemetry setup for Claude Code to monitor AI usage. Track costs, token usage, and cache efficiency with Prometheus, Loki, and Grafana dashboards. Ideal for operations teams managing AI workloads.
git clone https://github.com/centminmod/claude-code-opentelemetry-setup.gitThis skill automates the setup of a complete observability stack for Claude Code, integrating OpenTelemetry Collector, Prometheus, Loki, and Grafana. It enables real-time tracking of AI usage costs, token consumption by type (input, output, cache creation, cache read), and cache hit rates through pre-built dashboards. The accompanying Claude Code Usage Metrics MCP Server provides 14 tools for querying usage data, including current costs, token breakdowns, cache efficiency, recent prompts, and tool execution logs. Operations teams managing AI workloads benefit from comprehensive monitoring that surfaces performance metrics and cost insights directly within Claude Code.
Deploy the OpenTelemetry Collector, Prometheus, and Loki stack using the repository instructions. Add the Claude Code Usage Metrics MCP Server with the provided claude mcp add command. Access pre-built Grafana dashboards to monitor costs, tokens, cache efficiency, and tool results. Use the 14 MCP tools to query metrics programmatically or execute custom PromQL and LogQL queries.
Monitor daily Claude Code costs and token usage in real-time
Analyze cache efficiency and hit rates to optimize AI model interactions
Track tool execution performance and identify slow or failing operations
Query usage metrics programmatically via MCP tools within Claude Code
No install command available. Check the GitHub repository for manual installation instructions.
git clone https://github.com/centminmod/claude-code-opentelemetry-setupCopy the install command above and run it in your terminal.
Launch Claude Code, Cursor, or your preferred AI coding agent.
Use the prompt template or examples below to test the skill.
Adapt the skill to your specific use case and workflow.
Set up OpenTelemetry for Claude Code to monitor AI usage. Configure tracking for [METRICS] like costs, token usage, and cache efficiency. Integrate with [TOOLS] such as Prometheus, Loki, and Grafana. Provide step-by-step instructions for deployment and dashboard setup.
To set up OpenTelemetry for Claude Code, follow these steps: 1. **Install OpenTelemetry Collector**: Download and install the OpenTelemetry Collector from the official repository. Ensure it is compatible with your operating system. 2. **Configure OpenTelemetry**: Edit the configuration file to include the necessary exporters for Prometheus, Loki, and Grafana. Specify the metrics you want to track, such as costs, token usage, and cache efficiency. 3. **Deploy the Collector**: Start the OpenTelemetry Collector with the configured settings. Verify that it is running correctly by checking the logs. 4. **Set Up Dashboards**: Use Grafana to create dashboards that visualize the data collected by OpenTelemetry. Import pre-built dashboards or create custom ones tailored to your needs. 5. **Monitor and Optimize**: Regularly review the dashboards to monitor AI usage. Use the insights to optimize performance and reduce costs. By following these steps, you can effectively track and manage your AI workloads with OpenTelemetry.
Open source metrics and monitoring for your systems and services
Automate your browser workflows effortlessly
AI assistant built for thoughtful, nuanced conversation
Get more done every day with Microsoft Teams – powered by AI
Agentic AI Workflow platform
Connected workspace for docs, wikis, and projects
Take a free 3-minute scan and get personalized AI skill recommendations.
Take free scan