使用 Elastic 技术栈构建 K8S 全栈监控 -4: 使用 Elastic APM 实时监控应用性能

2022-11-20,,,,

文章转载自:https://www.qikqiak.com/post/k8s-monitor-use-elastic-stack-4/

操作步骤

apm-servver连接es使用上一步创建的secret:beats-elasticsearch-pw

kubectl apply  -f apm.configmap.yml \
-f apm.service.yml \
-f apm.deployment.yml kubectl get pods -n elastic -l app=apm-server 在示例应用程序 spring-boot-simple 上配置一个 Elastic APM Java agent 下载地址:https://repo1.maven.org/maven2/co/elastic/apm/elastic-apm-agent/1.32.0/elastic-apm-agent-1.32.0.jar 完整的 Dockerfile 文件 FROM openjdk:8-jdk-alpine
ENV ELASTIC_APM_VERSION "1.8.0"
RUN wget -O /apm-agent.jar https://repo1.maven.org/maven2/co/elastic/apm/elastic-apm-agent/1.32.0/elastic-apm-agent-1.32.0.jar
COPY target/spring-boot-simple.jar /app.jar
CMD java -jar /app.jar 如何构建新的含有文件apm-agent.jar的镜像呢? 原先使用的镜像是:cnych/spring-boot-simple:0.0.1-SNAPSHOT,可以先启动这个,然后从容器中拷贝出jar包,最后根据上面的Dockerfile文件重新构建镜像 但是实际上原先使用的镜像中已经包含文件apm-agent.jar了。因此只需要修改对应的Deployment即可 kubectl apply -f spring-boot-simple.yml kubectl get pods -n elastic -l app=spring-boot-simple kubectl get svc -n elastic -l app=spring-boot-simple 模拟请求 curl -X GET http://192.168.2.163:31398/message curl -X GET http://192.168.2.163:31398/message?sleep=3000 curl -X GET http://192.168.2.163:31398/message?error=true

该步骤用到的yaml文件地址

https://files.cnblogs.com/files/sanduzxcvbnm/elastic-4_yaml.zip?t=1655447911

使用 Elastic 技术栈构建 K8S 全栈监控 -4: 使用 Elastic APM 实时监控应用性能的相关教程结束。

《使用 Elastic 技术栈构建 K8S 全栈监控 -4: 使用 Elastic APM 实时监控应用性能.doc》

下载本文的Word格式文档,以方便收藏与打印。