prometheus

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2019 License: Apache-2.0 Imports: 14 Imported by: 81

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseMetricsQuery added in v0.12.0

type BaseMetricsQuery struct {
	v1.Range
	RateInterval string
	RateFunc     string
	Quantiles    []string
	Avg          bool
	ByLabels     []string
}

BaseMetricsQuery holds common parameters for all kinds of queries

type Client

type Client struct {
	ClientInterface
	// contains filtered or unexported fields
}

Client for Prometheus API. It hides the way we query Prometheus offering a layer with a high level defined API.

func NewClient

func NewClient() (*Client, error)

NewClient creates a new client to the Prometheus API. It returns an error on any problem.

func (*Client) API

func (in *Client) API() v1.API

API returns the Prometheus V1 HTTP API for performing calls not supported natively by this client

func (*Client) Address

func (in *Client) Address() string

Address return the configured Prometheus service URL

func (*Client) FetchHistogramRange added in v0.12.0

func (in *Client) FetchHistogramRange(metricName, labels, grouping string, q *BaseMetricsQuery) Histogram

FetchHistogramRange fetches bucketed metric as histogram in given range

func (*Client) FetchRange added in v0.14.0

func (in *Client) FetchRange(metricName, labels, grouping, aggregator string, q *BaseMetricsQuery) *Metric

FetchRange fetches a simple metric (gauge or counter) in given range

func (*Client) FetchRateRange added in v0.12.0

func (in *Client) FetchRateRange(metricName, labels, grouping string, q *BaseMetricsQuery) *Metric

FetchRateRange fetches a counter's rate in given range

func (*Client) GetAllRequestRates added in v0.6.0

func (in *Client) GetAllRequestRates(namespace string, ratesInterval string, queryTime time.Time) (model.Vector, error)

GetAllRequestRates queries Prometheus to fetch request counter rates, over a time interval, for requests into, internal to, or out of the namespace. Returns (rates, error)

func (*Client) GetAppRequestRates added in v0.6.0

func (in *Client) GetAppRequestRates(namespace, app, ratesInterval string, queryTime time.Time) (model.Vector, model.Vector, error)

GetAppRequestRates queries Prometheus to fetch request counters rates over a time interval for a given app, both in and out. Returns (in, out, error)

func (*Client) GetConfiguration added in v0.15.0

func (in *Client) GetConfiguration() (v1.ConfigResult, error)

func (*Client) GetDestinationServices added in v0.11.0

func (in *Client) GetDestinationServices(namespace string, namespaceCreationTime time.Time, workloadname string) ([]Service, error)

func (*Client) GetFlags added in v0.15.0

func (in *Client) GetFlags() (v1.FlagsResult, error)

func (*Client) GetMetrics added in v0.6.0

func (in *Client) GetMetrics(query *IstioMetricsQuery) Metrics

GetMetrics returns the Metrics related to the provided query options.

func (*Client) GetNamespaceServicesRequestRates

func (in *Client) GetNamespaceServicesRequestRates(namespace string, ratesInterval string, queryTime time.Time) (model.Vector, error)

GetNamespaceServicesRequestRates queries Prometheus to fetch request counter rates, over a time interval, limited to requests for services in the namespace. Returns (rates, error)

func (*Client) GetServiceRequestRates

func (in *Client) GetServiceRequestRates(namespace, service, ratesInterval string, queryTime time.Time) (model.Vector, error)

GetServiceRequestRates queries Prometheus to fetch request counters rates over a time interval for a given service (hence only inbound). Returns (in, error)

func (*Client) GetSourceWorkloads added in v0.6.0

func (in *Client) GetSourceWorkloads(namespace string, namespaceCreationTime time.Time, servicename string) (map[string][]Workload, error)

GetSourceWorkloads returns a map of list of source workloads for a given service identified by its namespace and service name. Returned map has a destination version as a key and a list of workloads as values. It returns an error on any problem.

func (*Client) GetWorkloadRequestRates added in v0.6.0

func (in *Client) GetWorkloadRequestRates(namespace, workload, ratesInterval string, queryTime time.Time) (model.Vector, model.Vector, error)

GetWorkloadRequestRates queries Prometheus to fetch request counters rates over a time interval for a given workload, both in and out. Returns (in, out, error)

func (*Client) Inject

func (in *Client) Inject(api v1.API)

Inject allows for replacing the API with a mock For testing

type ClientInterface

type ClientInterface interface {
	FetchHistogramRange(metricName, labels, grouping string, q *BaseMetricsQuery) Histogram
	FetchRange(metricName, labels, grouping, aggregator string, q *BaseMetricsQuery) *Metric
	FetchRateRange(metricName, labels, grouping string, q *BaseMetricsQuery) *Metric
	GetAllRequestRates(namespace, ratesInterval string, queryTime time.Time) (model.Vector, error)
	GetAppRequestRates(namespace, app, ratesInterval string, queryTime time.Time) (model.Vector, model.Vector, error)
	GetConfiguration() (v1.ConfigResult, error)
	GetDestinationServices(namespace string, namespaceCreationTime time.Time, workloadname string) ([]Service, error)
	GetFlags() (v1.FlagsResult, error)
	GetMetrics(query *IstioMetricsQuery) Metrics
	GetNamespaceServicesRequestRates(namespace, ratesInterval string, queryTime time.Time) (model.Vector, error)
	GetServiceRequestRates(namespace, service, ratesInterval string, queryTime time.Time) (model.Vector, error)
	GetSourceWorkloads(namespace string, namespaceCreationTime time.Time, servicename string) (map[string][]Workload, error)
	GetWorkloadRequestRates(namespace, workload, ratesInterval string, queryTime time.Time) (model.Vector, model.Vector, error)
}

ClientInterface for mocks (only mocked function are necessary here)

type CustomMetricsQuery added in v0.12.0

type CustomMetricsQuery struct {
	BaseMetricsQuery
	Namespace         string
	App               string
	Version           string
	RawDataAggregator string
}

CustomMetricsQuery holds query parameters for a custom metrics query

func (*CustomMetricsQuery) FillDefaults added in v0.12.0

func (q *CustomMetricsQuery) FillDefaults()

FillDefaults fills the struct with default parameters

type Histogram

type Histogram = map[string]*Metric

Histogram contains Metric objects for several histogram-kind statistics

type IstioMetricsQuery added in v0.12.0

type IstioMetricsQuery struct {
	BaseMetricsQuery
	Filters         []string
	Namespace       string
	App             string
	Workload        string
	Service         string
	Direction       string // outbound | inbound
	RequestProtocol string // e.g. http | grpc
	Reporter        string // source | destination, defaults to source if not provided
}

IstioMetricsQuery holds query parameters for a typical metrics query

func (*IstioMetricsQuery) FillDefaults added in v0.12.0

func (q *IstioMetricsQuery) FillDefaults()

FillDefaults fills the struct with default parameters

type Metric

type Metric struct {
	Matrix model.Matrix `json:"matrix"`
	// contains filtered or unexported fields
}

Metric holds the Prometheus Matrix model, which contains one or more time series (depending on grouping)

type Metrics

type Metrics struct {
	Metrics    map[string]*Metric   `json:"metrics"`
	Histograms map[string]Histogram `json:"histograms"`
}

Metrics contains all simple metrics and histograms data

type Service added in v0.11.0

type Service struct {
	Namespace   string
	App         string
	ServiceName string
}

Service describes a service with contextual information

type Workload added in v0.6.0

type Workload struct {
	Namespace string
	App       string
	Workload  string
	Version   string
}

Workload describes a workload with contextual information

Directories

Path Synopsis
Package internalmetrics provides functionality to collect Prometheus metrics.
Package internalmetrics provides functionality to collect Prometheus metrics.

Jump to

Keyboard shortcuts

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