Documentation ¶
Overview ¶
Package tsdb manages everything related to the time-series database. This database will be used to store and retrieve monitoring metrics.
Index ¶
- Constants
- type Activity
- type AlertEvent
- type Entry
- type EventValue
- type InfluxTSDB
- func (tsdb *InfluxTSDB) AddActivity(activity Activity) error
- func (tsdb *InfluxTSDB) AddAlertEvent(alert AlertEvent) error
- func (tsdb *InfluxTSDB) AddResults(results []Result) error
- func (tsdb *InfluxTSDB) AddState(state State) error
- func (tsdb *InfluxTSDB) GetActivity(organization uuid.UUID, agent uuid.UUID, opts ...QueryOption) ([]Activity, error)
- func (tsdb *InfluxTSDB) GetAlertEvents(probeConfigurations []uuid.UUID, opts ...QueryOption) ([]AlertEvent, error)
- func (tsdb *InfluxTSDB) GetResults(check uuid.UUID, opts ...QueryOption) ([]Result, error)
- func (tsdb *InfluxTSDB) GetStates(checks []uuid.UUID, opts ...QueryOption) ([]State, error)
- type Order
- type QueryOption
- type Result
- type State
- type TSDB
Constants ¶
const ( // EventValueNotified encodes a "notified" event EventValueNotified = EventValue(api.Event_NOTIFIED) // EventValueAcknowledged encodes an "acknowledged" event EventValueAcknowledged = EventValue(api.Event_ACKNOWLEDGED) // EventValueSnoozed encodes a "snoozed" event EventValueSnoozed = EventValue(api.Event_SNOOZED) )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AlertEvent ¶
type AlertEvent struct { Entry Event EventValue }
AlertEvent contains the data from an alert event in the TSDB.
type Entry ¶
type Entry struct { Timestamp time.Time Organization uuid.UUID ProbeConfiguration uuid.UUID Probe uuid.UUID Agent uuid.UUID Check uuid.UUID Target uuid.UUID }
Entry is a generic structure containing data common to all TSDB entries (probe results, states, alert events). It is meant to be embedded in each specific structure and serve as a kind of "abstract base class".
type EventValue ¶
type EventValue int
EventValue encodes a value evaluated for an event
func EventValueFromString ¶
func EventValueFromString(s string) (ev EventValue, err error)
EventValueFromString convert a string in EventValue
func (EventValue) String ¶
func (ev EventValue) String() string
type InfluxTSDB ¶
type InfluxTSDB struct {
// contains filtered or unexported fields
}
InfluxTSDB is a concrete implementation of `tsdb.TSDB` that uses InfluxDB as a time-series database.
func NewInfluxTSDB ¶
func NewInfluxTSDB(address, database string) (*InfluxTSDB, error)
NewInfluxTSDB creates a new connection to an InfluxDB TSDB. The `database` argument is the name of the database to `USE` inside InfluxDB.
func (*InfluxTSDB) AddActivity ¶
func (tsdb *InfluxTSDB) AddActivity(activity Activity) error
AddActivity adds an activity into the TSDB
func (*InfluxTSDB) AddAlertEvent ¶
func (tsdb *InfluxTSDB) AddAlertEvent(alert AlertEvent) error
AddAlertEvent adds a new alert event to the TSDB.
func (*InfluxTSDB) AddResults ¶
func (tsdb *InfluxTSDB) AddResults(results []Result) error
AddResults adds a batch of results from a check to the TSDB.
func (*InfluxTSDB) AddState ¶
func (tsdb *InfluxTSDB) AddState(state State) error
AddState adds a state computed from a probe result into the TSDB
func (*InfluxTSDB) GetActivity ¶
func (tsdb *InfluxTSDB) GetActivity(organization uuid.UUID, agent uuid.UUID, opts ...QueryOption) ([]Activity, error)
GetActivity retrieves the activity for an agent from the TSDB.
func (*InfluxTSDB) GetAlertEvents ¶
func (tsdb *InfluxTSDB) GetAlertEvents(probeConfigurations []uuid.UUID, opts ...QueryOption) ([]AlertEvent, error)
GetAlertEvents retrieves the alert events for a probeConfiguration from the TSDB.
func (*InfluxTSDB) GetResults ¶
func (tsdb *InfluxTSDB) GetResults(check uuid.UUID, opts ...QueryOption) ([]Result, error)
GetResults retrieves results from the TSDB following the given filters
func (*InfluxTSDB) GetStates ¶
func (tsdb *InfluxTSDB) GetStates(checks []uuid.UUID, opts ...QueryOption) ([]State, error)
GetStates retrieves the states for a check from the TSDB.
type QueryOption ¶
type QueryOption func(*queryOptions)
QueryOption is used to configure queries on the TSDB
func Count ¶
func Count(c int) QueryOption
Count returns a QueryOption that defines a maximum number of results from the TSDB query.
func Field ¶
func Field(k, v string) QueryOption
Field returns a QueryOption that specifies a column-value pair that the results from the TSDB must match.
func From ¶
func From(t time.Time) QueryOption
From returns a QueryOption that defines a lower time bound to the results of the TSDB query. The query will return results starting after and including the given time.
func GroupBy ¶
func GroupBy(g string) QueryOption
GroupBy returns a QueryOption that defines the grouping of the results from the TSDB query.
func Offset ¶
func Offset(o int) QueryOption
Offset returns a QueryOption that offsets the result set from the TSDB query. Used for pagination.
func OrderBy ¶
func OrderBy(o Order) QueryOption
OrderBy returns a QueryOption that defines the ordering according to time of the results from the TSDB query.
func Tag ¶
func Tag(k string, v ...string) QueryOption
Tag returns a QueryOption that specifies a column-value pair that the results from the TSDB must match.
func To ¶
func To(t time.Time) QueryOption
To returns a QueryOption that defines an upper time bound to the results of the TSDB query. The query will return results before and not including the given time.
type Result ¶
Result contains all the data for the server to enter a result from a probe into the time-series database.
type TSDB ¶
type TSDB interface { AddResults(results []Result) error GetResults(check uuid.UUID, opts ...QueryOption) ([]Result, error) AddState(state State) error GetStates(checks []uuid.UUID, opts ...QueryOption) ([]State, error) AddAlertEvent(alert AlertEvent) error GetAlertEvents(probeConfigurations []uuid.UUID, opts ...QueryOption) ([]AlertEvent, error) AddActivity(activity Activity) error GetActivity(organization uuid.UUID, agent uuid.UUID, opts ...QueryOption) ([]Activity, error) }
TSDB represents an abstract time-series database.