Service that exposes the "/metrics" and "/metricsandreset" routes for Prometheus to obtain performance metrics.
Inherits: RestService
Description
The PrometheusMetricsService class allows you to create services that expose the "/metrics" and "/metricsandreset" routes for Prometheus to obtain performance metrics.
Configuration parameters
dependencies:
- endpoint: override for HTTP Endpoint dependency
- prometheus_counters: override for PrometheusCounters dependency
connection(s):
- discovery_key: (optional) key to retrieve the connection from IDiscovery
- protocol: connection protocol: http or https
- host: host name or IP address
- port: port number
- uri: resource URI or connection string with all parameters in it
References
-
- *:logger:*:*:1.0 - (optional) ILogger components to pass log messages
-
- *:counters:*:*:1.0 - (optional) ICounters components to pass collected measurements
-
- *:discovery:*:*:1.0 - (optional) IDiscovery services to resolve connections
-
- *:endpoint:http:*:1.0 - (optional) HttpEndpoint reference to expose REST operations
-
- *:counters:prometheus:*:1.0 - PrometheusCounters reference to retrieve collected metrics
Constructors
Creates a new instance of this service.
public
PrometheusMetricsService()
Instance methods
SetReferences
Sets references to dependent components.
public override
void SetReferences(IReferences references)
- references: IReferences - references to locate the component dependencies.
Register
Registers all service routes in a HTTP endpoint.
public override
void Register()
Examples
var service = new PrometheusMetricsService();
service.Configure(ConfigParams.FromTuples(
"connection.protocol", "http",
"connection.host", "localhost",
"connection.port", 8080 ));
service.Open("123");
Console.Out.WriteLine("The Prometheus metrics service is accessible at http://+:8080/metrics");