apm-agent-nodejs is a free, open source monitoring & observability project written in JavaScript and released under BSD-2-Clause. It has 595 GitHub stars, 244 forks and 361 open issues, and was last pushed 25 hours ago. On this registry it ranks #257 of 270 tracked projects in Monitoring & Observability, with 5 head-to-head comparisons available. It gained 1 stars over the last 30 tracked days.

What is apm-agent-nodejs?

Elastic APM Node.js Agent is the official Node.js application performance monitoring agent from Elastic, a package that runs with a Node.js application to automatically capture errors, tracing data, and performance metrics and send them to an Elastic Observability deployment.

What it is

Elastic APM Node.js Agent is the official Node.js agent for the Elastic Observability solution, distributed as the elastic-apm-node package and licensed under BSD-2-Clause. It runs alongside an application, automatically capturing errors, tracing data, and performance metrics, and sends that APM data to an Elastic Observability deployment — either hosted in Elastic's cloud or running on premises. It lives in the Node.js and npm ecosystem, and its data lands in the Elastic Stack: APM Server receives the APM data from the agent, Elasticsearch stores it, and Kibana provides the interface used to visualise and analyse it, monitor the application, and create alerts.

The concrete problem it solves is manual instrumentation. Without an agent, a team writes its own code to catch errors, time requests, and record performance figures, then ships that data somewhere it can be queried. This package replaces that hand-rolled work: it is installed as a dependency and started from the application, after which automatic instrumentation of popular modules produces tracing and metrics without per-route instrumentation code. It also serves root-cause work, since captured traces and errors are what a team reviews to identify the cause of service issues quickly. In this registry it sits under Infrastructure & Operations, Monitoring & Observability.

Key capabilities

  • Published on npm as elastic-apm-node; install with npm install --save elastic-apm-node.
  • Started through require('elastic-apm-node').start({...}), and must be started before the application imports its other dependencies for automatic instrumentation of popular modules to work.
  • Configured with keys including serverUrl, secretToken, and apiKey, plus serviceName and environment.
  • Documents alternative start paths that avoid changing application code, and covers gotchas with transpilers and bundlers such as Babel, esbuild, and Webpack.
  • Ships framework and platform guides for Express, Fastify, Koa, hapi, AWS Lambda, Azure Functions, and TypeScript.
  • Supports ECMAScript modules on an experimental basis, documented separately from the standard setup.
  • Feeds APM Server, which passes data to Elasticsearch for storage and Kibana for exploration.

Who uses it and how

  • Node.js service teams running Express, Fastify, Koa, or hapi, who follow the per-framework "Get started" guide to wire the agent into an existing application.
  • Serverless teams on AWS Lambda or Azure Functions, which have dedicated setup documentation.
  • TypeScript codebases and projects built through transpilers or bundlers, which depend on the documented start-order guidance.
  • Teams already operating an Elastic Stack deployment, on Elastic's cloud or on premises, who supply that deployment's serverUrl and secretToken or configured apiKey.
  • Teams working on distributed tracing, error monitoring, and performance metrics, the agent's declared topics.

Getting started

Install with npm install --save elastic-apm-node, then start the agent at the very top of the main application file with require('elastic-apm-node').start({...}). An Elastic Stack deployment — APM Server, Elasticsearch, and Kibana — is a prerequisite, and the quick start guide covers creating one; the agent needs the deployment's serverUrl and a secretToken or configured apiKey.

How it compares

No similar tool and no list of paid products it replaces appears in the registry facts for this entry, so it stands alone in this registry. The facts do establish one axis of choice: APM data goes to an Elastic Observability deployment, hosted in Elastic's cloud or run on premises, so its value is tied to operating or subscribing to that stack rather than to an independent backend.

When to use it — and when not to

A self-hoster must operate the full Elastic Stack alongside the application: APM Server to receive APM data, Elasticsearch as the database storing all APM data, and Kibana as the interface. Teams that do not run Elastic Observability, or that want an agent reporting elsewhere, should look at other options, and anyone who cannot start the agent before other imports loses the automatic instrumentation. Two facts warrant caution: ECMAScript module support is described as experimental, and the repository carries 361 open issues against 594 stars, so expect a busy issue tracker.

project readme (upstream, from github) — read inline

Elastic APM Node.js Agent

This is the official Node.js application performance monitoring (APM) agent for the Elastic Observability solution. It is a Node.js package that runs with your Node.js application to automatically capture errors, tracing data, and performance metrics. APM data is sent to your Elastic Observability deployment -- hosted in Elastic's cloud or in your own on-premises deployment -- where you can monitor your application, create alerts, and quick identify root causes of service issues.

If you have any feedback or questions, please post them on the Discuss forum.

npm tests

Installation

npm install --save elastic-apm-node

Getting started

First, you will need an Elastic Stack deployment. This is a deployment of APM Server (which receives APM data from the APM agent running in your application), Elasticsearch (the database that stores all APM data), and Kibana (the application that provides the interface to visualize and analyze the data). If you do not already have an Elastic deployment to use, follow this APM Quick Start guide to create a free trial on Elastic's cloud. From this deployment you will need the APM serverUrl and secretToken (or a configured apiKey) to use for configuring the APM agent.

Next, the best and easiest way to see how to install and start the APM agent is to follow one of the "Get started" guides for the web framework or technology that you are using:

Typically, the quick start steps are:

  1. Install the APM agent package as a dependency:

    npm install --save elastic-apm-node
    
  2. Configure and start the APM agent. For the APM agent's automatic instrumentation of popular modules to work, it must be started before your application imports its other dependencies. For example, if you use CommonJS, then put this at the very top of your main application file:

    require('elastic-apm-node').start({
        serverUrl: '',
        secretToken: ''
        serviceName: '...', // https://www.elastic.co/guide/en/apm/agent/nodejs/current/configuration.html#service-name
        environment: '...', // https://www.elastic.co/guide/en/apm/agent/nodejs/current/configuration.html#environment
    });
    

There are other ways to start the APM agent: for example, to support starting the APM agent without having to change application code; or to avoid certain surprises when using TypeScript or other transpilers like Babel or esbuild. See Starting the agent for a reference of all ways to start the agent and for details on gotchas with transpilers and bundlers (like Webpack and esbuild).

If your application is using ES modules, please see ECMAScript module support for the current experimental support.

Documentation

The full Node.js APM agent documentation is here. Some important links:

  • Release notes
  • Supported Technologies describes the supported Node.js versions, which modules (and version ranges) are automatically traced, and other technologies.
  • Configuring the agent describes the different ways to configure the APM agent (via options to apm.start(...), environment variables, or other mechanisms).
  • Configuration options is a full configuration reference.
  • Troubleshooting describes some common issues and a way to get debugging output from the APM agent for bug reports.
  • Upgrading includes a guide for upgrading from each past major version of the APM agent.
  • Metrics describes the metrics that the APM agent automatically collects.
  • The APM agent includes an OpenTelemetry Bridge that allows one to use the vendor-agnostic OpenTelemetry API for manual instrumentation in your application, should you require manual instrumentation.

Active release branches

The following git branches are active:

Contributing

Contributions are very welcome. You can get in touch with us through our Discuss forum. If you have found an issue, you can open an issue at .

If you are considering contributing code to the APM agent, please read our contribution guide.

Please see TESTING.md for instructions on how to run the test suite.

License

BSD-2-Clause


Made with ♥️ by Elastic and our community.

Frequently asked questions

Is apm-agent-nodejs free to use?

apm-agent-nodejs is open source under the BSD-2-Clause licence. There is no licence fee and no seat count — you can self-host it or, where the project offers one, pay a vendor for a managed version instead.

What does apm-agent-nodejs do?

apm-agent-nodejs is an open source project.

What is apm-agent-nodejs written in?

apm-agent-nodejs is primarily written in JavaScript. Its source is publicly available at https://github.com/elastic/apm-agent-nodejs, and it has 595 GitHub stars.