$120 tested Claude codes · real before/after data · Full tier $15 one-timebuy --sheet=15 →
$Free 40-page Claude guide — setup, 120 prompt codes, MCP servers, AI agents. download --free →
clskills.sh — terminal v2.4 — 2,347 skills indexed● online
[CL]Skills_
Monitoring & Loggingintermediate

APM Setup

Share

Set up Application Performance Monitoring

Works with OpenClaude

You 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) or pip 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_URL or equivalent environment variable is set

Steps

  1. Install the APM agent for your runtime: npm install elastic-apm-node for Node.js, pip install elastic-apm for Python, or go get github.com/elastic/apm-agent-go for Go
  2. Import the APM agent at the very top of your application entry point—before any other imports or code
  3. Initialize the agent with start() method and pass service name, server URL, and environment (development/production)
  4. Wrap database calls with span() or use auto-instrumentation middleware to capture query performance
  5. Capture custom transactions for business logic using startTransaction() and startSpan() methods
  6. Add error tracking by calling captureException() in catch blocks or error handlers
  7. Configure sampling rate via transactionSampleRate parameter (0.1 = 10% of transactions, reduce in high-traffic apps)
  8. 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

Quick Info

Difficultyintermediate
Version1.0.0
AuthorClaude Skills Hub
monitoringapmperformance

Install command:

curl -o ~/.claude/skills/apm-setup.md https://claude-skills-hub.vercel.app/skills/monitoring/apm-setup.md

Related Monitoring & Logging Skills

Other Claude Code skills in the same category — free to download.

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.