|
1 | 1 | # Elastic APM Node.js Agent
|
2 | 2 |
|
3 |
| -This is the official Node.js agent for [Elastic APM](https://www.elastic.co/solutions/apm). |
| 3 | +This is the official Node.js [application performance monitoring](https://www.elastic.co/observability/application-performance-monitoring) |
| 4 | +(APM) agent for the Elastic Observability solution. It is a Node.js package |
| 5 | +that runs with your Node.js application to automatically capture errors, tracing |
| 6 | +data, and performance metrics. APM data is sent to your Elastic Observability |
| 7 | +deployment -- hosted in [Elastic's cloud](https://www.elastic.co/cloud/) or in |
| 8 | +your own on-premises deployment -- where you can monitor your application, |
| 9 | +create alerts, and quick identify root causes of service issues. |
4 | 10 |
|
5 |
| -If you have any feedback or questions, |
6 |
| -please post them on the [Discuss forum](https://discuss.elastic.co/c/apm). |
| 11 | +If you have any feedback or questions, please post them on the |
| 12 | +[Discuss forum](https://discuss.elastic.co/tags/c/apm/nodejs). |
7 | 13 |
|
8 | 14 | [](https://www.npmjs.com/package/elastic-apm-node)
|
9 |
| -[](https://apm-ci.elastic.co/job/apm-agent-nodejs/job/apm-agent-nodejs-mbp/job/3.x/) |
| 15 | +[](https://github.com/elastic/apm-agent-nodejs/actions/workflows/test.yml) |
10 | 16 |
|
11 | 17 |
|
12 | 18 | ## Installation
|
13 | 19 |
|
14 | 20 | ```
|
15 |
| -npm install elastic-apm-node --save |
| 21 | +npm install --save elastic-apm-node |
16 | 22 | ```
|
17 | 23 |
|
18 |
| -## Quick start |
| 24 | +## Getting started |
19 | 25 |
|
20 |
| -1. To run Elastic APM for your own applications, |
21 |
| - make sure you have the prerequisites in place first. |
22 |
| - This agent is compatible with [APM Server](https://github.com/elastic/apm-server) v6.5 and above. |
23 |
| - For support for previous releases of the APM Server, |
24 |
| - use version [1.x](https://github.com/elastic/apm-agent-nodejs/tree/1.x) of the agent. |
25 |
| - For details see [Getting Started with Elastic APM](https://www.elastic.co/guide/en/apm/get-started) |
| 26 | +First, you will need an Elastic Stack deployment. This is a deployment of APM |
| 27 | +Server (which receives APM data from the APM agent running in your application), |
| 28 | +Elasticsearch (the database that stores all APM data), and Kibana (the |
| 29 | +application that provides the interface to visualize and analyze the data). If |
| 30 | +you do not already have an Elastic deployment to use, follow [this APM Quick |
| 31 | +Start guide](https://www.elastic.co/guide/en/apm/guide/current/apm-quick-start.html) |
| 32 | +to create a free trial on Elastic's cloud. From this deployment you will need |
| 33 | +the APM **`serverUrl`** and **`secretToken`** (or a configured `apiKey`) to use |
| 34 | +for configuring the APM agent. |
26 | 35 |
|
27 |
| -1. Now follow the documentation links below relevant to your framework or stack to get set up |
| 36 | +Next, the best and easiest way to see how to install and start the APM agent is to follow |
| 37 | +[one of the "Get started" guides](https://www.elastic.co/guide/en/apm/agent/nodejs/current/set-up.html) |
| 38 | +for the web framework or technology that you are using: |
28 | 39 |
|
29 |
| -## Documentation |
30 |
| - |
31 |
| -- [Table of contents](https://www.elastic.co/guide/en/apm/agent/nodejs) |
32 |
| -- [Introduction](https://www.elastic.co/guide/en/apm/agent/nodejs/current/intro.html) |
33 | 40 | - [Get started with Express](https://www.elastic.co/guide/en/apm/agent/nodejs/current/express.html)
|
34 |
| -- [Get started with hapi](https://www.elastic.co/guide/en/apm/agent/nodejs/current/hapi.html) |
| 41 | +- [Get started with Fastify](https://www.elastic.co/guide/en/apm/agent/nodejs/current/fastify.html) |
35 | 42 | - [Get started with Koa](https://www.elastic.co/guide/en/apm/agent/nodejs/current/koa.html)
|
| 43 | +- [Get started with hapi](https://www.elastic.co/guide/en/apm/agent/nodejs/current/hapi.html) |
36 | 44 | - [Get started with Restify](https://www.elastic.co/guide/en/apm/agent/nodejs/current/restify.html)
|
37 |
| -- [Get started with Fastify](https://www.elastic.co/guide/en/apm/agent/nodejs/current/fastify.html) |
38 |
| -- [Get started with Lambda](https://www.elastic.co/guide/en/apm/agent/nodejs/current/lambda.html) |
39 |
| -- [Get started with a custom Node.js stack](https://www.elastic.co/guide/en/apm/agent/nodejs/current/custom-stack.html) |
40 |
| -- [Advanced Setup and Configuration](https://www.elastic.co/guide/en/apm/agent/nodejs/current/advanced-setup.html) |
41 |
| -- [API Reference](https://www.elastic.co/guide/en/apm/agent/nodejs/current/api.html) |
42 |
| -- [OpenTelemetry Bridge](https://www.elastic.co/guide/en/apm/agent/nodejs/current/opentelemetry-bridge.html) |
43 |
| -- [Custom Transactions](https://www.elastic.co/guide/en/apm/agent/nodejs/current/custom-transactions.html) |
44 |
| -- [Custom Spans](https://www.elastic.co/guide/en/apm/agent/nodejs/current/custom-spans.html) |
45 |
| -- [Metrics](https://www.elastic.co/guide/en/apm/agent/nodejs/current/metrics.html) |
46 |
| -- [Performance Tuning](https://www.elastic.co/guide/en/apm/agent/nodejs/current/performance-tuning.html) |
47 |
| -- [Source Map Support](https://www.elastic.co/guide/en/apm/agent/nodejs/current/source-maps.html) |
48 |
| -- [Supported Technologies](https://www.elastic.co/guide/en/apm/agent/nodejs/current/supported-technologies.html) |
49 |
| -- [Upgrading](https://www.elastic.co/guide/en/apm/agent/nodejs/current/upgrading.html) |
50 |
| -- [Troubleshooting](https://www.elastic.co/guide/en/apm/agent/nodejs/current/troubleshooting.html) |
| 45 | +- [Get started with AWS Lambda](https://www.elastic.co/guide/en/apm/agent/nodejs/current/lambda.html) |
| 46 | +- [Get started with Azure Functions](https://www.elastic.co/guide/en/apm/agent/nodejs/current/azure-functions.html) |
| 47 | +- [Get started with TypeScript](https://www.elastic.co/guide/en/apm/agent/nodejs/current/typescript.html) |
| 48 | + |
| 49 | +Typically, the quick start steps are: |
| 50 | + |
| 51 | +1. Install the APM agent package as a dependency: |
| 52 | + |
| 53 | + ``` |
| 54 | + npm install --save elastic-apm-node |
| 55 | + ``` |
| 56 | +
|
| 57 | +2. Configure and start the APM agent. For the APM agent's automatic |
| 58 | + instrumentation of popular modules to work, it must be started **before your |
| 59 | + application imports its other dependencies**. For example, if you use |
| 60 | + CommonJS, then put this at the *very top* of your main application file: |
| 61 | +
|
| 62 | + ```js |
| 63 | + require('elastic-apm-node').start({ |
| 64 | + serverUrl: '<serverUrl from your Elastic Stack deployment>', |
| 65 | + secretToken: '<secretToken from your Elastic Stack deployment>' |
| 66 | + serviceName: '...', // https://www.elastic.co/guide/en/apm/agent/nodejs/current/configuration.html#service-name |
| 67 | + environment: '...', // https://www.elastic.co/guide/en/apm/agent/nodejs/current/configuration.html#environment |
| 68 | + }); |
| 69 | + ``` |
| 70 | +
|
| 71 | +There are other ways to start the APM agent: for example, to support starting |
| 72 | +the APM agent without having to change application code; or to avoid certain |
| 73 | +surprises when using TypeScript or other transpilers like Babel or esbuild. See |
| 74 | +[Starting the agent](https://www.elastic.co/guide/en/apm/agent/nodejs/current/starting-the-agent.html) |
| 75 | +for a reference of all ways to start the agent and for details on gotchas |
| 76 | +with transpilers and bundlers (like Webpack and esbuild). |
| 77 | +
|
| 78 | +If your application is using ES modules, please see [ECMAScript module support](https://www.elastic.co/guide/en/apm/agent/nodejs/current/esm.html) |
| 79 | +for the current *experimental* support. |
| 80 | +
|
| 81 | +
|
| 82 | +## Documentation |
| 83 | +
|
| 84 | +The full [Node.js APM agent documentation is here](https://www.elastic.co/guide/en/apm/agent/nodejs/current/intro.html). |
| 85 | +Some important links: |
| 86 | +
|
| 87 | +- [Supported Technologies](https://www.elastic.co/guide/en/apm/agent/nodejs/current/supported-technologies.html) describes the supported Node.js versions, which modules (and version ranges) are automatically traced, and other technologies. |
| 88 | +- [Configuring the agent](https://www.elastic.co/guide/en/apm/agent/nodejs/current/configuring-the-agent.html) describes the different ways to configure the APM agent (via options to `apm.start(...)`, environment variables, or other mechanisms). |
| 89 | +- [Configuration options](https://www.elastic.co/guide/en/apm/agent/nodejs/current/configuration.html) is a full configuration reference. |
| 90 | +- [Troubleshooting](https://www.elastic.co/guide/en/apm/agent/nodejs/current/troubleshooting.html) describes some common issues and a way to get debugging output from the APM agent for bug reports. |
| 91 | +- [Upgrading](https://www.elastic.co/guide/en/apm/agent/nodejs/current/upgrading.html) includes a guide for upgrading from each past major version of the APM agent. |
| 92 | +- [Metrics](https://www.elastic.co/guide/en/apm/agent/nodejs/current/metrics.html) describes the metrics that the APM agent automatically collects. |
| 93 | +- The APM agent includes an [OpenTelemetry Bridge](https://www.elastic.co/guide/en/apm/agent/nodejs/current/opentelemetry-bridge.html) that allows one to use the vendor-agnostic OpenTelemetry API for manual instrumentation in your application, should you require manual instrumentation. |
51 | 94 |
|
52 | 95 |
|
53 | 96 | ## Active release branches
|
54 | 97 |
|
55 |
| -Currently the only active release branch is the |
56 |
| -["main" branch](https://github.com/elastic/apm-agent-nodejs/tree/main), which is |
57 |
| -used for 3.x versions. |
| 98 | +The following git branches are active: |
| 99 | +
|
| 100 | +- The ["main" branch](https://github.com/elastic/apm-agent-nodejs/tree/main) is being used for **4.x releases**. |
| 101 | +- The ["3.x" branch](https://github.com/elastic/apm-agent-nodejs/tree/3.x) is being used for **3.x maintenance releases**. The 3.x line will be [supported for 6 months](https://www.elastic.co/support/eol) after the release of v4.0.0. |
58 | 102 |
|
59 | 103 |
|
60 | 104 | ## Contributing
|
61 | 105 |
|
62 |
| -Contributions are welcome, |
63 |
| -but we recommend that you take a moment and read our [contribution guide](CONTRIBUTING.md) first. |
| 106 | +Contributions are very welcome. You can get in touch with us through our |
| 107 | +[Discuss forum](https://discuss.elastic.co/tags/c/apm/nodejs). If you have |
| 108 | +found an issue, you can open an issue at <https://github.com/elastic/apm-agent-nodejs/issues>. |
64 | 109 |
|
65 |
| -To see what data is being sent to the APM Server, |
66 |
| -use the environment variable `ELASTIC_APM_PAYLOAD_LOG_FILE` (or the config option `payloadLogFile`) to specify a log file, |
67 |
| -e.g: |
68 |
| - |
69 |
| -``` |
70 |
| -ELASTIC_APM_PAYLOAD_LOG_FILE=/tmp/payload.ndjson |
71 |
| -``` |
| 110 | +If you are considering contributing code to the APM agent, please read our |
| 111 | +[contribution guide](CONTRIBUTING.md). |
72 | 112 |
|
73 | 113 | Please see [TESTING.md](TESTING.md) for instructions on how to run the test suite.
|
74 | 114 |
|
| 115 | +
|
75 | 116 | ## License
|
76 | 117 |
|
77 | 118 | [BSD-2-Clause](LICENSE)
|
78 | 119 |
|
79 |
| -<br>Made with ♥️ and ☕️ by Elastic and our community. |
| 120 | +<br>Made with ♥️ by Elastic and our community. |
0 commit comments