Install and run Elastic APMedit

To get started using Elastic APM, you need to have:

  • an Elasticsearch cluster and Kibana (version 5.6 or above)
  • a running APM Server process
  • APM agents installed in your applications

For information about setting up an Elasticsearch cluster, see the Elasticsearch Getting Started. To view the collected data, you need Kibana.

The following sections show how to get started quickly with Elastic APM on a local machine.

Install and run APM Serveredit

First, download APM Server for your operating system and extract the package.

In a production environment, you would put APM Server on it’s own machines, similar to how you run Elasticsearch. You can run it on the same machines as Elasticsearch, but this is not recommended, as the processes will be competing for resources.

To start APM Server, run:

./apm-server -e

You should see APM Server start up. It will try to connect to Elasticsearch on localhost port 9200 and expose an API to agents on port 8200. You can change the defaults by supplying a different addresses on the command line:

./apm-server -e -E output.elasticsearch.hosts=ElasticsearchAddress:9200 -E apm-server.host=localhost:8200

Or you can update the apm-server.yml configuration file to change the defaults.

apm-server:
  host: localhost:8200

output:
  elasticsearch:
    hosts: ElasticsearchAddress:9200

Secure access to the APIedit

The HTTP API exposed by APM Server listens on localhost and port 8200 by default. If you change the listen address from localhost to something that is accessible from outside of the machine, we recommend setting up firewall rules to ensure that only your own systems can access the API. Alternatively, you can use the secret token and TLS to secure access to APM Server API.

Install the Kibana dashboardsedit

APM Server comes with predefined Kibana dashboards and index templates for the APM data. To install those run the following command:

./apm-server setup

Due to a bug in Kibana 6.0.0.-rc2 the dashboards don’t work in Kibana 6.0.0-rc2.

If you are using an X-Pack secured version of Elastic Stack, add -E output.elasticsearch.username=user -E output.elasticsearch.password=pass to the command.

See an example screenshot of a Kibana dashboard:

Screenshot of a Kibana Dashboard

More informationFor detailed instructions on how to install and secure APM Server in your server environment, including details on how to run APM Server in a highly available environment, please see APM Server documentation.

Once APM Server is up and running, you need to install an agent in your application.

Install and configure APM agentsedit

Agents are written in the same language as your application. Currently, Elastic APM has agents for Node.js and for Python.

Setting up a new application to be monitored requires installing the agent in the application, coming up with a good app name for the application, and then configuring the agents so they know the address of your APM Server and the app name.

Choose an app nameedit

The app name is used by Elastic APM to differentiate between data coming from different applications and to group data coming from the same applications. When configuring an agent, you need to supply an app name.

Elastic APM includes the app name field on every document that it saves in Elasticsearch. This has the implication that if you change the app name after using Elastic APM for some time, you will see the old app name and the new app name as two separate applications. Make sure you choose a good app name before you get started.

The app name can only contain alphanumeric characters, spaces, underscores, and dashes (must match ^[a-zA-Z0-9 _-]+$).

Install the Node.js agentedit

To install the Node.js agent, simply install the elastic-apm-node module from npm in your application:

npm install elastic-apm-node --save

Then configure the elastic-apm-node module inside your application by adding the following lines to the very top of your application code:

// Add this to the VERY top of the first file loaded in your app
var apm = require('elastic-apm-node').start({
  // Set required app name (allowed characters: a-z, A-Z, 0-9, -, _, and space)
  appName: '',

  // Set custom APM Server URL (default: http://localhost:8200)
  serverUrl: ''
})

The Node.js agent supports Express, hapi, and Koa out of the box. See the APM Node.js Agent documentation for more details.

Install the Python agentedit

To install the Python agent, install the Elastic APM module from pypi:

pip install elastic-apm

The Python agent supports Django and Flask out of the box. See the APM Python Agent documentation for more details.

Set up Kibanaedit

You can use the dashboards that are packaged with APM Server, as mentioned above.