· 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
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.
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.
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.
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 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.
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.
the request and response of a service, such as logon api calls. Each call consists of a separate 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.
an exception group with matched exceptions or log messages.
indicates the entire request process.
The relationship between them can be represented by the following figure:
when a request flows from one microservice to another, the tracker adds logic to create a unique tracing and identification code. The SPAN id
install and use APM
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
Download Address: https://www.elastic.co/cn/downloads/apm
- settings and configurations
apm-server setup [FLAGS]you can set the APM server
--pipelinesRegistration is defined in
ingest/pipeline/definition.jsonin the pipeline.
apm-server setup --index-management
apm-server setup --pipelines
run the following command to start the APM server:
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
- 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
- use the javaagent parameter to start the application and set the corresponding configuration items.
elastic.apm.server_urlsis the server request address
elastic.apm.application_packagesproject package path
- 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
- start Kibana
- 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
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:
- global Display: all services with APM clients installed and their connection relationships.
- Specify service Display: highlight the connection relationship of the selected service.
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.
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.|
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.
creator Profile: Hu Zhengnan, Java development expert of Hangzhou Guangyun technology, with ECE certification and CNCF K8S certification.