node-prometheus
    Preparing search index...

    Class Summary

    A Prometheus Summary metric. Tracks quantiles, sum, and count using a streaming targeted-quantile sketch.

    const summary = new Summary({
    name: "request_duration_seconds",
    description: "Request duration in seconds",
    quantiles: [
    { quantile: 0.5, error: 0.05 },
    { quantile: 0.9, error: 0.01 },
    { quantile: 0.99, error: 0.001 }
    ]
    });
    summary.observe(0.8);

    Hierarchy (View Summary)

    Index

    Constructors

    • Creates a new Summary.

      Parameters

      • config: {
            compressInterval?: number;
            description?: string;
            error?: number;
            labels?: Record<string, string>;
            name: string;
            quantiles: readonly (number | SummaryQuantile)[];
        }

        Configuration object.

        • OptionalcompressInterval?: number

          Optional interval controlling compression frequency.

        • Optionaldescription?: string

          Optional description.

        • Optionalerror?: number

          Default absolute rank error fraction for number-only quantiles.

        • Optionallabels?: Record<string, string>
        • name: string

          Metric name.

        • quantiles: readonly (number | SummaryQuantile)[]

          Quantiles to estimate, with optional per-quantile error bounds.

      Returns Summary

    Properties

    description?: string

    Optional metric description (used in # HELP).

    labels?: Record<string, string>

    Default labels applied to all samples of this metric.

    name: string

    The sanitized metric name.

    type: "summary"

    The Prometheus metric type.

    Methods

    • Observes a value, updating quantiles, sum, and count.

      Parameters

      • value: number

        The observed value.

      Returns void

    • Alias for observe().

      Parameters

      • value: number

        The observed value.

      Returns void

    • Serializes the metric to Prometheus exposition format.

      Returns Promise<string>

      A Promise resolving to the serialized string.

    • Sanitizes a metric name by removing or replacing invalid characters.

      Prometheus metric names must match [a-zA-Z_:][a-zA-Z0-9_:]* This removes hyphens, parens; replaces slashes and spaces with underscores.

      Parameters

      • Optionalinput: string

        The raw metric name.

      Returns string | undefined

      The cleaned metric name.

    • Concatenates multiple metrics into a single exposition string.

      Parameters

      • format: "prometheus" | "openmetrics" = 'prometheus'

        used to set the metric type

      • ...metrics: Metric<MetricType>[]

        The metrics to serialize.

      Returns Promise<string>

      A Promise resolving to the combined string.

    • Converts a label object to a Prometheus label string (e.g., {foo="bar"}).

      Parameters

      • Optionallabels: Record<string, string | number>

        The label key-value pairs.

      Returns string

      The formatted label string.