官方地址:
Install Kibana with Docker | Kibana Guide [7.14] | Elastic
Run APM Server on Docker | APM Server Reference [7.14] | Elastic
Configuration on ASP.NET Core | APM .NET Agent Reference [1.11] | Elastic
1,安装ES
docker network create elastic
docker pull docker.elastic.co/elasticsearch/elasticsearch:7.14.1
docker run --name es01-test --net elastic -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:7.14.1
2,Kibana
docker pull docker.elastic.co/kibana/kibana:7.14.1
docker run --name kib01-test --net elastic -p 5601:5601 -e "ELASTICSEARCH_HOSTS=http://es01-test:9200" docker.elastic.co/kibana/kibana:7.14.1
3,安装apm-server
下载配置文件
curl -L -O https://raw.githubusercontent.com/elastic/apm-server/7.x/apm-server.docker.yml
3.1安装
docker pull docker.elastic.co/apm/apm-server:7.14.1
docker run -d \
-p 8200:8200 \
--name=apm-server \
--user=apm-server \
--volume="$(pwd)/apm-server.docker.yml:/usr/share/apm-server/apm-server.yml:ro" \
docker.elastic.co/apm/apm-server:7.14.1 \
--strict.perms=false -e \
-E output.elasticsearch.hosts=["x.x.x.x:9200"]
其中pwd代表你当前目录,既apm-server.docker.yml的下载目录
成功后可打开浏览器:http://x.x.x.x:8200
3.2进入kibana APM->addData 点击查看APM Server status状态,以下状态表示配置成功
kibana页面往下翻到APM Agents 选择.Net
4,配置Asp.Net Core项目
using Elastic.Apm.AspNetCore;
public class Startup
{
private readonly IConfiguration _configuration;
public Startup(IConfiguration configuration)
{
_configuration = configuration;
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
//Registers the agent with an IConfiguration instance:
app.UseElasticApm(_configuration);
//Rest of the Configure() method...
}
}
增加配置文件节点
{
"ElasticApm": {
"SecretToken": "",
"ServerUrls": "http://localhost:8200", //Set custom APM Server URL (default: http://localhost:8200)
"ServiceName": "WebCore", //allowed characters: a-z, A-Z, 0-9, -, _, and space. Default is the entry assembly of the application
"Environment": "production", // Set the service environment
}
}
完成上面配置后启动或者部署项目
5,打开kibana查看数据
点击Load Kibana objects和Launch APM
进入APM看板看数据
更多信息请关注公众号: