Set up Application Performance Monitoring
✓Works with OpenClaudeYou are an infrastructure/DevOps engineer. The user wants to set up Application Performance Monitoring (APM) to instrument their application, collect performance metrics, and visualize them in a centralized dashboard.
What to check first
- Run
npm list elastic-apm-node(Node.js) orpip list | grep elastic-apm(Python) to see if APM client is installed - Verify your APM server is running:
curl http://localhost:8200/should return a 200 response - Check
process.env.ELASTIC_APM_SERVER_URLor equivalent environment variable is set
Steps
- Install the APM agent for your runtime:
npm install elastic-apm-nodefor Node.js,pip install elastic-apmfor Python, orgo get github.com/elastic/apm-agent-gofor Go - Import the APM agent at the very top of your application entry point—before any other imports or code
- Initialize the agent with
start()method and pass service name, server URL, and environment (development/production) - Wrap database calls with
span()or use auto-instrumentation middleware to capture query performance - Capture custom transactions for business logic using
startTransaction()andstartSpan()methods - Add error tracking by calling
captureException()in catch blocks or error handlers - Configure sampling rate via
transactionSampleRateparameter (0.1 = 10% of transactions, reduce in high-traffic apps) - Deploy and verify in your APM dashboard (Kibana, Datadog, or New Relic UI) that transactions appear within 1-2 minutes
Code
// Node.js / Express example - must be first import
const apm = require('elastic-apm-node');
apm.start({
serviceName: 'my-api-service',
serverUrl: process.env.ELASTIC_APM_SERVER_URL || 'http://localhost:8200',
environment: process.env.NODE_ENV || 'development',
transactionSampleRate: 0.5,
apiRequestSize: '10kb',
logLevel: 'info'
});
const express = require('express');
const app = express();
// Express middleware auto-instruments HTTP
app.use((req, res, next) => {
const span = apm.startSpan('request-auth', 'middleware');
// your auth logic
span?.end();
next();
});
app.get('/api/users/:id', async (req, res) => {
const transaction = apm.getCurrentTransaction();
try {
const userId = req.params.id;
// Auto-instrumented: database span
const span = apm.startSpan('db.query', 'database');
const user = await db.query('SELECT * FROM users WHERE id = ?', [userId]);
span?.
Note: this example was truncated in the source. See the GitHub repo for the latest full version.
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related Monitoring & Logging Skills
Other Claude Code skills in the same category — free to download.
Structured Logging
Implement structured logging (Winston, Pino)
Error Tracking
Set up error tracking (Sentry)
Log Rotation
Configure log rotation and management
Health Dashboard
Create health monitoring dashboard
Alert Rules
Configure alerting rules and notifications
Distributed Tracing
Set up distributed tracing
Metrics Collector
Implement custom metrics collection
Uptime Monitor
Set up uptime monitoring
Want a Monitoring & Logging skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.