kuzzle-plugin-prometheus
Version:
Kuzzle plugin: monitoring Kuzzle using Prometheus
88 lines (87 loc) • 3.29 kB
TypeScript
import { JSONObject } from 'kuzzle';
import { Gauge } from 'prom-client';
import { PrometheusPluginConfiguration } from '../PrometheusPlugin';
/**
* Core metrics type definition
*/
export type CoreMetrics = {
api: {
/**
* Concurrent requests being processed
*/
concurrentRequests: Gauge<string>;
/**
* Number of requests waiting to be processed
*/
pendingRequests: Gauge<string>;
};
network: {
/**
* Number of active connections per protocol using labels
*/
connections: Gauge<string>;
};
realtime: {
/**
* Number of active realtime rooms
* @see https://docs.kuzzle.io/core/2/guides/main-concepts/realtime-engine
*/
rooms: Gauge<string>;
/**
* Number of active realtime subscriptions
* @see https://docs.kuzzle.io/core/2/guides/main-concepts/realtime-engine
*/
subscriptions: Gauge<string>;
};
};
/**
* MetricService is a service to handle metrics from the Kuzzle API and the application.
* @property {{ core: CoreMetrics, requestDuration?: Histogram<string> }} metrics - The application metrics to register.
* @property {{[key: string]: Registry}} registries - The Prometheus registry to register metrics.
*/
export declare class MetricService {
/**
* A set of metrics matching the Kuzzle server:metrics action reponse
* @property {CoreMetrics} core - The core metrics to register.
* @property {Histogram} requestDuration - The application metrics to register.
*/
private metrics;
/**
* The Prometheus registries used to register metrics and format them
* @property {Registry} core - The core metrics registry
* @property {Registry} default - The default metrics registry (if enabled)
* @property {Registry} requestDuration - The default metrics registry (if enabled)
*/
private registries;
/**
* Labels to add to the metric registries
*/
private labels;
/**
* @param {PrometheusPluginConfiguration} config - The plugin configuration
*/
constructor(config: PrometheusPluginConfiguration);
/**
* Update the Prometheus coreMetrics with from the server:metrics JSON response
* @param {JSONObject} jsonMetrics - The server:metrics JSON response
*/
updateCoreMetrics(jsonMetrics: JSONObject): void;
/**
* Merge all the Prometheus registries into one and returns metrics as Prometheus text format
* @returns {string} All the regitries metrics formatted as a Prometheus text
*/
getMetrics(): Promise<string>;
/**
* Returns the content type used to export metrics to Prometheus
* @returns {string} The content type used to export metrics to Prometheus
*/
getPrometheusContentType(): string;
/**
* Record response time in the Prometheus responseTime histogram
* @param {number} time - Time in ms
* @param {{[key: string]: string | number}} labels - Labels to add to the metric
*/
recordResponseTime(time: number, labels: {
[key: string]: string | number;
}): void;
}