Skip to main content

A Python client for Cube: Time Series Data Collection & Analysis

Project description

A Python client for Cube: Time Series Data Collection & Analysis.

Features

You can post (Collector) and request (Evaluator) data to/from Cube.

  • Post events

  • Request events

  • Request metrics

  • Request known event types

Overview

>>> from cube import Cube
>>> c = Cube()
>>>
>>> c.put("sample_data", {"myval": 10})
[{'data': {'myval': 10}, 'type': 'sample_data', 'time': '2012-10-01T13:04:04.453929'}]

>>> c.event("sample_data")
[{u'time': u'2012-10-01T13:04:04.453Z'}]

>>> c.put("sample_data", {"myval": 20})
[{'data': {'myval': 20}, 'type': 'sample_data', 'time': '2012-10-01T13:04:39.725676'}]

>>> c.event("sample_data")
[{u'time': u'2012-10-01T13:04:04.453Z'}, {u'time': u'2012-10-01T13:04:39.725Z'}]

>>> c.event("sample_data(myval)")
[{u'data': {u'myval': 10}, u'time': u'2012-10-01T13:04:04.453Z'}, {u'data': {u'myval': 20}, u'time': u'2012-10-01T13:04:39.725Z'}]

>>> c.metric("sum(sample_data)", step="36e5", start="2012-10-01")
[{u'value': 0, u'time': u'2012-10-01T00:00:00.000Z'}, {u'value': 0, u'time': u'2012-10-01T01:00:00.000Z'}, {u'value': 0, u'time': u'2012-10-01T02:00:00.000Z'}, {u'value': 0, u'time': u'2012-10-01T03:00:00.000Z'}, {u'value': 0, u'time': u'2012-10-01T04:00:00.000Z'}, {u'value': 0, u'time': u'2012-10-01T05:00:00.000Z'}, {u'value': 0, u'time': u'2012-10-01T06:00:00.000Z'}, {u'value': 0, u'time': u'2012-10-01T07:00:00.000Z'}, {u'value': 0, u'time': u'2012-10-01T08:00:00.000Z'}, {u'value': 0, u'time': u'2012-10-01T09:00:00.000Z'}, {u'value': 0, u'time': u'2012-10-01T10:00:00.000Z'}, {u'value': 0, u'time': u'2012-10-01T11:00:00.000Z'}, {u'value': 0, u'time': u'2012-10-01T12:00:00.000Z'}, {u'value': 2, u'time': u'2012-10-01T13:00:00.000Z'}]

Requirements

Installation

$ pip install cube-client

Usage

from cube import Cube
from datetime import datetime

cube = Cube()
# or
cube = Cube("localhost")

# Create an event
cube.put("myevent", {"temp": 30})
# or
cube.put("myvent", {"temp": 30}, time=datatime.now().isoformat())

# Request events data
# See Cube queries:
# https://github.com/square/cube/wiki/Queries#wiki-metric
cube.event("myevent(temp)")

# Request metrics
cube.metric(c.metric("sum(myevent)", step="36e5", start="2012-10-01"))

# Request known event types
cube.types()

License (MIT)

Copyright (c) 2012 Thomas Sileo

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cube-client-0.1.tar.gz (3.4 kB view details)

Uploaded Source

File details

Details for the file cube-client-0.1.tar.gz.

File metadata

  • Download URL: cube-client-0.1.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for cube-client-0.1.tar.gz
Algorithm Hash digest
SHA256 4029c6c0641f1f070794ea997d63a9345050c8ed7473e47320879743d3285866
MD5 de80d9f8d8da4434c54a76f33bf06147
BLAKE2b-256 9616717c5d0bb4f7c6a097f1d9851a48bc48a76b2cd51c151b54946682fe1c4d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page