client

package
v1.0.0-alpha Latest Latest
Warning

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

Go to latest
Published: May 28, 2018 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AggregateTotals

func AggregateTotals(totals map[TotalKey]int64, last map[TotalKey]int64) map[RateKey][]int64

func CalculateRates

func CalculateRates(newRates map[RateKey][]int64, oldRates map[RateKey]int64, period int64, ingressPods int64, samples int64) map[RateKey]int64

CalculateRates calculates the moving average rates per service

func TotalRequests

func TotalRequests(podMetrics map[string][]UpstreamMetric) map[TotalKey]int64

Types

type NginxMetricsClient

type NginxMetricsClient struct {
	Label         string
	Port          string
	Path          string
	Duration      time.Duration
	MovingSamples int64
	// contains filtered or unexported fields
}

NginxMetricsClient holds some state about the clients

func NewMetricsClient

func NewMetricsClient(label, port, path string, duration time.Duration, movingSamples int64) *NginxMetricsClient

NewMetricsClient returns a new client and starts collecting metrics

func (*NginxMetricsClient) Do

func (c *NginxMetricsClient) Do()

Do does things

func (*NginxMetricsClient) Fetch

func (c *NginxMetricsClient) Fetch() (map[string][]UpstreamMetric, error)

Fetch gets the values from the current ingress pods

func (*NginxMetricsClient) GetValue

func (c *NginxMetricsClient) GetValue(resource, namespace, name, metricName string) (int64, error)

GetValue returns average requests per second * 100 (i.e. int millis)

func (*NginxMetricsClient) Loop

func (c *NginxMetricsClient) Loop()

Loop does the fetch-and-update loop

func (*NginxMetricsClient) LoopForever

func (c *NginxMetricsClient) LoopForever()

LoopForever starts the regular requests

func (*NginxMetricsClient) Timestamp

func (c *NginxMetricsClient) Timestamp() time.Time

func (*NginxMetricsClient) UpdateRates

func (c *NginxMetricsClient) UpdateRates(podMetrics map[string][]UpstreamMetric)

UpdateRates gets the latest totals and calculates the new rates

type RateKey

type RateKey struct {
	Namespace string
	Service   string
}

RateKey is the key for aggregated rates, which are averaged across all pods

type TotalKey

type TotalKey struct {
	PodIP     string
	Namespace string
	Service   string
}

TotalKey is the indexing of totals from the nginx traffic stats, which vary per pod

type UpstreamMetric

type UpstreamMetric struct {
	Namespace string
	Service   string
	Port      string
	Metric    string
	Value     int64
}

UpstreamMetric captures nginx metrics referring to upstreams

func Parse

func Parse(input io.Reader) ([]UpstreamMetric, error)

Jump to

Keyboard shortcuts

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