mongo

package
v0.0.0-...-177a272 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseGenerator

type BaseGenerator struct {
	UseNaive bool
}

BaseGenerator contains settings specific for Mongo database.

func (*BaseGenerator) GenerateEmptyQuery

func (g *BaseGenerator) GenerateEmptyQuery() query.Query

GenerateEmptyQuery returns an empty query.Mongo.

func (*BaseGenerator) NewDevops

func (g *BaseGenerator) NewDevops(start, end time.Time, scale int) (utils.QueryGenerator, error)

NewDevops creates a new devops use case query generator.

func (*BaseGenerator) NewFinance

func (g *BaseGenerator) NewFinance(start, end time.Time, scale int) (utils.QueryGenerator, error)

type Devops

type Devops struct {
	*BaseGenerator
	*devops.Core
}

Devops produces Mongo-specific queries for the devops use case.

func (*Devops) GroupByOrderByLimit

func (d *Devops) GroupByOrderByLimit(qi query.Query)

GroupByOrderByLimit populates a query.Query that has a time WHERE clause, that groups by a truncated date, orders by that date, and takes a limit: SELECT date_trunc('minute', time) AS t, MAX(cpu) FROM cpu WHERE time < '$TIME' GROUP BY t ORDER BY t DESC LIMIT $LIMIT

func (*Devops) GroupByTime

func (d *Devops) GroupByTime(qi query.Query, nHosts, numMetrics int, timeRange time.Duration)

GroupByTime selects the MAX for numMetrics metrics under 'cpu', per minute for nhosts hosts, e.g. in pseudo-SQL:

SELECT minute, max(metric1), ..., max(metricN) FROM cpu WHERE (hostname = '$HOSTNAME_1' OR ... OR hostname = '$HOSTNAME_N') AND time >= '$HOUR_START' AND time < '$HOUR_END' GROUP BY minute ORDER BY minute ASC

func (*Devops) GroupByTimeAndPrimaryTag

func (d *Devops) GroupByTimeAndPrimaryTag(qi query.Query, numMetrics int)

GroupByTimeAndPrimaryTag selects the AVG of numMetrics metrics under 'cpu' per device per hour for a day, e.g. in pseudo-SQL:

SELECT AVG(metric1), ..., AVG(metricN) FROM cpu WHERE time >= '$HOUR_START' AND time < '$HOUR_END' GROUP BY hour, hostname ORDER BY hour, hostname

func (*Devops) HighCPUForHosts

func (d *Devops) HighCPUForHosts(qi query.Query, nHosts int)

HighCPUForHosts populates a query that gets CPU metrics when the CPU has high usage between a time period for a number of hosts (if 0, it will search all hosts), e.g. in pseudo-SQL:

SELECT * FROM cpu WHERE usage_user > 90.0 AND time >= '$TIME_START' AND time < '$TIME_END' AND (hostname = '$HOST' OR hostname = '$HOST2'...)

func (*Devops) LastPointPerHost

func (d *Devops) LastPointPerHost(qi query.Query)

LastPointPerHost finds the last row for every host in the dataset

func (*Devops) MaxAllCPU

func (d *Devops) MaxAllCPU(qi query.Query, nHosts int, duration time.Duration)

MaxAllCPU selects the MAX of all metrics under 'cpu' per hour for nhosts hosts, e.g. in pseudo-SQL:

SELECT MAX(metric1), ..., MAX(metricN) FROM cpu WHERE (hostname = '$HOSTNAME_1' OR ... OR hostname = '$HOSTNAME_N') AND time >= '$HOUR_START' AND time < '$HOUR_END' GROUP BY hour ORDER BY hour

type Finance

type Finance struct {
	*BaseGenerator
	*finance.Core
}

func (*Finance) ExponentialMovingAverage

func (f *Finance) ExponentialMovingAverage(q query.Query, span, interval time.Duration, points int)

func (*Finance) LastPrice

func (f *Finance) LastPrice(q query.Query)

func (*Finance) MACD

func (f *Finance) MACD(q query.Query, span, interval time.Duration, firstPoints, secondPoints, signalPoints int)

func (*Finance) MovingAverage

func (f *Finance) MovingAverage(q query.Query, span, interval time.Duration, points int)

func (*Finance) RSI

func (f *Finance) RSI(q query.Query, span, interval time.Duration, points int)

func (*Finance) StochasticOscillator

func (f *Finance) StochasticOscillator(q query.Query, span, interval time.Duration, points int)

func (*Finance) TopPercentChange

func (f *Finance) TopPercentChange(q query.Query, span, interval time.Duration)

type NaiveDevops

type NaiveDevops struct {
	*BaseGenerator
	*devops.Core
}

NaiveDevops produces Mongo-specific queries for the devops use case.

func (*NaiveDevops) GroupByOrderByLimit

func (d *NaiveDevops) GroupByOrderByLimit(qi query.Query)

GroupByOrderByLimit populates a query.Query that has a time WHERE clause, that groups by a truncated date, orders by that date, and takes a limit, e.g. in pseudo-SQL:

SELECT minute, MAX(usage_user) FROM cpu WHERE time < '$TIME' GROUP BY minute ORDER BY minute DESC LIMIT $LIMIT

func (*NaiveDevops) GroupByTime

func (d *NaiveDevops) GroupByTime(qi query.Query, nHosts, numMetrics int, timeRange time.Duration)

GroupByTime selects the MAX for numMetrics metrics under 'cpu', per minute for nhosts hosts, e.g. in pseudo-SQL:

SELECT minute, max(metric1), ..., max(metricN) FROM cpu WHERE (hostname = '$HOSTNAME_1' OR ... OR hostname = '$HOSTNAME_N') AND time >= '$HOUR_START' AND time < '$HOUR_END' GROUP BY minute ORDER BY minute ASC

func (*NaiveDevops) GroupByTimeAndPrimaryTag

func (d *NaiveDevops) GroupByTimeAndPrimaryTag(qi query.Query, numMetrics int)

GroupByTimeAndPrimaryTag selects the AVG of numMetrics metrics under 'cpu' per device per hour for a day, e.g. in pseudo-SQL:

SELECT AVG(metric1), ..., AVG(metricN) FROM cpu WHERE time >= '$HOUR_START' AND time < '$HOUR_END' GROUP BY hour, hostname ORDER BY hour, hostname

func (*NaiveDevops) HighCPUForHosts

func (d *NaiveDevops) HighCPUForHosts(qi query.Query, nHosts int)

HighCPUForHosts populates a query that gets CPU metrics when the CPU has high usage between a time period for a number of hosts (if 0, it will search all hosts), e.g. in pseudo-SQL:

SELECT * FROM cpu WHERE usage_user > 90.0 AND time >= '$TIME_START' AND time < '$TIME_END' AND (hostname = '$HOST' OR hostname = '$HOST2'...)

func (*NaiveDevops) LastPointPerHost

func (d *NaiveDevops) LastPointPerHost(qi query.Query)

SELECT DISTINCT ON (hostname) * FROM cpu ORDER BY hostname, time DESC

func (*NaiveDevops) MaxAllCPU

func (d *NaiveDevops) MaxAllCPU(qi query.Query, nHosts int, duration time.Duration)

MaxAllCPU selects the MAX of all metrics under 'cpu' per hour for nhosts hosts, e.g. in pseudo-SQL:

SELECT MAX(metric1), ..., MAX(metricN) FROM cpu WHERE (hostname = '$HOSTNAME_1' OR ... OR hostname = '$HOSTNAME_N') AND time >= '$HOUR_START' AND time < '$HOUR_END' GROUP BY hour ORDER BY hour

Jump to

Keyboard shortcuts

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