APM Server binary

edit

This guide will explain how to set up and configure the APM Server binary.

Prerequisites
edit

First, see the Elastic Support Matrix for information about supported operating systems and product compatibility.

You’ll need:

  • Elasticsearch for storing and indexing data.
  • Kibana for visualizing with the Applications UI.

We recommend you use the same version of Elasticsearch, Kibana, and APM Server. See Installing the Elastic Stack for more information about installing these products.

Install Elastic APM yourself
Step 1: Install
edit

Before you begin: If you haven’t installed the Elastic Stack, do that now. See Learn how to install the Elastic Stack on your own hardware.

To download and install APM Server, use the commands below that work with your system. If you use apt or yum, you can install APM Server from our repositories to update to the newest version more easily.

deb:

Version 8.17.0 of APM Server has not yet been released.

RPM:

Version 8.17.0 of APM Server has not yet been released.

Other Linux:

Version 8.17.0 of APM Server has not yet been released.

Mac:

Version 8.17.0 of APM Server has not yet been released.

Windows:

Version 8.17.0 of APM Server has not yet been released.

Docker:

See Running on Docker for deploying Docker containers.

Step 2: Set up and configure
edit

Configure APM by editing the apm-server.yml configuration file. The location of this file varies by platform—​see the Installation layout for help locating it.

A minimal configuration file might look like this:

apm-server:
  host: "localhost:8200" 
output.elasticsearch:
  hosts: ["localhost:9200"] 
  username: "elastic" 
  password: "changeme"

The host:port APM Server listens on.

The Elasticsearch host:port to connect to.

This example uses basic authentication. The user provided here needs the privileges required to publish events to Elasticsearch. To create a dedicated user for this role, see Create a writer role.

All available configuration options are outlined in configuring APM Server.

Step 3: Start
edit

In a production environment, you would put APM Server on its 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

The -e global flag enables logging to stderr and disables syslog/file output. Remove this flag if you’ve enabled logging in the configuration file. For Linux systems, see APM Server status and logs.

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 in apm-server.yml or by supplying a different address on the command line:

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

For Debian package and RPM installations, we recommend the apm-server process runs as a non-root user. Therefore, these installation methods create an apm-server user which you can use to start the process. In addition, APM Server will only start if the configuration file is owned by the user running the process.

To start the APM Server in this case, run:

sudo -u apm-server apm-server [<argument...>]

By default, APM Server loads its configuration file from /etc/apm-server/apm-server.yml. See the deb & rpm default paths for a full directory layout.

Step 4: Install APM agents
edit

Manually set up and configure the agent with the -javaagent JVM option. No application code change is required, but this requires an application restart. See below for more information on this setup method.

1. Download the APM agent

The first step in getting started with the Elastic APM Java agent is to retrieve a copy of the agent JAR. Java agent releases are published to Maven central. In order to get a copy you can either:

  • download the latest agent or previous releases from Maven central.
  • download with curl:

    curl -o 'elastic-apm-agent.jar' -L 'https://oss.sonatype.org/service/local/artifact/maven/redirect?r=releases&g=co.elastic.apm&a=elastic-apm-agent&v=LATEST'

2. Add -javaagent flag

When starting your application, add the JVM flag -javaagent:/path/to/elastic-apm-agent-<version>.jar

3. Configure

Different application servers have different ways of setting the -javaagent flag and system properties. Start your application (for example a Spring Boot application or other embedded servers) and add the -javaagent JVM flag. Use the -D prefix to configure the agent using system properties:

java -javaagent:/path/to/elastic-apm-agent-<version>.jar -Delastic.apm.service_name=my-cool-service -Delastic.apm.application_packages=org.example,org.another.example -Delastic.apm.server_url=http://127.0.0.1:8200 -jar my-application.jar

Refer to Manual setup with -javaagent flag to learn more.

Alternate setup methods

  • Automatic setup with apm-agent-attach-cli.jar
    Automatically set up the agent without needing to alter the configuration of your JVM or application server. This method requires no changes to application code or JVM options, and allows attaching to a running JVM. Refer to the Java agent documentation for more information on this setup method.
  • Programmatic API setup to self-attach
    Set up the agent with a one-line code change and an extra apm-agent-attach dependency. This method requires no changes to JVM options, and the agent artifact is embedded within the packaged application binary. Refer to the Java agent documentation for more information on this setup method.
Step 5: View your data
edit

Once you have at least one APM agent sending data to APM Server, you can start visualizing your data in the Kibana Applications UI.

Applications UI with data
Repositories for APT and YUM
edit

We have repositories available for APT and YUM-based distributions. Note that we provide binary packages, but no source packages.

We use the PGP key D88E42B4, Elasticsearch Signing Key, with fingerprint

4609 5ACC 8548 582C 1A26 99A9 D27D 666C D88E 42B4

to sign all our packages. It is available from https://pgp.mit.edu.

APTedit

Version 8.17.0 of apm-server has not yet been released.

YUMedit

Version 8.17.0 of apm-server has not yet been released.

Run APM Server on Docker
edit

Docker images for APM Server are available from the Elastic Docker registry. The base image is ubuntu:22.04.

A list of all published Docker images and tags is available at www.docker.elastic.co.

These images are free to use under the Elastic license. They contain open source and free commercial features and access to paid commercial features. Start a 30-day trial to try out all of the paid commercial features. See the Subscriptions page for information about Elastic license levels.

Pull the imageedit

Obtaining APM Server for Docker is as simple as issuing a docker pull command against the Elastic Docker registry and then, optionally, verifying the image.

However, version 8.17.0 of APM Server has not yet been released, so no Docker image is currently available for this version.

Configure APM Server on Dockeredit

The Docker image provides several methods for configuring APM Server. The conventional approach is to provide a configuration file via a volume mount, but it’s also possible to create a custom image with your configuration included.

Example configuration fileedit

Download this example configuration file as a starting point:

curl -L -O https://raw.githubusercontent.com/elastic/apm-server/8.x/apm-server.docker.yml
Volume-mounted configurationedit

One way to configure APM Server on Docker is to provide apm-server.docker.yml via a volume mount. With docker run, the volume mount can be specified like this.

docker run -d \
  -p 8200:8200 \
  --name=apm-server \
  --user=apm-server \
  --volume="$(pwd)/apm-server.docker.yml:/usr/share/apm-server/apm-server.yml:ro" \
  docker.elastic.co/apm/apm-server:8.17.0 \
  --strict.perms=false -e \
  -E output.elasticsearch.hosts=["elasticsearch:9200"]  

Substitute your Elasticsearch hosts and ports.

If you are using the hosted Elasticsearch Service in Elastic Cloud, replace the -E output.elasticsearch.hosts line with the Cloud ID and elastic password using the syntax shown earlier.

Customize your configurationedit

The apm-server.docker.yml downloaded earlier should be customized for your environment. See Configure APM Server for more details. Edit the configuration file and customize it to match your environment then re-deploy your APM Server container.

Custom image configurationedit

It’s possible to embed your APM Server configuration in a custom image. Here is an example Dockerfile to achieve this:

FROM docker.elastic.co/apm/apm-server:8.17.0
COPY --chmod=0644 --chown=1000:1000 apm-server.yml /usr/share/apm-server/apm-server.yml