Documentation ¶
Overview ¶
Package whisper implements Graphite's Whisper database format
Index ¶
- Constants
- type AggregationMethod
- type Options
- type Retention
- type Retentions
- type TimeSeries
- type TimeSeriesPoint
- type Whisper
- func Create(path string, retentions Retentions, aggregationMethod AggregationMethod, ...) (whisper *Whisper, err error)
- func CreateWithOptions(path string, retentions Retentions, aggregationMethod AggregationMethod, ...) (whisper *Whisper, err error)
- func Open(path string) (whisper *Whisper, err error)
- func (whisper *Whisper) AggregationMethod() string
- func (whisper *Whisper) Close()
- func (whisper *Whisper) Fetch(fromTime, untilTime int) (timeSeries *TimeSeries, err error)
- func (whisper *Whisper) MaxRetention() int
- func (whisper *Whisper) MetadataSize() int
- func (whisper *Whisper) Retentions() []Retention
- func (whisper *Whisper) Size() int
- func (whisper *Whisper) StartTime() int
- func (whisper *Whisper) Update(value float64, timestamp int) (err error)
- func (whisper *Whisper) UpdateMany(points []*TimeSeriesPoint) (err error)
- func (whisper *Whisper) XFilesFactor() float32
Constants ¶
const ( IntSize = 4 FloatSize = 4 Float64Size = 8 PointSize = 12 MetadataSize = 16 ArchiveInfoSize = 12 )
const ( Seconds = 1 Minutes = 60 Hours = 3600 Days = 86400 Weeks = 86400 * 7 Years = 86400 * 365 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AggregationMethod ¶
type AggregationMethod int
const ( Average AggregationMethod = iota + 1 Sum Last Max Min )
type Retention ¶
type Retention struct {
// contains filtered or unexported fields
}
A retention level.
Retention levels describe a given archive in the database. How detailed it is and how far back it records.
func NewRetention ¶
func ParseRetentionDef ¶
Parse a retention definition as you would find in the storage-schemas.conf of a Carbon install. Note that this only parses a single retention definition, if you have multiple definitions (separated by a comma) you will have to split them yourself.
ParseRetentionDef("10s:14d") Retention{10, 120960}
See: http://graphite.readthedocs.org/en/1.0/config-carbon.html#storage-schemas-conf
func (*Retention) MaxRetention ¶
func (*Retention) NumberOfPoints ¶
func (*Retention) SecondsPerPoint ¶
type Retentions ¶
type Retentions []*Retention
func ParseRetentionDefs ¶
func ParseRetentionDefs(retentionDefs string) (Retentions, error)
func (Retentions) Len ¶
func (r Retentions) Len() int
func (Retentions) Swap ¶
func (r Retentions) Swap(i, j int)
type TimeSeries ¶
type TimeSeries struct {
// contains filtered or unexported fields
}
func (*TimeSeries) FromTime ¶
func (ts *TimeSeries) FromTime() int
func (*TimeSeries) Points ¶
func (ts *TimeSeries) Points() []TimeSeriesPoint
func (*TimeSeries) Step ¶
func (ts *TimeSeries) Step() int
func (*TimeSeries) String ¶
func (ts *TimeSeries) String() string
func (*TimeSeries) UntilTime ¶
func (ts *TimeSeries) UntilTime() int
func (*TimeSeries) Values ¶
func (ts *TimeSeries) Values() []float64
type TimeSeriesPoint ¶
type Whisper ¶
type Whisper struct {
// contains filtered or unexported fields
}
Represents a Whisper database file.
func Create ¶
func Create(path string, retentions Retentions, aggregationMethod AggregationMethod, xFilesFactor float32) (whisper *Whisper, err error)
Create a new Whisper database file and write it's header.
func CreateWithOptions ¶
func CreateWithOptions(path string, retentions Retentions, aggregationMethod AggregationMethod, xFilesFactor float32, options *Options) (whisper *Whisper, err error)
CreateWithOptions is more customizable create function
func (*Whisper) AggregationMethod ¶
Return aggregation method
func (*Whisper) Fetch ¶
func (whisper *Whisper) Fetch(fromTime, untilTime int) (timeSeries *TimeSeries, err error)
Fetch a TimeSeries for a given time span from the file.
func (*Whisper) MaxRetention ¶
Return max retention in seconds
func (*Whisper) MetadataSize ¶
Calculate the number of bytes the metadata section will be.
func (*Whisper) Size ¶
Calculate the total number of bytes the Whisper file should be according to the metadata.
func (*Whisper) Update ¶
Update a value in the database.
If the timestamp is in the future or outside of the maximum retention it will fail immediately.
func (*Whisper) UpdateMany ¶
func (whisper *Whisper) UpdateMany(points []*TimeSeriesPoint) (err error)