Documentation
¶
Overview ¶
Package pointstores contains the implementation of all the supported storage adapters for the series
Index ¶
- type ElasticAdapter
- func (ea ElasticAdapter) AddPoint(name string, p Point) error
- func (ea ElasticAdapter) AddSeries(name string, sample Point, retentionDays int) error
- func (ea ElasticAdapter) DeleteSeries(name string) error
- func (ea ElasticAdapter) Exists(name string) (bool, error)
- func (ea ElasticAdapter) GetCount(name string, labels map[string]string) (int, error)
- func (ea ElasticAdapter) GetLastN(name string, labels map[string]string, n int) ([]Point, error)
- func (ea ElasticAdapter) GetLatest(name string, labels map[string]string) (Point, error)
- func (ea ElasticAdapter) ListSeries() ([]types.BriefSeries, error)
- func (ea ElasticAdapter) LoadTestSet(name, path string) error
- type FileAdapter
- func (fa FileAdapter) AddPoint(name string, p Point) error
- func (fa FileAdapter) AddSeries(name string, sample Point, retentionDays int) error
- func (fa FileAdapter) DeleteSeries(name string) error
- func (fa FileAdapter) Exists(name string) (bool, error)
- func (fa FileAdapter) GetCount(name string, labels map[string]string) (int, error)
- func (fa FileAdapter) GetLastN(name string, labels map[string]string, n int) ([]Point, error)
- func (fa FileAdapter) GetLatest(name string, labels map[string]string) (Point, error)
- func (fa FileAdapter) ListSeries() ([]types.BriefSeries, error)
- func (fa FileAdapter) LoadTestSet(name string) ([]Point, error)
- type Point
- type PointStore
- type QResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ElasticAdapter ¶
type ElasticAdapter struct {
// contains filtered or unexported fields
}
ElasticAdapter is a point store implementation for Elasticsearch
func NewElasticAdapter ¶
func NewElasticAdapter(sp config.SeriesParams) (*ElasticAdapter, error)
NewElasticAdapter returns an initialized Elasticsearch point store
func (ElasticAdapter) AddPoint ¶
func (ea ElasticAdapter) AddPoint(name string, p Point) error
AddPoint upserts a measurement into the index of a given series
func (ElasticAdapter) AddSeries ¶
func (ea ElasticAdapter) AddSeries(name string, sample Point, retentionDays int) error
AddSeries creates and configures a new index in Elasticsearch to hold a time series
func (ElasticAdapter) DeleteSeries ¶
func (ea ElasticAdapter) DeleteSeries(name string) error
DeleteSeries removes the index used to store a series
func (ElasticAdapter) Exists ¶
func (ea ElasticAdapter) Exists(name string) (bool, error)
Exists returns true if an index for the specified series is present in Elasticsearch, false if not or in case of error (make sure to check if error is nil before looking at the boolean)
func (ElasticAdapter) GetCount ¶
GetCount retrieves the number of points recorded for the given series with the specified labels (returns 0 if the series doesn't exist)
func (ElasticAdapter) GetLastN ¶
GetLastN retrieves the last N points for the given series with the specified labels
func (ElasticAdapter) GetLatest ¶
GetLatest retrieves the most recent value of the series with the specified labels
func (ElasticAdapter) ListSeries ¶
func (ea ElasticAdapter) ListSeries() ([]types.BriefSeries, error)
ListSeries as its name implies, returns a list of all the series that are available in Elasticsearch
func (ElasticAdapter) LoadTestSet ¶
func (ea ElasticAdapter) LoadTestSet(name, path string) error
LoadTestSet loads a set of points from a single file for testing (not part of the standard PointStore interface)
type FileAdapter ¶
type FileAdapter struct {
Path string
}
FileAdapter is a point store implementation that uses the filesystem. Its main purpose is to facilitate testing, given its low performance it is strongly discouraged for production use
func NewFileAdapter ¶
func NewFileAdapter(conf map[string]interface{}) (*FileAdapter, error)
NewFileAdapter returns an initialized file point store object
func (FileAdapter) AddPoint ¶
func (fa FileAdapter) AddPoint(name string, p Point) error
AddPoint creates a new file with the JSON representation of the point in the subdirectory that corresponds to the given series
func (FileAdapter) AddSeries ¶
func (fa FileAdapter) AddSeries(name string, sample Point, retentionDays int) error
AddSeries creates a directory to hold a time series
func (FileAdapter) DeleteSeries ¶
func (fa FileAdapter) DeleteSeries(name string) error
DeleteSeries removes the subdirectory used to store a series
func (FileAdapter) Exists ¶
func (fa FileAdapter) Exists(name string) (bool, error)
Exists returns true if a directory is present for the specified series, false if not or in case of error
func (FileAdapter) GetCount ¶
GetCount retrieves the number of points recorded for the given series (labels are ignored in this adapter for speed) (returns 0 if the series doesn't exist)
func (FileAdapter) GetLatest ¶
GetLatest returns the most recent value of the series by looking for the most recent file in its subdir
func (FileAdapter) ListSeries ¶
func (fa FileAdapter) ListSeries() ([]types.BriefSeries, error)
ListSeries returns a list of all the available series in the configured directory
func (FileAdapter) LoadTestSet ¶
func (fa FileAdapter) LoadTestSet(name string) ([]Point, error)
LoadTestSet loads a set of points from a single file for testing (not part of the standard PointStore interface)
type Point ¶
Point represents a single measurement in a time series
func (Point) MarshalJSON ¶
MarshalJSON is required for flattening the struct
func (*Point) UnmarshalJSON ¶
UnmarshalJSON makes sure that we can recover a point struct from a flattened representation
type PointStore ¶
type PointStore interface { // Adds a point to a series, should create it if it doesn't exist (calling AddSeries) AddPoint(name string, p Point) error // Create a new series AddSeries(name string, sample Point, retentionDays int) error // Delete a series DeleteSeries(name string) error Exists(name string) (bool, error) GetCount(name string, labels map[string]string) (int, error) // Gets the current value of the series GetLatest(name string, labels map[string]string) (Point, error) GetLastN(name string, labels map[string]string, n int) ([]Point, error) // Get list of available series ListSeries() ([]types.BriefSeries, error) }
PointStore is an abstraction over the storage service that will be used to store the measurements taken from envs
type QResponse ¶
type QResponse struct { Took int `json:"took"` TimedOut bool `json:"timed_out"` Hits struct { Total struct { Value int `json:"value"` Relation string `json:"relation"` } `json:"total"` Hits []struct { Index string `json:"_index"` ID string `json:"_id"` P Point `json:"_source"` } `json:"hits"` } `json:"hits"` }
QResponse is used to facilitate parsing Elasticsearch point query responses