Commit c1c9611d authored by Daniele Venzano's avatar Daniele Venzano

Fix InfluxDB query limiting to the current deployment

parent 2c1ef7f3
...@@ -31,8 +31,8 @@ class InfluxDBInMetrics: ...@@ -31,8 +31,8 @@ class InfluxDBInMetrics:
def get_service_usage(self, service_id): def get_service_usage(self, service_id):
"""Query the DB for the current usage metrics.""" """Query the DB for the current usage metrics."""
query_cpu = 'SELECT mean("usage_percent") FROM "docker_container_cpu" WHERE "zoe_service_id" = \'{}\' AND time >= now() - 3m GROUP BY time(2m) ORDER BY time DESC LIMIT 1'.format(service_id) query_cpu = 'SELECT mean("usage_percent") / 100 FROM "docker_container_cpu" WHERE "zoe_service_id" = \'{}\' AND "zoe_deployment_name" = \'{}\' AND time >= now() - 3m GROUP BY time(2m) ORDER BY time DESC LIMIT 1'.format(service_id, get_conf().deployment_name)
query_mem = 'SELECT mean("usage") FROM "docker_container_mem" WHERE "zoe_service_id" = \'{}\' AND time >= now() - 3m GROUP BY time(2m) ORDER BY time DESC LIMIT 1'.format(service_id) query_mem = 'SELECT mean("usage") FROM "docker_container_mem" WHERE "zoe_service_id" = \'{}\' AND "zoe_deployment_name" = \'{}\' AND time >= now() - 3m GROUP BY time(2m) ORDER BY time DESC LIMIT 1'.format(service_id, get_conf().deployment_name)
url = self.base_url + '/query' url = self.base_url + '/query'
resp = requests.post(url, data={"db": 'telegraf', 'q': query_cpu + ';' + query_mem}) resp = requests.post(url, data={"db": 'telegraf', 'q': query_cpu + ';' + query_mem})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment