最新ES+Kibana+Apm-server做netcore链路日志监控

官方地址:

 

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看板看数据

更多信息请查看 博客 或者关注公众号:Z技术

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值