|
|
|
|
@@ -1,6 +1,7 @@
|
|
|
|
|
using Microsoft.AspNetCore.Authentication;
|
|
|
|
|
using Microsoft.AspNetCore.Authentication.Cookies;
|
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
using OpenTelemetry.Metrics;
|
|
|
|
|
using Serilog;
|
|
|
|
|
using ZB.MOM.WW.OtOpcUa.Admin.Components;
|
|
|
|
|
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").
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
|
|
app.UseSerilogRequestLogging();
|
|
|
|
|
@@ -87,6 +101,15 @@ app.MapPost("/auth/logout", async (HttpContext ctx) =>
|
|
|
|
|
app.MapHub<FleetStatusHub>("/hubs/fleet");
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
|
|
await app.RunAsync();
|
|
|
|
|
|