prometheus

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2018 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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) GetNamespaceMetrics

func (in *Client) GetNamespaceMetrics(query *NamespaceMetricsQuery) Metrics

GetNamespaceMetrics returns the Metrics described by the optional service pattern ("" for all), and optional version, for the given namespace. Use GetServiceMetrics if you don't need pattern matching.

func (*Client) GetNamespaceServicesRequestRates

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

GetNamespaceServicesRequestRates queries Prometheus to fetch request counters rates over a time interval for each service, both in and out. Returns (in, out, error)

func (*Client) GetServiceHealth

func (in *Client) GetServiceHealth(namespace string, servicename string) (EnvoyHealth, error)

GetServiceHealth returns the Health related to the provided service identified by its namespace and service name. It reads Envoy metrics, inbound and outbound When the health is unavailable, total number of members will be 0.

func (*Client) GetServiceMetrics

func (in *Client) GetServiceMetrics(query *ServiceMetricsQuery) Metrics

GetServiceMetrics returns the Metrics related to the provided service identified by its namespace and service name.

func (*Client) GetServiceRequestRates

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

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

func (*Client) GetSourceServices

func (in *Client) GetSourceServices(namespace string, servicename string) (map[string][]string, error)

GetSourceServices returns a map of list of source services for a given service identified by its namespace and service name. Returned map has a destination version as a key and a list of "<origin service>/<origin version>" pairs as values. Destination service is not included in the map as it is passed as argument. It returns an error on any problem.

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 {
	GetServiceHealth(namespace string, servicename string) (EnvoyHealth, error)
	GetNamespaceServicesRequestRates(namespace string, ratesInterval string) (model.Vector, model.Vector, error)
	GetServiceRequestRates(namespace, service string, ratesInterval string) (model.Vector, model.Vector, error)
	GetSourceServices(namespace string, servicename string) (map[string][]string, error)
}

ClientInterface for mocks (only mocked function are necessary here)

type EnvoyHealth

type EnvoyHealth struct {
	Inbound  EnvoyRatio `json:"inbound"`
	Outbound EnvoyRatio `json:"outbound"`
}

EnvoyHealth is the number of healthy versus total membership (ie. replicas) inside envoy cluster (ie. service)

type EnvoyRatio

type EnvoyRatio struct {
	Healthy int `json:"healthy"`
	Total   int `json:"total"`
}

EnvoyRatio is the number of healthy members versus total members

type Histogram

type Histogram struct {
	Average      *Metric `json:"average"`
	Median       *Metric `json:"median"`
	Percentile95 *Metric `json:"percentile95"`
	Percentile99 *Metric `json:"percentile99"`
}

Histogram contains Metric objects for several histogram-kind statistics

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 health, all simple metrics and histograms data

type MetricsQuery

type MetricsQuery struct {
	v1.Range
	Version      string
	RateInterval string
	RateFunc     string
	Filters      []string
	ByLabelsIn   []string
	ByLabelsOut  []string
	IncludeIstio bool
}

MetricsQuery is a common struct for ServiceMetricsQuery and NamespaceMetricsQuery

func (*MetricsQuery) FillDefaults

func (q *MetricsQuery) FillDefaults()

FillDefaults fills the struct with default parameters

type NamespaceMetricsQuery

type NamespaceMetricsQuery struct {
	MetricsQuery
	Namespace      string
	ServicePattern string
}

NamespaceMetricsQuery contains fields used for querying namespace metrics

type ServiceMetricsQuery

type ServiceMetricsQuery struct {
	MetricsQuery
	Namespace string
	Service   string
}

ServiceMetricsQuery contains fields used for querying a service metrics

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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