Skip to main content

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:

NameHTTP MethodWhat it does
getMetricsGET /<base_path>Returns all Prometheus metrics gathered by the system
getSingleMetricGET /<base_path>/:metricReturns 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

protected metricsConfig: object

Defined in: service-core/src/routes/BaseMetricsRoute.ts:38

authRequired

authRequired: boolean = true


registry

protected registry: Registry

Defined in: service-core/src/routes/BaseMetricsRoute.ts:42


trustedRoles

protected trustedRoles: 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>