feat(scadabridge): add HTTP/1.1 metrics listener on site nodes (NodeOptions.MetricsPort=8082)
This commit is contained in:
@@ -20,4 +20,6 @@ public class NodeOptions
|
||||
public int RemotingPort { get; set; } = 8081;
|
||||
/// <summary>Gets or sets the gRPC port for the site stream server.</summary>
|
||||
public int GrpcPort { get; set; } = 8083;
|
||||
/// <summary>HTTP/1.1 port serving the Prometheus /metrics scrape endpoint on site nodes.</summary>
|
||||
public int MetricsPort { get; set; } = 8082;
|
||||
}
|
||||
|
||||
@@ -293,6 +293,11 @@ try
|
||||
// Read GrpcPort from config (NodeOptions already has default 8083)
|
||||
var grpcPort = configuration.GetValue<int>("ScadaBridge:Node:GrpcPort", 8083);
|
||||
|
||||
// Read MetricsPort from config (NodeOptions already has default 8082).
|
||||
// Separate HTTP/1.1 listener so a standard HTTP/1.1 Prometheus scraper can
|
||||
// reach /metrics; the gRPC port stays HTTP/2-only below.
|
||||
var metricsPort = configuration.GetValue<int>("ScadaBridge:Node:MetricsPort", 8082);
|
||||
|
||||
// Configure Kestrel for HTTP/2 only on the gRPC port
|
||||
builder.WebHost.ConfigureKestrel(options =>
|
||||
{
|
||||
@@ -300,6 +305,13 @@ try
|
||||
{
|
||||
listenOptions.Protocols = Microsoft.AspNetCore.Server.Kestrel.Core.HttpProtocols.Http2;
|
||||
});
|
||||
|
||||
// Dedicated HTTP/1.1 (and HTTP/2) listener for the Prometheus /metrics
|
||||
// scrape endpoint, reachable by an HTTP/1.1 scraper.
|
||||
options.ListenAnyIP(metricsPort, listenOptions =>
|
||||
{
|
||||
listenOptions.Protocols = Microsoft.AspNetCore.Server.Kestrel.Core.HttpProtocols.Http1AndHttp2;
|
||||
});
|
||||
});
|
||||
|
||||
// gRPC server registration
|
||||
|
||||
Reference in New Issue
Block a user