KairosDB¶
Provides read access to the target KairosDB
-
kairosdb
(url, oauth2=False)
Methods of KairosDB¶
-
query
(name, group_by = None, tags = None, start = -5, end = 0, time_unit='seconds', aggregators = None, start_absolute = None, end_absolute = None)¶ Query kairosdb.
Parameters: - name (str) – Metric name.
- group_by (list) – List of fields to group by.
- tags (dict) –
Filtering tags. Example of tags object:
{ "key": ["max"] }
- start (int) – Relative start time. Default is 5. Should be greater than or equal 1.
- end (int) – End time. Default is 0. If not 0, then it should be greater than or equal to 1.
- time_unit (str) – Time unit (‘seconds’, ‘minutes’, ‘hours’). Default is ‘minutes’.
- aggregators (list) –
List of aggregators. Aggregator is an object that looks like
{ "name": "max", "sampling": { "value": "1", "unit": "minutes" }, "align_sampling": true }
- start_absolute (long) – Absolute start time in milliseconds, overrides the start parameter which is relative
- end_absolute (long) – Absolute end time in milliseconds, overrides the end parameter which is relative
Returns: Result queries.
Return type:
-
query_batch
(self, metrics, start=5, end=0, time_unit='minutes', start_absolute=None, end_absolute=None)¶ Query kairosdb for several checks at once.
Parameters: - metrics (dict) –
list of KairosDB metric queries, one query per metric name, e.g.
[ { 'name': 'metric_name', # name of the metric 'group_by': ['foo'], # list of fields to group by 'aggregators': [ # list of aggregator objects { # structure of a single aggregator 'name': 'max', 'sampling': { 'value': '1', 'unit': 'minutes' }, 'align_sampling': True } ], 'tags': { # dict with filtering tags 'key': ['max'] # a key is a tag name, list of values is used to filter # all the records with given tag and given values } } ]
- start (int) – Relative start time. Default is 5.
- end (int) – End time. Default is 0.
- time_unit (str) – Time unit (‘seconds’, ‘minutes’, ‘hours’). Default is ‘minutes’.
- start_absolute (long) – Absolute start time in milliseconds, overrides the start parameter which is relative
Returns: Array of results for each queried metric
Return type: list
- metrics (dict) –