/** * Label map for metrics */ export type Labels = Record; /** * Metric types */ export declare enum MetricType { COUNTER = "counter", GAUGE = "gauge", HISTOGRAM = "histogram" } /** * Histogram bucket configuration */ export interface HistogramBuckets { buckets: number[]; counts: Map; sum: number; count: number; } /** * Base metric class */ declare abstract class Metric { readonly name: string; readonly type: MetricType; readonly help: string; readonly labels: string[]; constructor(name: string, type: MetricType, help: string, labels?: string[]); abstract getValue(labels?: Labels): number | HistogramBuckets; abstract reset(): void; } /** * Counter metric - monotonically increasing value * * @example * ```typescript * const requestCounter = new Counter('http_requests_total', 'Total HTTP requests', ['method', 'status']); * requestCounter.inc({ method: 'GET', status: '200' }); * requestCounter.inc({ method: 'POST', status: '201' }, 5); * ``` */ export declare class Counter extends Metric { private values; constructor(name: string, help: string, labels?: string[]); /** * Increment counter */ inc(labels?: Labels, value?: number): void; /** * Get current value */ getValue(labels?: Labels): number; /** * Reset counter */ reset(): void; /** * Get all values with labels */ getAll(): Array<{ labels: Labels; value: number; }>; private getKey; private parseKey; } /** * Gauge metric - value that can go up and down * * @example * ```typescript * const activeConnections = new Gauge('active_connections', 'Number of active connections'); * activeConnections.set(42); * activeConnections.inc(); * activeConnections.dec(5); * ``` */ export declare class Gauge extends Metric { private values; constructor(name: string, help: string, labels?: string[]); /** * Set gauge to a specific value */ set(value: number, labels?: Labels): void; /** * Increment gauge */ inc(labels?: Labels, value?: number): void; /** * Decrement gauge */ dec(labels?: Labels, value?: number): void; /** * Get current value */ getValue(labels?: Labels): number; /** * Reset gauge */ reset(): void; /** * Get all values with labels */ getAll(): Array<{ labels: Labels; value: number; }>; private getKey; private parseKey; } /** * Histogram metric - tracks distribution of values * * @example * ```typescript * const latency = new Histogram('request_duration_seconds', 'Request latency', ['endpoint'], [0.1, 0.5, 1, 2, 5]); * latency.observe(0.234, { endpoint: '/api/users' }); * latency.observe(1.567, { endpoint: '/api/users' }); * ``` */ export declare class Histogram extends Metric { private buckets; private values; constructor(name: string, help: string, labels?: string[], buckets?: number[]); /** * Observe a value */ observe(value: number, labels?: Labels): void; /** * Get histogram data */ getValue(labels?: Labels): HistogramBuckets; /** * Reset histogram */ reset(): void; /** * Get all histogram data with labels */ getAll(): Array<{ labels: Labels; value: HistogramBuckets; }>; private getKey; private parseKey; } /** * Metrics registry */ export declare class MetricsRegistry { private metrics; /** * Register a metric */ register(metric: Metric): void; /** * Get a metric by name */ get(name: string): Metric | undefined; /** * Get all metrics */ getAll(): Metric[]; /** * Clear all metrics */ clear(): void; /** * Reset all metric values */ reset(): void; /** * Export metrics in Prometheus text format */ export(): string; } /** * Default metrics registry */ export declare const defaultRegistry: MetricsRegistry; /** * Metrics collector for Elasticsearch client */ export declare class MetricsCollector { readonly registry: MetricsRegistry; readonly requestsTotal: Counter; readonly requestDuration: Histogram; readonly requestErrors: Counter; readonly activeConnections: Gauge; readonly bulkOperations: Counter; readonly bulkDocuments: Counter; readonly retries: Counter; constructor(registry?: MetricsRegistry); /** * Create a custom counter */ counter(name: string, help: string, labels?: string[]): Counter; /** * Create a custom gauge */ gauge(name: string, help: string, labels?: string[]): Gauge; /** * Create a custom histogram */ histogram(name: string, help: string, labels?: string[], buckets?: number[]): Histogram; /** * Record a counter increment (convenience method for plugins) */ recordCounter(name: string, value?: number, labels?: Labels): void; /** * Record a histogram observation (convenience method for plugins) */ recordHistogram(name: string, value: number, labels?: Labels): void; /** * Record a gauge value (convenience method for plugins) */ recordGauge(name: string, value: number, labels?: Labels): void; /** * Export all metrics in Prometheus format */ export(): string; } /** * Default metrics collector */ export declare const defaultMetricsCollector: MetricsCollector; export {};