Documentation ¶
Index ¶
- Constants
- type Entry
- type MetricType
- type OpenMetricsParser
- func (p *OpenMetricsParser) Comment() []byte
- func (p *OpenMetricsParser) Exemplar(e *exemplar.Exemplar) bool
- func (p *OpenMetricsParser) Help() ([]byte, []byte)
- func (p *OpenMetricsParser) Metric(l *labels.Labels) string
- func (p *OpenMetricsParser) Next() (Entry, error)
- func (p *OpenMetricsParser) Series() ([]byte, *int64, float64)
- func (p *OpenMetricsParser) Type() ([]byte, MetricType)
- func (p *OpenMetricsParser) Unit() ([]byte, []byte)
- type Parser
- type PromParser
- func (p *PromParser) Comment() []byte
- func (p *PromParser) Exemplar(e *exemplar.Exemplar) bool
- func (p *PromParser) Help() ([]byte, []byte)
- func (p *PromParser) Metric(l *labels.Labels) string
- func (p *PromParser) Next() (Entry, error)
- func (p *PromParser) Series() ([]byte, *int64, float64)
- func (p *PromParser) Type() ([]byte, MetricType)
- func (p *PromParser) Unit() ([]byte, []byte)
Constants ¶
const ( MetricTypeCounter = MetricType("counter") MetricTypeGauge = MetricType("gauge") MetricTypeHistogram = MetricType("histogram") MetricTypeGaugeHistogram = MetricType("gaugehistogram") MetricTypeSummary = MetricType("summary") MetricTypeInfo = MetricType("info") MetricTypeStateset = MetricType("stateset") MetricTypeUnknown = MetricType("unknown") )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type OpenMetricsParser ¶
type OpenMetricsParser struct {
// contains filtered or unexported fields
}
OpenMetricsParser parses samples from a byte slice of samples in the official OpenMetrics text exposition format. This is based on the working draft https://docs.google.com/document/u/1/d/1KwV0mAXwwbvvifBvDKH_LU1YjyXE_wxCkHNoCGq1GX0/edit
func (*OpenMetricsParser) Comment ¶
func (p *OpenMetricsParser) Comment() []byte
Comment returns the text of the current comment. Must only be called after Next returned a comment entry. The returned byte slice becomes invalid after the next call to Next.
func (*OpenMetricsParser) Exemplar ¶
func (p *OpenMetricsParser) Exemplar(e *exemplar.Exemplar) bool
Exemplar writes the exemplar of the current sample into the passed exemplar. It returns the whether an exemplar exists.
func (*OpenMetricsParser) Help ¶
func (p *OpenMetricsParser) Help() ([]byte, []byte)
Help returns the metric name and help text in the current entry. Must only be called after Next returned a help entry. The returned byte slices become invalid after the next call to Next.
func (*OpenMetricsParser) Metric ¶
func (p *OpenMetricsParser) Metric(l *labels.Labels) string
Metric writes the labels of the current sample into the passed labels. It returns the string from which the metric was parsed.
func (*OpenMetricsParser) Next ¶
func (p *OpenMetricsParser) Next() (Entry, error)
Next advances the parser to the next sample. It returns false if no more samples were read or an error occurred.
func (*OpenMetricsParser) Series ¶
func (p *OpenMetricsParser) Series() ([]byte, *int64, float64)
Series returns the bytes of the series, the timestamp if set, and the value of the current sample.
func (*OpenMetricsParser) Type ¶
func (p *OpenMetricsParser) Type() ([]byte, MetricType)
Type returns the metric name and type in the current entry. Must only be called after Next returned a type entry. The returned byte slices become invalid after the next call to Next.
func (*OpenMetricsParser) Unit ¶
func (p *OpenMetricsParser) Unit() ([]byte, []byte)
Unit returns the metric name and unit in the current entry. Must only be called after Next returned a unit entry. The returned byte slices become invalid after the next call to Next.
type Parser ¶
type Parser interface { // Series returns the bytes of the series, the timestamp if set, and the value // of the current sample. Series() ([]byte, *int64, float64) // Help returns the metric name and help text in the current entry. // Must only be called after Next returned a help entry. // The returned byte slices become invalid after the next call to Next. Help() ([]byte, []byte) // Type returns the metric name and type in the current entry. // Must only be called after Next returned a type entry. // The returned byte slices become invalid after the next call to Next. Type() ([]byte, MetricType) // Unit returns the metric name and unit in the current entry. // Must only be called after Next returned a unit entry. // The returned byte slices become invalid after the next call to Next. Unit() ([]byte, []byte) // Comment returns the text of the current comment. // Must only be called after Next returned a comment entry. // The returned byte slice becomes invalid after the next call to Next. Comment() []byte // Metric writes the labels of the current sample into the passed labels. // It returns the string from which the metric was parsed. Metric(l *labels.Labels) string // Exemplar writes the exemplar of the current sample into the passed // exemplar. It returns if an exemplar exists or not. Exemplar(l *exemplar.Exemplar) bool // Next advances the parser to the next sample. It returns false if no // more samples were read or an error occurred. Next() (Entry, error) }
Parser parses samples from a byte slice of samples in the official Prometheus and OpenMetrics text exposition formats.
func NewOpenMetricsParser ¶
NewOpenMetricsParser returns a new parser of the byte slice.
func NewPromParser ¶
NewPromParser returns a new parser of the byte slice.
type PromParser ¶
type PromParser struct {
// contains filtered or unexported fields
}
PromParser parses samples from a byte slice of samples in the official Prometheus text exposition format.
func (*PromParser) Comment ¶
func (p *PromParser) Comment() []byte
Comment returns the text of the current comment. Must only be called after Next returned a comment entry. The returned byte slice becomes invalid after the next call to Next.
func (*PromParser) Exemplar ¶
func (p *PromParser) Exemplar(e *exemplar.Exemplar) bool
Exemplar writes the exemplar of the current sample into the passed exemplar. It returns if an exemplar exists.
func (*PromParser) Help ¶
func (p *PromParser) Help() ([]byte, []byte)
Help returns the metric name and help text in the current entry. Must only be called after Next returned a help entry. The returned byte slices become invalid after the next call to Next.
func (*PromParser) Metric ¶
func (p *PromParser) Metric(l *labels.Labels) string
Metric writes the labels of the current sample into the passed labels. It returns the string from which the metric was parsed.
func (*PromParser) Next ¶
func (p *PromParser) Next() (Entry, error)
Next advances the parser to the next sample. It returns false if no more samples were read or an error occurred.
func (*PromParser) Series ¶
func (p *PromParser) Series() ([]byte, *int64, float64)
Series returns the bytes of the series, the timestamp if set, and the value of the current sample.
func (*PromParser) Type ¶
func (p *PromParser) Type() ([]byte, MetricType)
Type returns the metric name and type in the current entry. Must only be called after Next returned a type entry. The returned byte slices become invalid after the next call to Next.
func (*PromParser) Unit ¶
func (p *PromParser) Unit() ([]byte, []byte)
Unit returns the metric name and unit in the current entry. Must only be called after Next returned a unit entry. The returned byte slices become invalid after the next call to Next.