window 10安装和使用Elastic APM Server

本文详细指导了如何下载、安装APM Server,配置Kibana连接、索引设置,以及APMAgent的多种安装方式。包括启动与停止服务,以及解决常见问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

官方文档:https://www.elastic.co/guide/en/apm/server/current/index.html

1、下载APM Server

2、安装APM Server

官方安装教程:https://www.elastic.co/guide/en/apm/server/current/installing.html
# 进入安装目录,管理员权限安装APM Server服务,会开机启动
cd D:\ELK\apm-server-7.15.0
PowerShell.exe -ExecutionPolicy UnRestricted -File .\install-service-apm-server.ps1

Status   Name               DisplayName
------   ----               -----------
Stopped  apm-server         apm-server

3、修改apm-server.yml配置

配置kibana

  #---------------------------- APM Server - Agent Configuration ----------------------------
  # 配置kibana
  kibana:
    enabled: true
    host: "kibana-host:5601"
    username: "elastic"
    password: "123456"
  #---------------------------- APM Server - ILM Index Lifecycle Management ----------------------------
  # 修改默认索引需要关闭ilm
  ilm:
    enabled: false
#================================= Template =================================
# 配置自定义索引模板名称
setup.template.name: "moss-oauth-apm"
setup.template.pattern: "moss-oauth-apm-*"
#-------------------------- Elasticsearch output --------------------------
# 配置es
output.elasticsearch:
  hosts: ["es-node-1-host:9200","es-node-2-host:9200"]
  username: "elastic"
  password: "123456"
  # 根据不同的服务生成不同的索引
  indices:
    - index: "moss-oauth-apm-%{+yyyy.MM.dd}"
      when.contains:
        service.name: "moss-oauth"

4、启动APM Server

默认的日志在:C:\ProgramData\apm-server

# 启动
net start apm-server

# 停止
net stop apm-server

5、安装APM Agent

支持的Agent:https://www.elastic.co/guide/en/apm/server/current/next-steps.html
官方教程:https://www.elastic.co/guide/en/apm/agent/java/1.x/setup.html

有三种安装方式
第一种:使用-javaagent

maven central下载elastic-apm-agent.jar
在这里插入图片描述
在这里插入图片描述
jar包启动的应用(springboot)使用

java -javaagent:d:/elastic-apm-agent-1.26.0.jar -Delastic.apm.service_name=my-cool-service -Delastic.apm.application_packages=org.example,org.another.example -Delastic.apm.server_url=http://localhost:8200 -jar my-application.jar

其它方式,如Tomcat,jetty等,见官方教程

第二种:使用apm-agent-attach-cli.jar自动安装(此安装方法是beta版),不推荐使用

具体操作见官方教程

第三种:代码入侵式的,在应用启动入口main方法中加入ElasticApmAttacher.attach()调用

添加依赖

<dependency>
    <groupId>co.elastic.apm</groupId>
    <artifactId>apm-agent-attach</artifactId>
    <version>${elastic-apm.version}</version>
</dependency>

在应用的配置文件中加入以下配置

service_name=my-cool-service
application_packages=org.example,org.another.example
server_url=http://localhost:8200

在启动入口加入ElasticApmAttacher.attach(),以springboot为例

import co.elastic.apm.attach.ElasticApmAttacher;
import org.springframework.boot.SpringApplication;

@SpringBootApplication
public class MyApplication {
    public static void main(String[] args) {
        # 加上这句
        ElasticApmAttacher.attach();
        SpringApplication.run(MyApplication.class, args);
    }
}

6、启动应用

示例

java -javaagent:d:/elastic-apm-agent-1.26.0.jar -Delastic.apm.service_name=my-cool-service -Delastic.apm.application_packages=org.example,org.another.example -Delastic.apm.server_url=http://localhost:8200 -jar my-application.jar

7、登录kibana查看

生成的索引
在这里插入图片描述

服务
在这里插入图片描述
请求查看
在这里插入图片描述
关联节点
在这里插入图片描述

如果kibana上的APM显示无服务,要做以下配置

点击右上角的【设置】

在这里插入图片描述
点【索引】,因为默认是显示apm开头的索引的,上面更改了索引的名称,所以要在这里加进去
在这里插入图片描述
点【应用更改】就可以看到了

常见错误

APMServ 5.2.6 是一款拥有图形界面的快速搭建Apache 2.2.9、PHP 5.2.6、MySQL 5.1.28&4.0.26、Nginx 0.7.19、Memcached 1.2.4、phpMyAdmin 2.11.9.2、OpenSSL、SQLite、ZendOptimizer,以及ASP、CGI、Perl网站服务器平台的绿色软件。无需安装,具有灵活的移动性,将其拷贝到其它目录、分区或别的电脑时,均只需点击APMServ.exe中的启动按钮,即可自动进行相关设置,将ApacheMySQL安装为系统服务并启动。APMServ集合了Apache稳定安全的优点,并拥有跟IIS一样便捷的图形管理界面,同时支持MySQL 5.0 & 4.0两个版本,虚拟主机、虚拟目录、端口更改、SMTP、上传大小限制、自动全局变量、SSL证书制作、缓存性能优化等设置,只需鼠标一点即可完成。   1、注意事项:APMServ程序所在路径不能含有汉字空格。   2、MySQL默认用户名:root,密码为空   3、MySQL数据库文件存放目录:MySQL5.1\data或MySQL4.0\data   4、网站根目录[HTML,PHP]www\htdocs [ASP]www\asp [CGI,Perl]www\cgi-bin   5、访问本机请用127.0.0.1/或https://127.0.0.1/ (如果开启SSL)   6、非默认端口,网址为127.0.0.1:端口/或https://127.0.0.1:端口/   7、如果在“扩展功能”中选择使用Memcached,它的端口为:11211   8、APMServ集成了以下软件:   Apache 2.2.9 【HTTP服务器】   Nginx 0.7.19 【HTTP服务器】   NetBox 2.8 Build 4128 【HTTP服务器+ASP脚本解释引擎】   PHP 5.2.6 【PHP脚本解释引擎】   MiniPerl 5.8 【Perl脚本解释器】   Memcached 1.2.4 【key-value内存缓存系统】   MySQL 5.1.28 【MySQL数据库服务器】   MySQL 4.0.26 【MySQL数据库服务器】   phpMyAdmin 2.11.9.2 【MySQL数据库在线管理工具】   eAccelerator 0.9.5.3 【PHP脚本加速引擎】   ZendOptimizer 3.3.3 【PHP脚本加速引擎】   OpenSSL 0.9.8h 【HTTPS(SSL)安全传输协议】
安装Elastic APM Server的步骤如下: 1. 下载Elastic APM Server,可以从官网下载:https://www.elastic.co/downloads/apm/apm-server 2. 安装Elastic APM Server,在Linux上,可以使用以下命令进行安装: ```bash sudo dpkg -i apm-server-<version>-amd64.deb ``` 在Windows上,可以使用以下命令进行安装: ```powershell .\apm-server.exe install-service .\apm-server.exe start ``` 3. 配置Elastic APM Server,可以在apm-server.yml文件中进行配置,具体配置方法可以参考官方文档:https://www.elastic.co/guide/en/apm/server/current/configuration.html 4. 启动Elastic APM Server,在Linux上,可以使用以下命令进行启动: ```bash sudo systemctl start apm-server ``` 在Windows上,可以使用以下命令进行启动: ```powershell .\apm-server.exe start ``` 5. 验证Elastic APM Server是否正常工作,可以使用curl命令进行验证: ```bash curl -XGET 'http://localhost:8200' ``` 如果返回以下类似的信息,则说明Elastic APM Server已经正常工作: ``` { "version" : { "number" : "7.10.2", "build_flavor" : "default", "build_type" : "deb", "build_hash" : "747e1cc71def077253878a59143c1f785afa92b9", "build_date" : "2021-01-13T00:42:12.435326Z", "build_snapshot" : false, "lucene_version" : "8.7.0", "minimum_wire_compatibility_version" : "6.8.0", "minimum_index_compatibility_version" : "6.0.0-beta1" }, "tagline" : "You know, for APM" } ``` 以上就是Elastic APM Server安装步骤。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值