textparse

package
v2.4.1+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 19, 2018 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package textparse contains an efficient parser for the Prometheus text format.

Index

Constants

View Source
const (
	MetricTypeCounter   = "counter"
	MetricTypeGauge     = "gauge"
	MetricTypeHistogram = "histogram"
	MetricTypeSummary   = "summary"
	MetricTypeUntyped   = "untyped"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry int

Entry represents the type of a parsed entry.

const (
	EntryInvalid Entry = -1
	EntryType    Entry = 0
	EntryHelp    Entry = 1
	EntrySeries  Entry = 2
	EntryComment Entry = 3
)

type MetricType

type MetricType string

MetricType represents metric type values.

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

Parser parses samples from a byte slice of samples in the official Prometheus text exposition format.

func New

func New(b []byte) *Parser

New returns a new parser of the byte slice.

func (*Parser) Comment

func (p *Parser) 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 (*Parser) Help

func (p *Parser) 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 (*Parser) Metric

func (p *Parser) 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 (*Parser) Next

func (p *Parser) 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 (*Parser) Series

func (p *Parser) Series() ([]byte, *int64, float64)

Series returns the bytes of the series, the timestamp if set, and the value of the current sample.

func (*Parser) Type

func (p *Parser) 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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL