Compare commits
2 Commits
diff-acl-s
...
otel-expor
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ef53553e9d | ||
| d1e50db304 |
@@ -1,6 +1,7 @@
|
|||||||
using Microsoft.AspNetCore.Authentication;
|
using Microsoft.AspNetCore.Authentication;
|
||||||
using Microsoft.AspNetCore.Authentication.Cookies;
|
using Microsoft.AspNetCore.Authentication.Cookies;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using OpenTelemetry.Metrics;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
using ZB.MOM.WW.OtOpcUa.Admin.Components;
|
using ZB.MOM.WW.OtOpcUa.Admin.Components;
|
||||||
using ZB.MOM.WW.OtOpcUa.Admin.Hubs;
|
using ZB.MOM.WW.OtOpcUa.Admin.Hubs;
|
||||||
@@ -70,6 +71,19 @@ builder.Services.AddScoped<ILdapAuthService, LdapAuthService>();
|
|||||||
// SignalR real-time fleet status + alerts (admin-ui.md §"Real-Time Updates").
|
// SignalR real-time fleet status + alerts (admin-ui.md §"Real-Time Updates").
|
||||||
builder.Services.AddHostedService<FleetStatusPoller>();
|
builder.Services.AddHostedService<FleetStatusPoller>();
|
||||||
|
|
||||||
|
// OpenTelemetry Prometheus exporter — Meter stream from RedundancyMetrics + any future
|
||||||
|
// Admin-side instrumentation lands on the /metrics endpoint Prometheus scrapes. Pull-based
|
||||||
|
// means no OTel Collector deployment required for the common deploy-in-a-K8s case; appsettings
|
||||||
|
// Metrics:Prometheus:Enabled=false disables the endpoint entirely for locked-down deployments.
|
||||||
|
var metricsEnabled = builder.Configuration.GetValue("Metrics:Prometheus:Enabled", true);
|
||||||
|
if (metricsEnabled)
|
||||||
|
{
|
||||||
|
builder.Services.AddOpenTelemetry()
|
||||||
|
.WithMetrics(m => m
|
||||||
|
.AddMeter(RedundancyMetrics.MeterName)
|
||||||
|
.AddPrometheusExporter());
|
||||||
|
}
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
app.UseSerilogRequestLogging();
|
app.UseSerilogRequestLogging();
|
||||||
@@ -87,6 +101,15 @@ app.MapPost("/auth/logout", async (HttpContext ctx) =>
|
|||||||
app.MapHub<FleetStatusHub>("/hubs/fleet");
|
app.MapHub<FleetStatusHub>("/hubs/fleet");
|
||||||
app.MapHub<AlertHub>("/hubs/alerts");
|
app.MapHub<AlertHub>("/hubs/alerts");
|
||||||
|
|
||||||
|
if (metricsEnabled)
|
||||||
|
{
|
||||||
|
// Prometheus scrape endpoint — expose instrumentation registered in the OTel MeterProvider
|
||||||
|
// above. Emits text-format metrics at /metrics; auth is intentionally NOT required (Prometheus
|
||||||
|
// scrape jobs typically run on a trusted network). Operators who need auth put the endpoint
|
||||||
|
// behind a reverse-proxy basic-auth gate per fleet-ops convention.
|
||||||
|
app.MapPrometheusScrapingEndpoint();
|
||||||
|
}
|
||||||
|
|
||||||
app.MapRazorComponents<App>().AddInteractiveServerRenderMode();
|
app.MapRazorComponents<App>().AddInteractiveServerRenderMode();
|
||||||
|
|
||||||
await app.RunAsync();
|
await app.RunAsync();
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
<PackageReference Include="Novell.Directory.Ldap.NETStandard" Version="3.6.0"/>
|
<PackageReference Include="Novell.Directory.Ldap.NETStandard" Version="3.6.0"/>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="10.0.0"/>
|
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="10.0.0"/>
|
||||||
<PackageReference Include="Serilog.AspNetCore" Version="9.0.0"/>
|
<PackageReference Include="Serilog.AspNetCore" Version="9.0.0"/>
|
||||||
|
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.15.2"/>
|
||||||
|
<PackageReference Include="OpenTelemetry.Exporter.Prometheus.AspNetCore" Version="1.15.2-beta.1"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -23,5 +23,10 @@
|
|||||||
},
|
},
|
||||||
"Serilog": {
|
"Serilog": {
|
||||||
"MinimumLevel": "Information"
|
"MinimumLevel": "Information"
|
||||||
|
},
|
||||||
|
"Metrics": {
|
||||||
|
"Prometheus": {
|
||||||
|
"Enabled": true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user