summaryrefslogtreecommitdiffstats
path: root/library/cpp/monlib/encode/prometheus/prometheus.h
blob: 6467836a6a655784588fc49c782223ef827c28f2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#pragma once

#include <functional>

#include <library/cpp/monlib/encode/encoder.h>
#include <library/cpp/monlib/encode/format.h>

#include <util/generic/yexception.h>


namespace NMonitoring {

    class TPrometheusDecodeException: public yexception {
    };

    enum class EPrometheusDecodeMode {
        DEFAULT,
        RAW
    };

    struct TPrometheusDecodeSettings {
        EPrometheusDecodeMode Mode{EPrometheusDecodeMode::DEFAULT};
        /*
         * Mangles the label that is equal to metricNameLabel. The
         * new name must be not equal to any already present in the
         * metric sample.
         */
        std::function<TString(TStringBuf)> NameMangler{};
    };

    IMetricEncoderPtr EncoderPrometheus(IOutputStream* out, TStringBuf metricNameLabel = "sensor");

    void DecodePrometheus(TStringBuf data, IMetricConsumer* c, TStringBuf metricNameLabel = "sensor", const TPrometheusDecodeSettings& settings = TPrometheusDecodeSettings{});

}