Commit 2a700859 authored by Azat Khuziyakhmetov's avatar Azat Khuziyakhmetov
Browse files

influxdb sequential queries bug fix

parent 22b7d198
......@@ -7,18 +7,22 @@ import conf.config as conf
from . import common
from . import metrics
m_proc = conf.measurements["proc"]
DB_INTERVAL = conf.METRIC_INTERVAL
def get_query_aggr_per_node_for_job(aggr, metric, job_id, metric_db, measurement, delta, t_start, t_end):
aggr = '{:s}("{:s}") as "{:s}"'.format(aggr, metric_db, metric)
query = (
'SELECT {:s} FROM "{:s}" '
'WHERE "jobid1" = \'{:s}\' '
'AND time >= {:d}s AND time <= {:d}s '
'GROUP BY "host", time({:d}s);'
).format(aggr, measurement, job_id, t_start, t_end, delta)
'SELECT mean({met}) as "{met}" FROM ('
'SELECT {agr} FROM "{mes}" '
'WHERE "jobid1" = \'{job}\' '
'AND time >= {start}s AND time <= {end}s '
'GROUP BY "host", time({dbdelta}s)) '
'WHERE time >= {start}s AND time <= {end}s '
'GROUP BY "host", time({delta}s);'
).format(agr = aggr, mes = measurement, job = job_id,
start=t_start, end=t_end, delta=delta, met = metric,
dbdelta = DB_INTERVAL)
return query
......@@ -28,11 +32,16 @@ def get_query_aggr_for_nodes(aggr, metric, nodes, metric_db, measurement, delta,
node_cond = ' OR '.join("host='{:s}'".format(n) for n in nodes)
query = (
'SELECT {:s} FROM "{:s}" '
'WHERE ({:s}) '
'AND time >= {:d}s AND time <= {:d}s '
'GROUP BY "host", time({:d}s);'
).format(aggr, measurement, node_cond, t_start, t_end, delta)
'SELECT mean({met}) as "{met}" FROM ('
'SELECT {agr} FROM "{mes}" '
'WHERE ({nodes}) '
'AND time >= {start}s AND time <= {end}s '
'GROUP BY "host", time({dbdelta}s)) '
'WHERE time >= {start}s AND time <= {end}s '
'GROUP BY "host", time({delta}s);'
).format(agr = aggr, mes = measurement, nodes = node_cond,
start = t_start, end = t_end, delta = delta, met = metric,
dbdelta = DB_INTERVAL)
return query
......
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