top

package
v0.0.0-...-2a235c3 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

top provides the functionality for constructing a PromQL query given the predefined set of metrics in targetMetrics. The type of query is specified via the Config.QueryType. Supported queries are 95%ile over time, average over time, and instantaneous, for each metric. Thus, the query/metric matrix is as follows, where only 1 vertex is executed per invocation.

| 95%-ile | or | Avg | or | Instant |

CPU |_________| or |_____| or |_________| Memory |_________| or |_____| or |_________| FS I/O |_________| or |_____| or |_________| Net Send |_________| or |_____| or |_________| Net Rcv |_________| or |_____| or |_________|

Top supports only a small subset of functionality of PromQL. Queries are deliberately geared to return InstantVectors. A vector instance is essentially a scalar value and a timestamp. Thus, the queries used here MAY span a range of time, but MUST return a single vector representation of the measurement. For instance, the average bytes of memory consumed over the last 10 minutes is an InstantVector. However, the average bytes of memory consumed, read at steps of 1 second over 10 minutes, would produce a RangeVector:a series of InstantVectors representing the moment to moment average value. See https://prometheus.io/docs/prometheus/latest/querying/basics/#expression-language-data-types for more info on promQL vector types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Context context.Context
	// QueryType must specify the query to be executed, defaults to Instant
	QueryType string `json:"queryType"`
	// Range (optional) defines a span of time from (time.Now() - Range) until time.Now()
	// Ignored by Instant query.
	// Input must adhere to Prometheus time format where time is an int and time unit is a single character.
	// Time units are
	//   ms milliseconds
	//   s = seconds
	//   m = minutes
	//   h = hours
	//   d = days
	//   w = weeks
	//   m = months
	//   y = years
	// The time format concatenates the int and unit: ##unit, e.g. 10 minutes == 10m
	Range string `json:"range,omitempty"`
	// PrometheusClient must be an initialized prometheus client
	PrometheusClient v1.API `json:"prometheusClient"`
}

type PodMetric

type PodMetric dbhandler.Row

func (PodMetric) MarshalCSV

func (p PodMetric) MarshalCSV() []byte

func (PodMetric) String

func (p PodMetric) String() string

type PodMetricTable

type PodMetricTable []*PodMetric

func Top

func Top(cfg Config) (PodMetricTable, error)

Top executes the specified query against targetMetrics and returns a slice of Prometheus InstantVertices. An instantVertex is a point-in-time data structure containing the metric values for all reporting components. Thus, Top is not intended for continuous monitoring.

func (PodMetricTable) MarshalCSV

func (pm PodMetricTable) MarshalCSV() []byte

Jump to

Keyboard shortcuts

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