project

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BestSundaySky = SundaySky{1.25, 2.0, 10, 30} // article uses 3.5 for stddev
View Source
var StandardJuricaJade = JuricaJade{1.25, 2.0, 10, 30} // article SundaySky uses 3.5 for stddev

Functions

func DetectProjectCostAnomalies

func DetectProjectCostAnomalies(c *cli.Context, p model.Params) error

DetectProjectCostAnomalies collects 30 days of costs per project to detect a cost Write a report to [DetectProjectCostAnomalies.json] if at lease one anomaly was found.

func QueryPastDays

func QueryPastDays(fqDatasetTableID string, start, end time.Time) string

QueryPastDays returns the query that collects daily cost records between start and end (both including).

func QueryWeeklyIntervalCostAverage added in v0.9.2

func QueryWeeklyIntervalCostAverage(fqDatasetTableID string, projectID string, weeks int, since time.Time) string

Types

type AnomalyDetector added in v0.6.0

type AnomalyDetector interface {
	IsAnomaly(stats *ProjectStats) bool
	String() string
	WindowDays() int
	WithStddevThreshold(t float64) AnomalyDetector
	ChargesPercentage(stats *ProjectStats) float64
}

type AnomalyEvent added in v0.6.0

type AnomalyEvent struct {
	EventID           string    `bigquery:"event_id" `
	EventCreationTime time.Time `bigquery:"event_creation_time" `
	ProjectID         string    `bigquery:"project_id" `
	ProjectName       string    `bigquery:"project_name" `
	Charges           string    `bigquery:"charges" `
	ChargesPercentage string    `bigquery:"charges_percentage" `
	Credits           string    `bigquery:"credits" `
	Mean              string    `bigquery:"mean" `
	StandardDeviation string    `bigquery:"stddev" `
	DetectionDay      time.Time `bigquery:"detection_day" `
	Detector          string    `bigquery:"detector" `
}

type DailyCost

type DailyCost struct {
	Day         time.Time `biguery:"consumption_day" json:"consumption_day" `
	ProjectName string    `bigquery:"project_name" json:"project_name" `
	ProjectID   string    `bigquery:"project_id" json:"project_id" `
	Charges     float64   `bigquery:"charges" json:"charges"`
	Credits     float64   `bigquery:"credits" json:"credits"`
}

func DailyCostFrom

func DailyCostFrom(m map[string]bigquery.Value) DailyCost

type JuricaJade added in v0.9.2

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

func (JuricaJade) ChargesPercentage added in v0.9.2

func (s JuricaJade) ChargesPercentage(stats *ProjectStats) float64

pre: bounds of .Daily is checked

func (JuricaJade) IsAnomaly added in v0.9.2

func (s JuricaJade) IsAnomaly(stats *ProjectStats) bool

func (JuricaJade) String added in v0.9.2

func (s JuricaJade) String() string

func (JuricaJade) WindowDays added in v0.9.2

func (s JuricaJade) WindowDays() int

func (JuricaJade) WithStddevThreshold added in v0.9.2

func (s JuricaJade) WithStddevThreshold(f float64) AnomalyDetector

type ProjectStats

type ProjectStats struct {
	Daily                   []DailyCost `json:"daily" `
	Mean                    float64     `json:"mean" `
	StandardDeviation       float64     `json:"stddev" `
	WeeklyMean              float64     `json:"weekly_mean" `
	WeeklyStandardDeviation float64     `json:"weekly_stddev" `
}

type ProjectStatsReport added in v0.1.1

type ProjectStatsReport struct {
	LastDay                 DailyCost `json:"last_day" `
	ChargesPercentage       float64   `json:"charges_percentage" `
	Mean                    float64   `json:"mean" `
	StandardDeviation       float64   `json:"stddev" `
	Detector                string    `json:"detector" `
	WeeklyMean              float64   `json:"weekly_mean" `
	WeeklyStandardDeviation float64   `json:"weekly_stddev" `
}

type SundaySky

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

https://github.com/SundaySky/cost-anomaly-detector

func (SundaySky) ChargesPercentage added in v0.9.2

func (s SundaySky) ChargesPercentage(stats *ProjectStats) float64

pre: bounds of .Daily is checked

func (SundaySky) IsAnomaly

func (s SundaySky) IsAnomaly(stats *ProjectStats) bool

func (SundaySky) String added in v0.1.1

func (s SundaySky) String() string

func (SundaySky) WindowDays added in v0.9.2

func (s SundaySky) WindowDays() int

func (SundaySky) WithStddevThreshold added in v0.9.2

func (s SundaySky) WithStddevThreshold(f float64) AnomalyDetector

Jump to

Keyboard shortcuts

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