def setUp(self): print "setUp" self.conn = pyKairosDB.connect('192.168.0.116', '8080') self.write_delay = 0.5 self.metric_name = 'Metric11' self.metrics = [{'name': self.metric_name, 'timestamp': time.time(), 'value': 1, 'tags': {'resource_id': 123}}, {'name': self.metric_name, 'timestamp': time.time() + 1, 'value': 2, 'tags': {'resource_id': 123}}, {'name': self.metric_name, 'timestamp': time.time() + 2, 'value': 3, 'tags': {'resource_id': 123}}, {'name': self.metric_name, 'timestamp': time.time() + 3, 'value': 4, 'tags': {'resource_id': 1}}, {'name': 123, 'timestamp': time.time() + 3, 'value': 5, 'tags': {'resource_id': 1}}] self.conn.write_metrics(self.metrics) time.sleep(self.write_delay)
def setUp(self): print "setUp" self.conn = pyKairosDB.connect('192.168.0.116', '8080') self.write_delay = 0.5 self.metric_name = 'Metric11' self.metrics = [{ 'name': self.metric_name, 'timestamp': time.time(), 'value': 1, 'tags': { 'resource_id': 123 } }, { 'name': self.metric_name, 'timestamp': time.time() + 1, 'value': 2, 'tags': { 'resource_id': 123 } }, { 'name': self.metric_name, 'timestamp': time.time() + 2, 'value': 3, 'tags': { 'resource_id': 123 } }, { 'name': self.metric_name, 'timestamp': time.time() + 3, 'value': 4, 'tags': { 'resource_id': 1 } }, { 'name': 123, 'timestamp': time.time() + 3, 'value': 5, 'tags': { 'resource_id': 1 } }] self.conn.write_metrics(self.metrics) time.sleep(self.write_delay)
#!/usr/bin/env python import time import pyKairosDB from pyKairosDB import util as util from pyKairosDB import graphite # use this after the following read test has settled: # ipython pyKairosDB/tests/test_graphite_write.py test.bar.baz # ipython pyKairosDB/tests/test_graphite_write.py test.bar.bar # ipython pyKairosDB/tests/test_graphite_write.py test.bar.foo # ipython pyKairosDB/tests/test_graphite_write.py test.bar.bat # c = pyKairosDB.connect() # use localhost:8080, the default, no ssl start_time = time.time() - 3600 end_time = time.time() metrics_list = graphite.expand_graphite_wildcard_metric_name(c, "test.*.*.*") (timeinfo, datapoints) = graphite.read_absolute(c, metrics_list[0], start_time, end_time) print "Datapoints are:" print datapoints print "Timeinfo is:" print timeinfo
#!/usr/bin/env python import pyKairosDB import time # use this after a read test c = pyKairosDB.connect() # use localhost:8080, the default, no ssl r = c.write_one_metric("test", time.time(), time.time(), tags = {"graphite" : "yes"})
from liberouterapi import config, app from .error import JobsError from .Aggregate import Aggregate from flask import request from pyKairosDB import connect, metadata, reader import json import requests conn = connect(server=config["kairosdb"].get("server", "localhost"), port=config["kairosdb"].get("port", 8000), user=config["kairosdb"].get("user", ""), passw=config["kairosdb"].get("password", "")) from .utils import check_times, generate_health_url, generate_base_url, extract_data, merge_dicts, join_data @app.route("/kairos/health") def health(): res = requests.get(generate_health_url() + "/check", auth=(conn.user, conn.passw)) return ('', res.status_code) @app.route("/kairos/status") def status(): res = requests.get(generate_health_url() + "/status", auth=(conn.user, conn.passw)) return (str(res.content))
elif o in ('-p', '--port'): port = a elif o in ('-o', '--output'): outfile = a elif o in ("-h", "--help"): usage() exit() elif o in ("-b", "--brief"): brief = True elif o in ("-r", "--regex"): regex = a filter = re.compile(regex) try: con = pyKairosDB.connect(ip, port, False) except requests.exceptions.ConnectionError as err: print >> sys.stderr, (err) print() usage() exit(1) metric_names = pyKairosDB.metadata.get_all_metric_names(con) filtered_metrics = [] for name in metric_names: if filter.search(name): filtered_metrics.append(name) if brief: print name