| @@ -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) | ||||