APM-Elastic Stack manual-Alibaba Cloud Developer Community

· For more wonderful content, please download and read the full version of "Elastic Stack practical manual"

join the group of creators, communicate and collide together, and participate in the annual grand event in the technology Circle

created by: Hu Zhengnan reviewer: Yang Zhentao

APM is short for Application Performance Management (Application Performance Management). The main function is to monitor and manage the performance and availability of software applications.

Elastic APM is a free and open performance monitoring system based on Elastic technology stack. It monitors performance metrics of software services and applications in real time, such as request access metrics, access time consumption, database queries, cache calls, and external HTTP requests. Developers can quickly troubleshoot and fix performance problems.

Elastic APM also automatically collects various system exceptions. Developers can identify the time and frequency of system exceptions by tracking the abnormal program stack.

Automatic collection of system metrics is also a very important data source Elastic APM. The collection dimensions include the host level and the service Agent level, such as JVM metrics of applications written in the Java language system and Runtime metrics of the Go language runtime environment.

Elastic APM consists of four components: APM proxy, APM server, Elasticsearch, and Kibana.

Figure 1

APM Agent

APM Agent is an open-source class library written in the same language as the application service. Install the agent as other application services. After the installation is complete, you can use the proxy to collect application metrics and runtime exceptions. The collected data will be cached for a short period of time and then sent to the APM Server.

Supported languages include Go, Java,. NET, Node.js, Python, Ruby, and JavaScript.

APM Server

APM Server is an open source application that collects APM Agent data and can be deployed independently. APM Server makes the proxy lightweight, prevents security risks, and improves the cross-language capability of the Elastic technology stack. The APM Server verifies and processes the data collected by the APM Agent and stores the data in the corresponding Elasticsearch index. After several seconds, the visualized application performance data can be observed through the Kibana APM application.

Elasticsearch

Elasticsearch is a highly scalable full-text search and analysis engine. Used to store, search, and analyze large amounts of data in near real time. In Elastic APM, Elasticsearch is used to store and aggregate performance metrics.

Kibana

Kibana is an open-source data analysis platform that analyzes and visualizes Elasticsearch data. You can retrieve, display, and operate data stored in Elasticsearch.

APM terms

Service

configure APM agent to identify a specific APM agent group as a single service. This is a way to logically identify a group of transactions.

Transaction

the request and response of a service, such as logon api calls. Each call consists of a separate span.

Span

A single event in a transaction, such as method calls, database queries, or cache insertion or retrieval, is any event that takes time to complete.

Erorrs

an exception group with matched exceptions or log messages.

Trace

indicates the entire request process.

The relationship between them can be represented by the following figure:

figure 2

distributed Tracing

when a request flows from one microservice to another, the tracker adds logic to create a unique tracing and identification code. The SPAN id

figure 3

figure 4

figure 5

install and use APM

procedure

to start APM, you can install the APM Server, configure the APM Agent, and configure the visualization panel in Kibana.

Step 1: install the APM Server

  1. mounting

download the appropriate server installation package from the APM server address.

Download Address: https://www.elastic.co/cn/downloads/apm
  1. settings and configurations

pass apm-server setup [FLAGS]you can set the APM server

FLAGS:

-h, --helpview help.

--index-managementConfigure associated Elasticsearch index management, including index templates, lifecycle management policies, and write aliases.

--pipelinesRegistration is defined in ingest/pipeline/definition.jsonin the pipeline.

Configuration example:

apm-server setup --index-management

apm-server setup --pipelines

  1. start

run the following command to start the APM server:

./apm-server -e

specify the output Elasticsearch and APM server

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

step 2: configure the APM Agent

  1. to download an APM agent, you can download the agent Jar package through the Maven Central without introducing dependencies to the project,
download Address: https://search.maven.org/search? q=a:elastic-apm-agent
  1. use the javaagent parameter to start the application and set the corresponding configuration items.

elastic.apm.service_nameService name

elastic.apm.server_urlsis the server request address

elastic.apm.application_packagesproject package path

  1. sample startup parameters:
java -javaagent:/path/to/elastic-apm-agent-<version>.jar \
     -Delastic.apm.service_name=my-application \
     -Delastic.apm.server_urls=http://localhost:8200 \
     -Delastic.apm.secret_token= \
     -Delastic.apm.application_packages=org.example \
     -jar my-application.jar

step 3: view the visualization panel in Kibana

  1. start Kibana
  2. select APM under the Observability (Observability) menu in Kibana, as shown in Figure 1.

Figure 6 select APM from Observability menu

figure 7 service health status view

figure 8 service trace view

Figure 9 service Topology View

Service Map

the Service topology (Service map) function of APM can display the Service topology of the application architecture in real time. Displays how services are connected and service-related metrics, such as transaction processing time, number of requests per minute, and number of errors per minute. The APM service topology can also be combined with machine learning to display the real-time health status based on the score of anomaly detection. The preceding features can help developers quickly and visually observe the status and health of services.

The APM service topology can be displayed in two ways, as shown in the following figure:

  1. global Display: all services with APM clients installed and their connection relationships.
  2. Specify service Display: highlight the connection relationship of the selected service.

Figure 10

the service topology is implemented through out-of-the-box service link tracking. That is, projects that are not configured with the tracing service are not tracked or displayed in the service topology.

Select the service in the service topology to view the details of the service.

Figure 11

machine learning automatically detects transaction call scores and displays them in the service topology.

The exception score is less than 25, and the service is in the healthy state.

Table 1

nodes in the service topology are in two shapes.

Round: The detected service. The Icon depends on the proxy used.

Diamond-shaped: Databases, external systems, and messages. Displays the icons for, such as Elasticsearch icons, based on known entities.

References

  • https://elasticstack.blog.csdn.net/article/details/102844900
creator Profile: Hu Zhengnan, Java development expert of Hangzhou Guangyun technology, with ECE certification and CNCF K8S certification.
Selected, One-Stop Store for Enterprise Applications
Support various scenarios to meet companies' needs at different stages of development

Start Building Today with a Free Trial to 50+ Products

Learn and experience the power of Alibaba Cloud.

Sign Up Now