All Products
Search
Document Center

Elasticsearch:Use a self-managed APM server to collect data to Alibaba Cloud Elasticsearch

Last Updated:Aug 19, 2026

You can integrate the application performance monitoring (APM) service provided by open source Elasticsearch with Alibaba Cloud Elasticsearch to build an APM system, which helps achieve observability of services and applications. This topic describes how to use a self-managed APM server to collect data to Alibaba Cloud Elasticsearch.

Background information

Observability is measuring your infrastructure, platforms, and applications to understand their state. Unlike traditional monitoring, which focuses on detecting and alerting on known issues, observability aims to provide explanations for everything that happens within a complex distributed system. While monitoring focuses on service health during and after software delivery, observability covers the entire development and operations lifecycle.

The three pillars of observability are logs, infrastructure metrics, and application performance monitoring (APM). APM bridges the gap between metrics and logs. While logs and metrics cover broad infrastructure and components, APM focuses on the application layer. It allows IT and development teams to monitor their application stack, including the end-user experience. By adding APM to your system, you can:

  • Understand where your services spend time and why they crash.

  • Visualize service interactions and identify bottlenecks.

  • Proactively discover and fix performance issues and errors.

  • Increase the productivity of your development teams.

  • Track the end-user experience in the browser.

APM is commonly used in the following scenarios:

  • User experience monitoring: Improve user experience by monitoring user behavior, such as interactions with a web interface or client, and recording the timing of these events.

  • Runtime application architecture: Understand service dependencies and the network topology of application interactions within your architecture.

  • Business transaction monitoring: Generate meaningful SLA reports and provide trend information on application performance from a business perspective.

  • Deep-dive component monitoring: Install an agent to monitor middle-tier components such as web servers, application servers, and message queues. Robust monitoring provides a clear path of code execution, a dimension often combined with runtime architecture in APM products.

  • Analytics and reporting: Standardize and present the metrics collected from applications into a unified view of application performance data.

Prerequisites

  • You have created an Alibaba Cloud Elasticsearch V7.10 instance. For more information, see Create an Alibaba Cloud Elasticsearch instance.

    Note

    We recommend enabling Indexing Service and Openstore to support cost-effective, high-volume data ingestion and storage for application performance monitoring.

  • You have created an Alibaba Cloud ECS instance that runs a Linux operating system. For more information, see Create an instance by using the custom launch wizard.

  • You have installed the Go language environment on the ECS instance.

    Note

    This topic uses the APM agent for Go, which requires the Go language environment.

Procedure

  1. Step 1: Set up the APM Server

  2. Step 2: Configure the APM agent

  3. Step 3: View and analyze data in Kibana

Step 1: Build an APM server

  1. Connect to the ECS instance.

    For more information, see Log on to a Linux instance by using Workbench.

    Note

    The operations in this topic are performed using a regular user account.

  2. Install an APM server.

    1. Download the installation package of an APM server.

      wget https://artifacts.elastic.co/downloads/apm-server/apm-server-7.10.2-linux-x86_64.tar.gz
    2. Decompress the installation package.

      tar -zxf apm-server-7.10.2-linux-x86_64.tar.gz
  3. Modify the configurations of the APM server.

    1. Go to the directory in which the APM server is installed.

      cd apm-server-7.10.2-linux-x86_64/
    2. Modify the YML configuration file.

      vim apm-server.yml

      Modify the YML file as shown in the following example.

      apm-server:
        host: "0.0.0.0:8200"
      output.elasticsearch:
        hosts: ["es-cn-*****.elasticsearch.aliyuncs.com:9200"]
        username: "elastic"
        password: "[pwd]"

      Parameter

      Description

      apm-server

      The endpoint for the APM Server. The host value must be set to the listening IP address:port of the APM Server. In this example, it is set to 0.0.0.0:8200.

      output.elasticsearch

      The Elasticsearch output configuration.

  4. Start the APM server.

    sudo nohup ./apm-server -e > apmserver.log 2>&1 &

Step 2: Configure an APM agent

This topic uses Go as an example.

  1. Install an APM agent.

    1. Initialize the go.mod file.

      sudo go mod init demo
    2. Install an APM Go agent package.

      sudo go get go.elastic.co/apm
      sudo go get go.elastic.co/apm/module/apmhttp
      Note

      A golang.org xxxx: i/o timeout error indicates that golang.org is inaccessible. To resolve this, change the download source.

  2. Configure the APM agent.

    1. Open the configuration file for environment variables.

      vim ~/.bash_profile
    2. In the configuration file, add the following settings to initialize the APM agent. Then, save the modifications.

      # Set the service name. Allowed characters: a-z, A-Z, 0-9, -, _, and space.
      # If ELASTIC_APM_SERVICE_NAME is not set, the executable's file name is used.
      export ELASTIC_APM_SERVICE_NAME=zijian
      
      # Set a custom APM Server URL (default: http://localhost:8200).
      export ELASTIC_APM_SERVER_URL=
      
      # Use a secret token if required by the APM Server.
      export ELASTIC_APM_SECRET_TOKEN=
    3. Run the following command to make the configuration file take effect:

      source ~/.bash_profile
  3. Use the APM agent to detect an application.

    1. Create a sample application file named apm.go.

      vim apm.go
    2. Add the following information to the apm.go file and save the file.

      To instrument your Go application, use one of the provided instrumentation modules or the tracer API.

      package main
      
        import (
          "net/http"
      
          "go.elastic.co/apm/module/apmhttp"
        )
      
        func main() {
          mux := http.NewServeMux()
          http.ListenAndServe(":8080", apmhttp.Wrap(mux))
        }
    3. Run the apm.go file.

      sudo go run apm.go

Step 3: View and analyze data that is collected by the APM server in the Kibana console

  1. Log on to the Kibana console of the Elasticsearch cluster.

    For more information, see Log on to the Kibana console.

    Note

    This topic uses an Alibaba Cloud Elasticsearch V7.10 instance as an example. The UI and operations may differ for other versions.

  2. On the Kibana homepage, click Dev tools in the upper-right corner.

  3. On the Console tab, run the following script to enable auto-creation of the APM onboarding index.

    Note
    • Alibaba Cloud Elasticsearch enforces specific naming conventions for automatically created indexes. Because the default name for the APM onboarding index does not comply, you must run this command to allow its creation.

    • In the following script, 7.10.2 is the version of the APM Server you installed.

    PUT _cluster/settings
    {
      "persistent": {
        "action.auto_create_index":"+.*,+apm-7.10.2-onboarding-*,-*"
      }
    }
  4. View services that are monitored by APM.

    The APM Services page lists all onboarded services in a table. The table contains the Name, Environment, Avg. response time, Trans. per minute, and Error rate % columns, which show each onboarded service and its performance metrics.

    1. In the upper-left corner, click the Navigation bar icon icon to expand the left-side navigation pane.

    2. In the navigation pane, under Observability, click APM.

    3. The Services tab displays all APM services.

    4. Click the name of a service and view and analyze data related to the service.