/ unidist / timeseries
timeseries
By Geoff Howland
A wrapper for dealing with time series data. Creates storage, stores, fetches,
and graphs.
Currently wrapped time series backends:
TODO(g): Create more than a thin wrapper around RRD. This is fine for now, but
it should be abstracted enough that any backend can be used, and even
alternative graphing methods could be used with RRD.
Functions
|
|
|
Graph
|
Graph (
filename,
image_filename,
create_fields,
graph_fields,
method,
title,
label_vertical,
defaults_path=TIME_SERIES_DEFAULTS,
)
Graph a timeseries file.
Args:
filename: string, path to timeseries (RRD) file
image_filename: string, path to render to
create_fields: dict, the same data passed to the Create() method
graph_fields: list of strings, ordered field names to graph
method: string, valid: STACK, ... (TODO(g): Implement more!)
title: string, title of graph
label_vertical: string, label written vertically on left of graph
defaults_path: string (optional), override time series defaults
|
|
Create
|
Create (
filename,
interval,
create_fields,
defaults_path=TIME_SERIES_DEFAULTS,
)
Create a time series file.
Args:
filename: string
interval: int, seconds between saving time series data points
create_fields: dict, fields and information about them for creation
defaults_path: string (optional), path to YAML file with time series
backend (ex. RRD) data
Returns: int, status of command run (depends on backend, for now RRDTool code)
|
|
GetLastUpdateTime
|
GetLastUpdateTime ( filename )
Returns the last time the RRD file was stored to, in epoch time (int).
Args:
filename: string, path to timeseries (RRD) file
|
|
Store
|
Store (
filename,
interval,
occurred,
fields,
)
Stores data from the fields in the RRD, from the occurred time.
Args:
filename: string, path to timeseries (RRD) file
internal: int, number of seconds between storage. When created, the time
series had this set, and this is required to ensure updates are only
saved at the appropriate times. RRD requires this, otherwise it's just
good practice to have things aligned, even though it loses precision
it's all fuzzy anyway. Get used to it.
occurred: int, the epoch time this data was collected. Will be adjusted
forward (important!) in time to the next even seconds by the interval.
fields: dict, contains the data points which will be stored in the
timeseries (RRD) file. The dict keys should match the timeseries keys.
|
|
Fetch
|
Fetch (
filename,
start_time,
end_time=None,
)
Returns data stored in timeseries (RRD) file from start_time to now,
or end_time, if specified. Args:
filename: string, path to timeseries (RRD) file
start_time: int, epoch time to start fetching from
end_time: int (NOT YET IMPLMENTED), epoch time to stop fetching
TODO(g): Implment end_time and other fetch parameteres.
|
|
|