writer

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

writer provides our stdout writers for promql query results

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteInstant

func WriteInstant(i InstantWriter, format string, noHeaders bool) error

WriteInstant writes out the results of the query to an output buffer and prints it to stdout

func WriteRange

func WriteRange(r RangeWriter, format string, noHeaders bool) error

WriteRange writes out the results of the query to an output buffer and prints it to stdout

Types

type InstantResult

type InstantResult struct {
	model.Vector
}

InstantResult is wrapper of the prometheus model.Matrix type returned from instant queries Satisfies the InstantWriter interface

func (*InstantResult) Csv

func (r *InstantResult) Csv(noHeaders bool) (bytes.Buffer, error)

Csv returns the response from an instant query as a csv

func (*InstantResult) Json

func (r *InstantResult) Json() (bytes.Buffer, error)

Json returns the response from an instant query as json

func (*InstantResult) Table

func (r *InstantResult) Table(noHeaders bool) (bytes.Buffer, error)

Table returns the response from an instant query as a tab separated table

type InstantWriter

type InstantWriter interface {
	Writer
	Table(noHeaders bool) (bytes.Buffer, error)
}

InstantWriter extends the Writer interface by adding a Table method Use specifically for writing the results of instant queries

type LabelsResult

type LabelsResult struct {
	model.Vector
}

LabelsResult is the result of an instant query It's really the same as an InstantResult with different methods for parsing the unique labels present in a query result.

func (*LabelsResult) Csv

func (r *LabelsResult) Csv(noHeaders bool) (bytes.Buffer, error)

Csv returns the labels from an instant query as a single column csv

func (*LabelsResult) Json

func (r *LabelsResult) Json() (bytes.Buffer, error)

Json returns the labels from an instant query as json

func (*LabelsResult) Table

func (r *LabelsResult) Table(noHeaders bool) (bytes.Buffer, error)

Table returns the labels from an instant query as a single column table

type MetaResult added in v0.3.0

type MetaResult map[string][]v1.Metadata

MetaResult is the result of our metadata query It satisfies the InstantWriter interface

func (*MetaResult) Csv added in v0.3.0

func (r *MetaResult) Csv(noHeaders bool) (bytes.Buffer, error)

Csv returns the result from a metadata query as csv

func (*MetaResult) Json added in v0.3.0

func (r *MetaResult) Json() (bytes.Buffer, error)

Json returns the result from a metadata query as json

func (*MetaResult) Metrics added in v0.3.0

func (r *MetaResult) Metrics() MetricsResult

Metrics returns an array of metrics from a metadata query result

func (*MetaResult) Table added in v0.3.0

func (r *MetaResult) Table(noHeaders bool) (bytes.Buffer, error)

Table returns the result from a metadata query as tab separated table

type MetricsResult

type MetricsResult []string

MetricsResult is the list of metrics names from a metadata query result It satisfies the InstantWriter interface as it's a point in time (e.g. what metrics are currently queryable)

func (*MetricsResult) Csv

func (r *MetricsResult) Csv(noHeaders bool) (bytes.Buffer, error)

Csv returns the response from a metrics query as a single column csv

func (*MetricsResult) Json

func (r *MetricsResult) Json() (bytes.Buffer, error)

Json returns the response from a metrics query as json

func (*MetricsResult) Table

func (r *MetricsResult) Table(noHeaders bool) (bytes.Buffer, error)

Table returns the response from a metrics query as a single column table

type RangeResult

type RangeResult struct {
	model.Matrix
}

RangeResult is wrapper of the prometheus model.Matrix type returned from range queries Satisfies the RangeWriter interface

func (*RangeResult) Csv

func (r *RangeResult) Csv(noHeaders bool) (bytes.Buffer, error)

Csv returns the response from a range query as a csv

func (*RangeResult) Graph

func (r *RangeResult) Graph(dim util.TermDimensions) (bytes.Buffer, error)

Graph returns an ascii graph using https://github.com/guptarohit/asciigraph

func (*RangeResult) Json

func (r *RangeResult) Json() (bytes.Buffer, error)

Json returns the response from a range query as json

type RangeWriter

type RangeWriter interface {
	Writer
	Graph(dim util.TermDimensions) (bytes.Buffer, error)
}

RangeWriter extends the Writer interface by adding a Graph method Used specifically for writing the results of range queries

type SeriesResult added in v0.3.0

type SeriesResult []model.LabelSet

SeriesResult currently doesn't write anything itself but helps create other result types like metrics from the series api

func (*SeriesResult) Metrics added in v0.3.0

func (r *SeriesResult) Metrics() MetricsResult

Metrics creates a MetricsResult from a SeriesResult

type Writer

type Writer interface {
	Json() (bytes.Buffer, error)
	Csv(noHeaders bool) (bytes.Buffer, error)
}

Writer is our base interface for promql writers Defines Json and Csv writers

Jump to

Keyboard shortcuts

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