singlestat

package
v0.11.5 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(stat *SingleStat)

Option represents an option that can be used to configure a single stat panel.

func ColorBackground

func ColorBackground() Option

ColorBackground will show the threshold's colors in the background.

func ColorValue

func ColorValue() Option

ColorValue will show the threshold's colors on the value itself.

func Colors

func Colors(values [3]string) Option

Colors define which colors will be applied to the single value based on the threshold levels.

func DataSource

func DataSource(source string) Option

DataSource sets the data source to be used by the panel.

func Editable

func Editable() Option

Editable marks the graph as editable.

func FullSparkLine

func FullSparkLine() Option

FullSparkLine displays a full height spark line summary of the series in addition to the single stat.

func Height

func Height(height string) Option

Height sets the height of the panel, in pixels. Example: "400px".

func Postfix

func Postfix(postfix string) Option

Postfix sets the text used as postfix of the value.

func PostfixFontSize

func PostfixFontSize(size string) Option

PostfixFontSize sets the size used for the postfix text (eg: "110%")

func Prefix

func Prefix(prefix string) Option

Prefix sets the text used as prefix of the value.

func PrefixFontSize

func PrefixFontSize(size string) Option

PrefixFontSize sets the size used for the prefix text (eg: "110%").

func RangesToText

func RangesToText(mapping []RangeMap) Option

RangesToText allows to translate the value of the summary stat into explicit text.

func ReadOnly

func ReadOnly() Option

ReadOnly marks the graph as non-editable.

func Span

func Span(span float32) Option

Span sets the width of the panel, in grid units. Should be a positive number between 1 and 12. Example: 6.

func SparkLine

func SparkLine() Option

SparkLine displays the spark line summary of the series in addition to the single stat.

func SparkLineColor

func SparkLineColor(color string) Option

SparkLineColor sets the line color of the spark line.

func SparkLineFillColor

func SparkLineFillColor(color string) Option

SparkLineFillColor sets the color the spark line will be filled with.

func SparkLineYMax

func SparkLineYMax(value float64) Option

SparkLineYMax defines the largest value expected on the Y axis of the spark line.

func SparkLineYMin

func SparkLineYMin(value float64) Option

SparkLineYMin defines the smallest value expected on the Y axis of the spark line.

func Thresholds

func Thresholds(values [2]string) Option

Thresholds change the background and value colors dynamically within the panel, depending on the Singlestat value. The threshold is defined by 2 values which represent 3 ranges that correspond to the three colors directly to the right.

func Unit

func Unit(unit string) Option

Unit sets the unit of the data displayed on this axis.

func ValueFontSize

func ValueFontSize(size string) Option

ValueFontSize sets the font size used to display the value (eg: "100%").

func ValueType

func ValueType(valueType StatType) Option

ValueType configures how the series will be reduced to a single value.

func ValuesToText

func ValuesToText(mapping []ValueMap) Option

ValuesToText allows to translate the value of the summary stat into explicit text.

func WithPrometheusTarget

func WithPrometheusTarget(query string, options ...prometheus.Option) Option

WithPrometheusTarget adds a prometheus query to the graph.

type RangeMap

type RangeMap struct {
	From string
	To   string
	Text string
}

RangeMap allows to map a range of values into explicit text.

type SingleStat

type SingleStat struct {
	Builder *sdk.Panel
}

SingleStat represents a single stat panel.

func New

func New(title string, options ...Option) *SingleStat

New creates a new single stat panel.

type StatType

type StatType string

StatType let you set the function that your entire query is reduced into a single value with.

const (
	// Min will return the smallest value in the series.
	Min StatType = "min"

	// Max will return the largest value in the series.
	Max StatType = "max"

	// Avg will return the average of all the non-null values in the series.
	Avg StatType = "avg"

	// Current will return the last value in the series. If the series ends on
	// null the previous value will be used.
	Current StatType = "current"

	// Total will return the sum of all the non-null values in the series.
	Total StatType = "total"

	// First will return the first value in the series.
	First StatType = "first"

	// Delta will return the total incremental increase (of a counter) in the
	// series. An attempt is made to account for counter resets, but this will
	// only be accurate for single instance metrics. Used to show total
	// counter increase in time series.
	Delta StatType = "delta"

	// Diff will return difference between ‘current’ (last value) and ‘first’..
	Diff StatType = "diff"

	// Range will return the difference between ‘min’ and ‘max’. Useful to
	// show the range of change for a gauge..
	Range StatType = "range"
)

type ValueMap

type ValueMap struct {
	Value string
	Text  string
}

ValueMap allows to map a value into explicit text.

Jump to

Keyboard shortcuts

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