当前位置:网站首页>elk笔记25--快速体验APM
elk笔记25--快速体验APM
2022-07-23 17:15:00 【昕光xg】
1 介绍
Elastic APM是建立在Elastic Stack上的应用程序性能监控系统。它允许用户通过收集关于传入请求、数据库查询、缓存调用、外部HTTP请求等响应时间的详细性能信息,从而实时监控软件服务和应用程序。这使用户定位和修复性能问题变得非常容易。
Elastic APM还会自动收集未处理的错误和异常,这些错误主要基于堆栈跟踪进行分组,因此用户可以在出现新错误时识别它们,并关注特定错误发生的次数。
在调试生产系统时,度量标准是另一个重要的信息来源。Elastic APM agent会自动获取基本的主机级指标和特定的代理相关的指标,比如Java代理中的JVM指标和Go代理中的Go运行时指标。
Elastic APM 包含4个主要部分: APM agents, Elastic APM integration, Elasticsearch, and Kibana , 它们的主要工程架构包括如下两种:
1) 边缘机器上的APM agents 将数据发送到集中托管的APM集成是
2)APM agents和APM集成运行在边缘机器上,并通过集中托管的Elastic agent 进行注册

以上为Elastic APM的主要功能和架构,在了解Elastic APM 主要功能后,本文将从基础开安装 APM server,并通过 python 案例加以展示。
2 安装测试
2.1 安装 APM server
docker pull docker.elastic.co/apm/apm-server:7.15.2
curl -L -O https://raw.githubusercontent.com/elastic/apm-server/7.15/apm-server.docker.yml
docker run -d \
-p 8200:8200 \
--name=apm-server-7.15.2 \
--user=apm-server \
--volume="/home/xg/soft/elk/apm-7.15.2/apm-server.docker.yml:/usr/share/apm-server/apm-server.yml:ro" \
docker.elastic.co/apm/apm-server:7.15.2 \
--strict.perms=false -e \
-E output.elasticsearch.hosts=["es_ip:9200"] -E output.elasticsearch.username="es_user" -E output.elasticsearch.password="es_pwd"
2.2 python测试用例
#!/usr/bin/python3
""" pip3 install elastic-apm[flask] """
import time
from flask import Flask
import requests
import json
from elasticapm.contrib.flask import ElasticAPM
app = Flask(__name__)
app.config['ELASTIC_APM'] = {
'SERVICE_NAME': 'xg-flask-01',
'SECRET_TOKEN': 'not-set',
'SERVER_URL': 'http://localhost:8200'
}
apm = ElasticAPM(app)
@app.route("/")
def hello_world():
ret_dict = {
"main": "/ , Hello. World",
"test_error": "/api/test-error",
"test_wait": "/api/test-wait",
"test_get": "/api/test-get"
}
return json.dumps(ret_dict)
@app.route("/api/test-error")
def test_error():
try:
print(10/0)
except Exception as e:
print(f"error: {
e}")
print(101 + "error")
return json.dumps({
'msg': "test-error"})
def my_wait(ts=1):
time.sleep(ts)
@app.route("/api/test-wait")
def test_wait():
ts = 5
print("wait")
my_wait(ts)
return json.dumps({
'msg': f"wait {
ts}s"})
@app.route("/api/test-get")
def test_get():
r = requests.get(url='http://www.baidu.com')
return json.dumps({
'msg': f"get www.baidu.com, status_code={
r.status_code}"})
if __name__ == "__main__":
app.run(host="0.0.0.0", port=8080)
2.3 kibana APM 展示信息
Services
Traces
Dependencies
Overview
Transactions
Dependencies
Errors
Metrics![[图片]](/img/61/097bdca57b73b76d158f0e24065bf1.png)
3 注意事项
- 看APM官方文档,发现Elastic 的 apm-server 支持将数据写入到 kafka, 因此可以考虑使用其 apm-server 将数据写入 kafka, 然后再进一步将数据导入到 clickhouse或者其它db, 最上层封装自己的 APM 查询前端,那么就可以实现有个人特色的APM了.
优点: 可以直接使用 elastic 的 apm-server 和 agent 接入规范,我们只需要关注用户查询即可
缺点:需要自己实现 APM 的前端,可以参考 elastic 的 apm 功能
Configure the Kafka output
4 说明
测试环境:
elk 7.15.2
apm-server 7.15.2
参考文档:
APM User Guide
Run APM Server on Docker
agent code example
边栏推荐
- mBio | 海洋所孙超岷组在深海原位验证了微生物介导的单质硫形成新通路
- Multithreading [comprehensive study of graphics and text]
- [the whole process of Game Modeling and model production] create the game soldier character with ZBrush
- ZigBee integrated development environment IAR installation
- [attack and defense world web] difficulty four-star 12 point advanced question: cat
- VB connecting access database customization
- C # startup program loses double quotation marks for parameters passed. How to solve it?
- [2020] [paper notes] new terahertz detection - Introduction to terahertz characteristics, various terahertz detectors
- 软件测试岗位就业竞争压力大,985毕业的“打工人“同样存在苦不堪言
- Tcl 语言之Synopsys Tcl篇(3)(数字IC)
猜你喜欢
![Multithreading [comprehensive study of graphics and text]](/img/70/8a1227b2159349cf25a85dff8f9d1c.png)
Multithreading [comprehensive study of graphics and text]

多线程与高并发day11

Deepstream learning notes (II): description of GStreamer and deepstream-test1

1259. Disjoint handshake dynamic programming
![[2022] [paper notes] terahertz quantum well——](/img/05/27e9b6a5b2aebf8aa4604f5992551e.png)
[2022] [paper notes] terahertz quantum well——
![[2020] [paper notes] optically controlled spectral ratio adjustable y based on two-dimensional photonic crystal——](/img/d5/b4c82b2a9b34036e182ea9f1b14618.png)
[2020] [paper notes] optically controlled spectral ratio adjustable y based on two-dimensional photonic crystal——

Navigation component of jetpack compose uses

1259. Programmation dynamique de poignée de main disjointe
![[2020] [paper notes] Based on Rydberg atom——](/img/5c/186cae4e47a236ae4062d15f839196.png)
[2020] [paper notes] Based on Rydberg atom——

Google is improving the skin color performance in all products and practicing the concept of "image fairness"
随机推荐
一、爬虫概念及基本流程
How to realize the digital transformation of the banking industry
日志框架【详解学习】
小鱼送激光雷达啦 | 恰饭即抽奖第一期
Rapid establishment of devstack cloud computing platform
DP问题大合集
Conception de l'interface UART basée sur la FPGA
TODO FIXME BUG TAG FEATURE 等配置
基于FPGA的UART接口设计
Cell array processing
Source code analysis of ThreadPoolExecutor
Time2Vec 的理解与简单实现
FPGA implementation of IIC bus of IIC protocol (II) (single read / write drive)
What does MySQL access port mean_ What is the port number of the database port
【机器学习】吴恩达:终生学习
Fragment
Recognition engine ocropy- & gt; ocropy2-> Ocropus3 summary
integer 和==比较
MEE | 浙大程磊组开发设计与构建合成菌群新方法
Jumpserver administrator account is locked