Documentation ¶
Index ¶
- Variables
- func MetricName(measurement, fieldKey string, valueType telegraf.ValueType) string
- func MetricType(valueType telegraf.ValueType) *dto.MetricType
- func SampleCount(value interface{}) (uint64, bool)
- func SampleSum(value interface{}) (float64, bool)
- func SampleValue(value interface{}) (float64, bool)
- func SanitizeLabelName(name string) (string, bool)
- func SanitizeMetricName(name string) (string, bool)
- type Bucket
- type Collection
- type Entry
- type FormatConfig
- type Histogram
- type LabelPair
- type Metric
- type MetricFamily
- type MetricKey
- type MetricTypes
- type Quantile
- type Scaler
- type Serializer
- type Summary
- type Table
- type TimeFunc
Constants ¶
This section is empty.
Variables ¶
var LabelNameTable = Table{ First: &unicode.RangeTable{ R16: []unicode.Range16{ {0x0041, 0x005A, 1}, {0x005F, 0x005F, 1}, {0x0061, 0x007A, 1}, }, LatinOffset: 3, }, Rest: &unicode.RangeTable{ R16: []unicode.Range16{ {0x0030, 0x0039, 1}, {0x0041, 0x005A, 1}, {0x005F, 0x005F, 1}, {0x0061, 0x007A, 1}, }, LatinOffset: 4, }, }
var MetricNameTable = Table{ First: &unicode.RangeTable{ R16: []unicode.Range16{ {0x003A, 0x003A, 1}, {0x0041, 0x005A, 1}, {0x005F, 0x005F, 1}, {0x0061, 0x007A, 1}, }, LatinOffset: 4, }, Rest: &unicode.RangeTable{ R16: []unicode.Range16{ {0x0030, 0x003A, 1}, {0x0041, 0x005A, 1}, {0x005F, 0x005F, 1}, {0x0061, 0x007A, 1}, }, LatinOffset: 4, }, }
Functions ¶
func MetricName ¶
MetricName returns the Prometheus metric name.
func MetricType ¶
func MetricType(valueType telegraf.ValueType) *dto.MetricType
func SampleCount ¶
SampleCount converts a field value into a count suitable for a metric family of the Histogram or Summary type.
func SampleSum ¶
SampleSum converts a field value into a sum suitable for a metric family of the Histogram or Summary type.
func SampleValue ¶
SampleValue converts a field value into a value suitable for a simple sample value.
func SanitizeLabelName ¶
SanitizeLabelName checks if the name is a valid Prometheus label name. If not, it attempts to replaces invalid runes with an underscore to create a valid name.
func SanitizeMetricName ¶
SanitizeMetricName checks if the name is a valid Prometheus metric name. If not, it attempts to replaces invalid runes with an underscore to create a valid name.
Types ¶
type Collection ¶
type Collection struct { Entries map[MetricFamily]Entry // contains filtered or unexported fields }
func NewCollection ¶
func NewCollection(config FormatConfig) *Collection
func (*Collection) GetEntries ¶
func (c *Collection) GetEntries() []Entry
func (*Collection) GetMetrics ¶
func (c *Collection) GetMetrics(entry Entry) []*Metric
func (*Collection) GetProto ¶
func (c *Collection) GetProto() []*dto.MetricFamily
type Entry ¶
type Entry struct { Family MetricFamily Metrics map[MetricKey]*Metric }
type FormatConfig ¶
type FormatConfig struct { ExportTimestamp bool `toml:"prometheus_export_timestamp"` SortMetrics bool `toml:"prometheus_sort_metrics"` StringAsLabel bool `toml:"prometheus_string_as_label"` // CompactEncoding defines whether to include // HELP metadata in Prometheus payload. Setting to true // helps to reduce payload size. CompactEncoding bool `toml:"prometheus_compact_encoding"` TypeMappings MetricTypes `toml:"prometheus_metric_types"` }
type MetricFamily ¶
type MetricTypes ¶ added in v1.28.0
type MetricTypes struct { Counter []string `toml:"counter"` Gauge []string `toml:"gauge"` // contains filtered or unexported fields }
func (*MetricTypes) DetermineType ¶ added in v1.28.0
func (*MetricTypes) Init ¶ added in v1.28.0
func (mt *MetricTypes) Init() error
type Serializer ¶
type Serializer struct {
FormatConfig
}
func (*Serializer) Init ¶ added in v1.28.0
func (s *Serializer) Init() error
func (*Serializer) InitFromConfig ¶ added in v1.27.0
func (s *Serializer) InitFromConfig(cfg *serializers.Config) error
InitFromConfig is a compatibility function to construct the parser the old way
func (*Serializer) Serialize ¶
func (s *Serializer) Serialize(metric telegraf.Metric) ([]byte, error)
func (*Serializer) SerializeBatch ¶
func (s *Serializer) SerializeBatch(metrics []telegraf.Metric) ([]byte, error)
type Table ¶
type Table struct { First *unicode.RangeTable Rest *unicode.RangeTable }