Class: BaseMetricsRoute
Defined in: service-core/src/routes/BaseMetricsRoute.ts:36
The BaseMetricsRoute class provides a base set of endpoints for exposing Prometheus metrics.
Exposed endpoints:
| Name | HTTP Method | What it does |
|---|---|---|
getMetrics | GET /<base_path> | Returns all Prometheus metrics gathered by the system |
getSingleMetric | GET /<base_path>/:metric | Returns a single Prometheus metric with the given name |
Services that wish to provide metrics to be exposed via this route can register them using the global registry
from the provided prom-client dependency. See the prom-client documentation for more details.
!!Note!! that the BaseMetricsRoute is not automatically registered with a server by default. You must create
your own class that extends AdminRoute and apply the desired base path with @Route().
Example
import { BaseMetricsRoute, RouteDecorators } from "@rapidrest/service-core";
const { Route } = RouteDecorators;
@Route("/metrics")
export class MetricsRoute extends BaseMetricsRoute {}
Constructors
Constructor
new BaseMetricsRoute():
BaseMetricsRoute
Defined in: service-core/src/routes/BaseMetricsRoute.ts:47
Returns
BaseMetricsRoute
Properties
metricsConfig
protectedmetricsConfig:object
Defined in: service-core/src/routes/BaseMetricsRoute.ts:38
authRequired
authRequired:
boolean=true
registry
protectedregistry:Registry
Defined in: service-core/src/routes/BaseMetricsRoute.ts:42
trustedRoles
protectedtrustedRoles:string[] =[]
Defined in: service-core/src/routes/BaseMetricsRoute.ts:45
Methods
getMetrics()
getMetrics(
user?):Promise<string>
Defined in: service-core/src/routes/BaseMetricsRoute.ts:56
Parameters
user?
JWTUser
Returns
Promise<string>
getSingleMetric()
getSingleMetric(
metric,user?):Promise<string>
Defined in: service-core/src/routes/BaseMetricsRoute.ts:68
Parameters
metric
any
user?
JWTUser
Returns
Promise<string>