Utility functions and classes

InfluxGraph utility functions

class influxgraph.utils.Query(pattern)

Graphite-API compatible query class

influxgraph.utils.calculate_interval(start_time, end_time, deltas=None)

Calculates wanted data series interval according to start and end times

Returns interval in seconds :param start_time: Start time in seconds from epoch :param end_time: End time in seconds from epoch :type start_time: int :type end_time: int :param deltas: Delta configuration to use. Defaults hardcoded if no

configuration is provided
Return type:int - Interval in seconds
influxgraph.utils.gen_memcache_key(start_time, end_time, aggregation_func, paths)

Generate memcache key to use to cache request data

influxgraph.utils.gen_memcache_pattern_key(pattern)

Generate memcache key from pattern

influxgraph.utils.get_aggregation_func(path, aggregation_functions)

Lookup aggregation function for path, if any. Defaults to ‘mean’.

Parameters:
  • path (str) – Path to lookup
  • aggregation_functions (dict(<pattern>: <compiled regex>)) – Aggregation function configuration
influxgraph.utils.get_retention_policy(interval, retention_policies)

Get appropriate retention policy for interval provided

Parameters:
  • interval (int) – Interval of query in seconds
  • retention_policies (dict(max time range of interval in seconds: retention policy name)) – Retention policy configuration
Return type:

str or None

influxgraph.utils.make_memcache_client(memcache_host, memcache_max_value=1)

Make memcache client if given a memcache host or None

influxgraph.utils.parse_series(series, fields, graphite_templates, separator='.')

Parses series and fields with/without graphite templates and returns built Index

Parameters:
  • series (list(unicode str)) – Series to load
  • fields (dict(measurement: [field1, field2, .])) – Per measurement field keys from InfluxDB. May be None
  • graphite_templates – Graphite templates to use to parse series

and fields. :type graphite_templates: list(tuple) as returned by influxgraph.templates.parse_influxdb_graphite_templates

Return type:influxgraph.classes.tree.NodeTreeIndex
influxgraph.utils.read_influxdb_values(influxdb_data, paths, measurement_data)

Return metric path -> datapoints dict for values from InfluxDB data