storage

package
v0.0.0-...-bdb8b92 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2023 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteSummarizedSamples

func DeleteSummarizedSamples(c context.Context, loc *time.Location, daysToKeep int) error

DeleteSummarizedSamples deletes samples from days that have been "fully" summarized (see GenerateSummaries). Samples from partially-summarized days are never deleted. loc is used to determine day boundaries. daysToKeep defines the number of fully-summarized days for which samples should be retained.

func DoQuery

func DoQuery(c context.Context, w io.Writer, qp QueryParams) error

runQuery runs the query described by qp synchronously and writes a Google Chart API DataTable object to w.

func EvaluateConds

func EvaluateConds(c context.Context, conds []Condition, now time.Time,
	sender string, recipients []string) error

func GenerateSummaries

func GenerateSummaries(c context.Context, now time.Time, fullDayDelay time.Duration) error

GenerateSummaries reads samples and inserts daily and hourly summary entities. now.Location() is used to define day boundaries; hour boundaries are computed based on UTC. fullDayDelay defines how long we wait after the end of a day before assuming that we have all the data we're going to get from it (and not re-summarizing it in the future).

func WriteSamples

func WriteSamples(c context.Context, samples []common.Sample) error

WriteSamples writes samples to datastore.

Types

type Condition

type Condition struct {
	// Source and name associated with sample.
	Source string
	Name   string

	// Operator: one of "eq", "ne", "lt", "gt", "le", "ge", or "ot".
	// "ot" is "older than"; Value is then in seconds.
	Op string

	// Value to compare samples against.
	Value float32
}

Condition describes a condition responsible for triggering an alert.

type QueryGranularity

type QueryGranularity int

QueryGranularity describes types of points used in query results.

const (
	IndividualSample QueryGranularity = iota
	HourlyAverage
	DailyAverage
)

type QueryParams

type QueryParams struct {
	// Labels contains human-readable labels for lines.
	Labels []string

	// SourceNames contains "source|name" pairs describing lines. It must be the
	// same length, and be in the same order, as labels.
	SourceNames []string

	// Start and End describe the inclusive time range for the query.
	Start time.Time
	End   time.Time

	// Granularity describes the type of points to use.
	Granularity QueryGranularity

	// Aggregation describes how many sequential points to average together for
	// each returned point. It has no effect if less than or equal to 1.
	Aggregation int
}

QueryParams describes a query to be performed.

func (*QueryParams) UpdateGranularityAndAggregation

func (qp *QueryParams) UpdateGranularityAndAggregation(
	sampleInterval time.Duration, sampleStart time.Time)

UpdateGranularityAndAggregation updates the Granularity and Aggregation fields based on Start, End, sampleInterval (the typical interval between samples), and sampleStart (an optional timestamp describing the oldest samples that are available).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳