ceres¶
-
class
ceres.CeresNode(tree, nodePath, fsPath)[source]¶ A
CeresNoderepresents a single time-series metric of a given timeStep (its seconds-per-point resolution) and containing arbitrary key-value metadata.A
CeresNodeis associated with its most precise timeStep. This timeStep is the finest resolution that can be used for writing, though aCeresNodecan contain and read data with other, less-precise timeStep values in its underlyingCeresSlicedata.param tree: The CeresTreethis node is associated withparam nodePath: The name of the metric this node represents param fsPath: The filesystem path of this metric Note
This class generally should be instantiated through use of
CeresTree. SeeCeresTree.createNode()andCeresTree.getNode()See also
setDefaultSliceCachingBehavior()to adjust caching behavior-
aggregationMethod¶
-
compact(datapoints)[source]¶ Compacts datapoints into a list of contiguous, sorted lists of points with duplicate timestamps and null values removed
param datapoints: List of datapoint tuples [(timestamp, value), ...]returns: A list of lists of contiguous sorted datapoint tuples [[(timestamp, value), ...], ...]
-
classmethod
create(tree, nodePath, **properties)[source]¶ Create a new
CeresNodeon disk with the specified properties.param tree: The CeresTreethis node is associated withparam nodePath: The name of the metric this node represents param **properties: A set of key-value properties to be associated with this node A
CeresNodealways has the timeStep property which is an integer value representing the precision of the node in seconds-per-datapoint. E.g. a value of60represents one datapoint per minute. If no timeStep is specified at creation, the value ofceres.DEFAULT_TIMESTEPis usedreturns: CeresNode
-
classmethod
fromFilesystemPath(fsPath)[source]¶ Instantiate a
CeresNodefrom the on-disk path of an existing nodeParams fsPath: The filesystem path of an existing node Returns: CeresNode
-
fsPath¶
-
hasDataForInterval(fromTime, untilTime)[source]¶ Test whether this node has any data in the given time interval. All slices are inspected which will trigger a read of slice information from disk if slice cache behavior is set to latest or none (See
slices())param fromTime: Beginning of interval in unix epoch seconds param untilTime: End of interval in unix epoch seconds :returns True or False
-
static
isNodeDir(path)[source]¶ Tests whether the given path is a
CeresNodeParameters: path – Path to test :returns True or False
-
metadataFile¶
-
nodePath¶
-
read(fromTime, untilTime)[source]¶ Read data from underlying slices and return as a single time-series
Parameters: - fromTime – Beginning of interval in unix epoch seconds
- untilTime – End of interval in unix epoch seconds
Returns:
-
readMetadata()[source]¶ Update node metadata from disk
Raises: CorruptNode
-
setSliceCachingBehavior(behavior)[source]¶ Set slice caching behavior.
Parameters: behavior – See slices()for valid behavior values
-
sliceCache¶
-
sliceCachingBehavior¶
-
slice_info¶ A property providing a list of current information about each slice
Returns: [(startTime, endTime, timeStep), ...]
-
slices¶ A property providing access to information about this node’s underlying slices. Because this information is accessed in every read and write, a caching mechanism is provided. Cache behavior is set using
setSliceCachingBehavior()and defaults to the value set inDEFAULT_SLICE_CACHING_BEHAVIORThe following behaviors are available:
none (default) - Slice information is read from the filesystem at every access
latest - The latest slice is served from cache, all others from disk. Reads and writes of recent data are most likely to be in the latest slice
all - All slices are cached. The cache is only refreshed on new slice creation or deletion
returns: [(startTime, timeStep), ...]
-
timeStep¶
-
tree¶
-
-
class
ceres.CeresSlice(node, startTime, timeStep)[source]¶ -
-
endTime¶
-
fsPath¶
-
isEmpty¶
-
mtime¶
-
node¶
-
startTime¶
-
timeStep¶
-
-
class
ceres.CeresTree(root)[source]¶ Represents a tree of Ceres metrics contained within a single path on disk This is the primary Ceres API.
Parameters: root – The directory root of the Ceres tree Note
Use
createTree()to initialize and instantiate a new CeresTreeSee also
setDefaultNodeCachingBehavior()to adjust caching behavior-
createNode(nodePath, **properties)[source]¶ Creates a new metric given a new metric name and optional per-node metadata :param nodePath: The new metric name. :param **properties: Arbitrary key-value properties to store as metric metadata.
Returns: CeresNode
-
classmethod
createTree(root, **props)[source]¶ Create and returns a new Ceres tree with the given properties
Parameters: - root – The root directory of the new Ceres tree
- **props – Arbitrary key-value properties to store as tree metadata
Returns:
-
fetch(nodePath, fromTime, untilTime)[source]¶ Fetch data within a given interval from the given metric
Parameters: - nodePath – The metric name to fetch from
- fromTime – Requested interval start time in unix-epoch.
- untilTime – Requested interval end time in unix-epoch.
Returns: Raises:
-
find(nodePattern, fromTime=None, untilTime=None)[source]¶ Find nodes which match a wildcard pattern, optionally filtering on a time range
param nodePattern: A glob-style metric wildcard param fromTime: Optional interval start time in unix-epoch. param untilTime: Optional interval end time in unix-epoch. returns: An iterator yielding CeresNodeobjects
-
getFilesystemPath(nodePath)[source]¶ Get the on-disk path of a Ceres node given a metric name
Parameters: nodePath – A metric name e.g. carbon.agents.graphite-a.cpuUsageReturns: The Ceres node path on disk
-
getNode(nodePath)[source]¶ Returns a Ceres node given a metric name. Because nodes are looked up in every read and write, a caching mechanism is provided. Cache behavior is set using
setNodeCachingBehavior()and defaults to the value set inDEFAULT_NODE_CACHING_BEHAVIORThe following behaviors are available:
- none - Node is read from the filesystem at every access.
- all (default) - All nodes are cached.
param nodePath: A metric name returns: CeresNodeor None
-
getNodePath(fsPath)[source]¶ Get the metric name of a Ceres node given the on-disk path
Parameters: fsPath – The filesystem path of a Ceres node Returns: A metric name Raises: ValueError – When fsPath is not a path within the CeresTree
-
hasNode(nodePath)[source]¶ Returns whether the Ceres tree contains the given metric
Parameters: nodePath – A metric name e.g. carbon.agents.graphite-a.cpuUsageReturns: True or False
-
setNodeCachingBehavior(behavior)[source]¶ Set node caching behavior.
Parameters: behavior – See getNode()for valid behavior values
-