UNPKG

kuzzle-plugin-prometheus

Version:
96 lines (95 loc) 3 kB
import { Plugin, PluginContext, KuzzleRequest, JSONObject } from 'kuzzle'; /** * Promtheus Plugin configuration type */ export type PrometheusPluginConfiguration = { core: { /** * Enable or disable request duration metrics * This is a plugin provided metric using Kuzzle hooks on request:* events * @default true */ monitorRequestDuration?: boolean; /** * String to prefix core metrics with * @default 'kuzzle_' */ prefix?: string; }; default: { /** * Enable or disable the Node.js process metrics (EventLoop lags, GC, CPU, RAM etc...) * @default true */ enabled?: boolean; /** * The event loop monitoring sampling rate in milliseconds * @default 10 */ eventLoopMonitoringPrecision?: number; /** * The custom buckets for GC duration histogram in seconds * @default [0.001,0.01,0.1,1,2,5] */ gcDurationBuckets?: number[]; /** * String to prefix default metrics with * @default 'kuzzle_' */ prefix?: string; }; /** * Custom labels to add to all metrics (useful for multi Kuzzle instances) * @default {} * @example * { * instance: 'my-instance-name' * region: 'eu-west-1' * environment: 'production' * } */ labels?: JSONObject; }; /** * @class PrometheusPlugin * * @property {PluginConfiguration} config Plugin configuration * @property {MetricService} metricService Metric service * * @externs */ export declare class PrometheusPlugin extends Plugin { /** * Plugin configuration validation */ config: PrometheusPluginConfiguration; /** * Service to manage, update and format Prometheus metrics */ private metricService; constructor(); /** * Plugin initialization * @param {PrometheusPluginConfiguration} config - Plugin configuration * @param {PluginContext} context - Kuzzle plugin context */ init(config: PrometheusPluginConfiguration, context: PluginContext): Promise<void>; /** * On server:afterMetrics hook, format the metrics and send them to the client as Prometheus format * @param {KuzzleRequest} request - Kuzzle request * @returns {KuzzleRequest} */ pipeFormatMetrics(request: KuzzleRequest): Promise<KuzzleRequest>; /** * Log the response time for the given request in the associated metric * @param {KuzzleRequest} request - Kuzzle request */ recordRequest(request: KuzzleRequest): void; /** * Return the metrics in Prometheus format * NOTE: This is an HTTP route for Prometheus installations that do not support HTTP arguments * @param {KuzzleRequest} request - Kuzzle request * @returns {Promise<string>} */ metrics(request: KuzzleRequest): Promise<string>; }