analytics

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2020 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	APNLabel       = "apn"
	DaysLabel      = "days"
	DirectionLabel = "direction"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type APThroughputCalculation

type APThroughputCalculation struct {
	CalculationParams
	QueryStepSize time.Duration
	Direction     ConsumptionDirection
}

func (*APThroughputCalculation) Calculate

func (x *APThroughputCalculation) Calculate(prometheusClient PrometheusAPI) ([]Result, error)

type Analyzer

type Analyzer interface {
	// Schedule the analyzer to run calculations periodically based on the
	// cron expression format schedule parameter
	Schedule(schedule string) error

	// Run triggers the analyzer's cronjob to start running. This function
	// blocks.
	Run()
}

func NewPrometheusAnalyzer

func NewPrometheusAnalyzer(prometheusClient v1.API, calculations []Calculation, exporter Exporter) Analyzer

type Calculation

type Calculation interface {
	Calculate(PrometheusAPI) ([]Result, error)
}

type CalculationParams

type CalculationParams struct {
	Days            int
	RegisteredGauge *prometheus.GaugeVec
	Labels          prometheus.Labels
	Name            string
}

type ConsumptionDirection

type ConsumptionDirection string
const (
	ConsumptionIn  ConsumptionDirection = "in"
	ConsumptionOut ConsumptionDirection = "out"
)

type Exporter

type Exporter interface {
	Export(Result, HttpClient) error
}

func NewWWWExporter

func NewWWWExporter(metricsPrefix, appSecret, appID, metricExportURL, categoryName string) Exporter

type HttpClient

type HttpClient interface {
	PostForm(url string, data url.Values) (resp *http.Response, err error)
}

type PrometheusAPI

type PrometheusAPI interface {
	Query(ctx context.Context, query string, ts time.Time) (model.Value, api.Warnings, error)
	QueryRange(ctx context.Context, query string, r v1.Range) (model.Value, api.Warnings, error)
}

type PrometheusAnalyzer

type PrometheusAnalyzer struct {
	Cron             *cron.Cron
	PrometheusClient PrometheusAPI
	Calculations     []Calculation
	Exporter         Exporter
}

PrometheusAnalyzer accesses prometheus metrics and performs queries/aggregations to calculate various metrics

func (*PrometheusAnalyzer) Analyze

func (a *PrometheusAnalyzer) Analyze()

func (*PrometheusAnalyzer) Run

func (a *PrometheusAnalyzer) Run()

func (*PrometheusAnalyzer) Schedule

func (a *PrometheusAnalyzer) Schedule(schedule string) error

type Result

type Result struct {
	// contains filtered or unexported fields
}

type UserConsumptionCalculation

type UserConsumptionCalculation struct {
	CalculationParams
	Direction ConsumptionDirection
}

func (*UserConsumptionCalculation) Calculate

func (x *UserConsumptionCalculation) Calculate(prometheusClient PrometheusAPI) ([]Result, error)

type UserThroughputCalculation

type UserThroughputCalculation struct {
	CalculationParams
	QueryStepSize time.Duration
	Direction     ConsumptionDirection
}

func (*UserThroughputCalculation) Calculate

func (x *UserThroughputCalculation) Calculate(prometheusClient PrometheusAPI) ([]Result, error)

type XAPCalculation

type XAPCalculation struct {
	CalculationParams
	ThresholdBytes int
}

XAPCalculation holds the parameters needed to run a XAP query and the registered prometheus gauge that the resulting value should be stored in

func (*XAPCalculation) Calculate

func (x *XAPCalculation) Calculate(prometheusClient PrometheusAPI) ([]Result, error)

Calculate returns the number of unique users who have had a session in the past X days and have used over `thresholdBytes` data in that time

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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