package expfmt
import "github.com/etcd-io/etcd/Godeps/_workspace/src/github.com/prometheus/common/expfmt"
A package for reading and writing Prometheus metrics.
Index ¶
- Constants
- func ExtractSamples(o *DecodeOptions, fams ...*dto.MetricFamily) model.Vector
- func MetricFamilyToText(out io.Writer, in *dto.MetricFamily) (int, error)
- type DecodeOptions
- type Decoder
- type Encoder
- type Format
- type ParseError
- type SampleDecoder
- type TextParser
- Bugs
Constants ¶
const ( TextVersion = "0.0.4" ProtoType = `application/vnd.google.protobuf` ProtoProtocol = `io.prometheus.client.MetricFamily` ProtoFmt = ProtoType + "; proto=" + ProtoProtocol + ";" // The Content-Type values for the different wire protocols. FmtUnknown Format = `<unknown>` FmtText Format = `text/plain; version=` + TextVersion FmtProtoDelim Format = ProtoFmt + ` encoding=delimited` FmtProtoText Format = ProtoFmt + ` encoding=text` FmtProtoCompact Format = ProtoFmt + ` encoding=compact-text` )
Functions ¶
func ExtractSamples ¶
func ExtractSamples(o *DecodeOptions, fams ...*dto.MetricFamily) model.Vector
Extract samples builds a slice of samples from the provided metric families.
func MetricFamilyToText ¶
MetricFamilyToText converts a MetricFamily proto message into text format and writes the resulting lines to 'out'. It returns the number of bytes written and any error encountered. This function does not perform checks on the content of the metric and label names, i.e. invalid metric or label names will result in invalid text format output. This method fulfills the type 'prometheus.encoder'.
Types ¶
type DecodeOptions ¶
type DecodeOptions struct { // Timestamp is added to each value from the stream that has no explicit timestamp set. Timestamp model.Time }
type Decoder ¶
type Decoder interface { Decode(*dto.MetricFamily) error }
Decoder types decode an input stream into metric families.
func NewDecoder ¶
NewDecoder returns a new decoder based on the given input format. If the input format does not imply otherwise, a text format decoder is returned.
type Encoder ¶
type Encoder interface { Encode(*dto.MetricFamily) error }
Encoder types encode metric families into an underlying wire protocol.
func NewEncoder ¶
NewEncoder returns a new encoder based on content type negotiation.
type Format ¶
type Format string
func Negotiate ¶
Negotiate returns the Content-Type based on the given Accept header. If no appropriate accepted type is found, FmtText is returned.
func ResponseFormat ¶
ResponseFormat extracts the correct format from a HTTP response header. If no matching format can be found FormatUnknown is returned.
type ParseError ¶
ParseError signals errors while parsing the simple and flat text-based exchange format.
func (ParseError) Error ¶
func (e ParseError) Error() string
Error implements the error interface.
type SampleDecoder ¶
type SampleDecoder struct { Dec Decoder Opts *DecodeOptions // contains filtered or unexported fields }
func (*SampleDecoder) Decode ¶
func (sd *SampleDecoder) Decode(s *model.Vector) error
type TextParser ¶
type TextParser struct {
// contains filtered or unexported fields
}
TextParser is used to parse the simple and flat text-based exchange format. Its nil value is ready to use.
func (*TextParser) TextToMetricFamilies ¶
func (p *TextParser) TextToMetricFamilies(in io.Reader) (map[string]*dto.MetricFamily, error)
TextToMetricFamilies reads 'in' as the simple and flat text-based exchange format and creates MetricFamily proto messages. It returns the MetricFamily proto messages in a map where the metric names are the keys, along with any error encountered.
If the input contains duplicate metrics (i.e. lines with the same metric name and exactly the same label set), the resulting MetricFamily will contain duplicate Metric proto messages. Similar is true for duplicate label names. Checks for duplicates have to be performed separately, if required. Also note that neither the metrics within each MetricFamily are sorted nor the label pairs within each Metric. Sorting is not required for the most frequent use of this method, which is sample ingestion in the Prometheus server. However, for presentation purposes, you might want to sort the metrics, and in some cases, you must sort the labels, e.g. for consumption by the metric family injection hook of the Prometheus registry.
Summaries and histograms are rather special beasts. You would probably not use them in the simple text format anyway. This method can deal with summaries and histograms if they are presented in exactly the way the text.Create function creates them.
This method must not be called concurrently. If you want to parse different input concurrently, instantiate a separate Parser for each goroutine.
Bugs ¶
☞ Update other names to "quantile".
Source Files ¶
decode.go encode.go expfmt.go json_decode.go text_create.go text_parse.go
- Version
- v2.3.8+incompatible (latest)
- Published
- Feb 16, 2017
- Platform
- linux/amd64
- Imports
- 16 packages
- Last checked
- 1 month ago –
Tools for package owners.