writer

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2021 License: Apache-2.0 Imports: 10 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 repsonse 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 MetricsResult

type MetricsResult struct {
	model.LabelValues
}

MetricsResult is the result of our metrics query 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 repsonse 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 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