Apptuit Python Client
Project description
Python client for Apptuit.AI
Installation
pip install apptuit
Dependencies
Supported Python versions: 2.7.x, 3.4, 3.5, 3.6, 3.7
Requirements:
- pandas
- numpy
- requests
Usage
Querying for data
from apptuit import Apptuit
import time
token = 'my_token' # replace with your Apptuit token
apptuit = Apptuit(token=token)
start_time = int(time.time()) - 3600 # let's query for data going back 1 hour from now
query_res = apptuit.query("fetch('proc.cpu.percent').downsample('1m', 'avg')", start=start_time)
# we can create a Pandas dataframe from the result object by calling to_df()
df = query_res[0].to_df()
# Another way of creating the DF is accessing by the metric name in the query
another_df = query_res['proc.cpu.percent'].to_df()
Sending data
from apptuit import Apptuit, DataPoint
import time
import random
token = "mytoken"
client = Apptuit(token=token)
metrics = ["proc.cpu.percent", "node.memory.bytes", "network.send.bytes", "network.receive.bytes", "node.load.avg"]
tags = {"host": "localhost", "ip": "127.0.0.1"}
curtime = int(time.time())
dps = []
while True:
curtime = int(time.time())
for metric in metrics:
dps.append(DataPoint(metric, tags, curtime, random.random()))
if len(dps) == 100:
client.send(dps)
dps = []
time.sleep(60)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
apptuit-0.2.3.tar.gz
(9.2 kB
view hashes)
Built Distribution
Close
Hashes for apptuit-0.2.3-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 459d5af2e3d4e2275fd7c19b5c4ed5a097064668d46b476e012e317e48663c2e |
|
MD5 | 798722ba2043e5e465f78453440988c4 |
|
BLAKE2b-256 | 9f6d2473074c7798d1bda26969edc9a0ebe617d7251efee5122a3f90582da0aa |