【发布时间】:2021-08-15 19:14:35
【问题描述】:
我有一个 asp.net 核心网络应用程序 (mvc) 项目,当应用程序中发生某些事情时,它会将日志写入 elasticsearch 并从 elasticsearch 读取日志。
有没有一种方法可以关联同一浏览器事务中发生的日志? (即打开浏览器,用户单击每个页面上的按钮将他们重定向到另一个页面,直到他们到达完成的页面末尾,然后他们关闭浏览器)我看到了一些关于 APM 但是否有替代组如果有意义的话,这些日志将作为一个事务合并在一起。
更新:
我完全按照apm installation tutorial guide for Windows 的说明进行操作。当我进入第 3 步,即启动 APM 服务器时,它说要运行 cmd Start-Service apm-server,但什么也没发生。因此,当我尝试使用 cmd ./apm-server -e 启动服务器时,它做了一些看起来不像它应该以管理员身份在 powershell 中显示的格式。
然后我检查了 apm 服务器状态,它显示为正确设置。我没有执行第 2 步,因为我在 localhost 运行它。
进入最后一步,即 APM 代理。我进入 .NET 选项卡并按照说明操作...安装 Elastic.APM.NetCoreAll nuget 包并执行以下操作...
Startup.cs 文件我添加了app.UseElasticApm(Configuration, new HttpDiagnosticsSubscriber(), new EfCoreDiagnosticsSubscriber());
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseElasticApm(Configuration,
new HttpDiagnosticsSubscriber(), // Enable tracing of outgoing HTTP requests
new EfCoreDiagnosticsSubscriber()); // Enable tracing of database calls through EF Core
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
});
}
在我的appsettings.json 文件中:
{
"ApplicationName": "customer-simulation-es-app",
"Serilog": {
"MinimumLevel": {
"Default": "Information",
"Override": {
"Microsoft": "Information",
"System": "Warning"
}
}
},
"ElasticConfiguration": {
"Uri": "http://localhost:9200"
},
"ElasticApm": {
"ServerUrl": "http://localhost:8200",
"ServiceName": "CustomerApp",
"Environment": "production",
"CloudProvider": "none",
"LogLevel": "Trace"
},
"AllowedHosts": "*"
}
这是我在程序开始运行时在 .exe 文件应用程序上看到的内容:
我运行程序并在浏览器上执行一些操作。然后我去检查代理状态,它说还没有收到代理的数据。但我完全按照他们的意愿做了。
我是否遗漏了指南中没有的内容?
【问题讨论】:
标签: c# asp.net-mvc elasticsearch apm