浏览代码

Added writing to Time Series Database KairosDB

pull/194/head
Johannes 7 年前
父节点
当前提交
0803e85630
共有 1 个文件被更改,包括 10 次插入3 次删除
  1. +10
    -3
      modules/logs/endpoints.py

+ 10
- 3
modules/logs/endpoints.py 查看文件

@@ -63,17 +63,22 @@ class LogView(FlaskView):
def querry_tsdb(self, type, id): def querry_tsdb(self, type, id):
kairosdb_server = "http://127.0.0.1:" + cbpi.cache["config"]["kairos_db_port"].__dict__["value"] kairosdb_server = "http://127.0.0.1:" + cbpi.cache["config"]["kairos_db_port"].__dict__["value"]


if cbpi.cache["active_brew"] != "" and cbpi.cache["active_brew"] != "none":
tag = '"brew": "%s"' % cbpi.cache["active_brew"]
else:
tag = ""

data = dict(metrics=[ data = dict(metrics=[
{ {
"tags": {},
"tags": {tag},
"name": "cbpi.%s_%s" % (type, id), "name": "cbpi.%s_%s" % (type, id),
"aggregators": [ "aggregators": [
{ {
"name": "avg", "name": "avg",
"align_sampling": True, "align_sampling": True,
"sampling": { "sampling": {
"value": "1",
"unit": "minutes"
"value": "5",
"unit": "seconds"
}, },
"align_start_time": True "align_start_time": True
} }
@@ -86,6 +91,8 @@ class LogView(FlaskView):
"unit": "days" "unit": "days"
}) })


self.logger.debug("query: %s", json.dumps(data))

response = requests.post(kairosdb_server + "/api/v1/datapoints/query", json.dumps(data)) response = requests.post(kairosdb_server + "/api/v1/datapoints/query", json.dumps(data))
if response.ok: if response.ok:
self.logger.debug("Fetching time series for [%s_%s] took [%s]", type, id, response.elapsed) self.logger.debug("Fetching time series for [%s_%s] took [%s]", type, id, response.elapsed)


正在加载...
取消
保存