This commit is contained in:
Pünkösd Marcell 2021-12-09 22:11:32 +01:00
parent f5edd93ee1
commit 8465bf92df
1 changed files with 14 additions and 12 deletions

View File

@ -30,17 +30,17 @@ class ReportView(FlaskView):
@route("/link", methods=['GET']) @route("/link", methods=['GET'])
def link_get(self): def link_get(self):
q = influxdb_instance.connection.query_api()
response = {} response = {}
# Query latency # Query latency
latency_tables = q.query(f"""from(bucket: "alma") query = """from(bucket: "alma")
|> range(start: -2m, stop: now()) |> range(start: -2m, stop: now())
|> filter(fn: (r) => r["_measurement"] == "link_latency") |> filter(fn: (r) => r["_measurement"] == "link_latency")
|> timedMovingAverage(every: 30s, period: 1m) |> timedMovingAverage(every: 30s, period: 1m)
|> last() |> last()
|> yield()""") |> yield()"""
latency_tables = influxdb_instance.query_api(query)
for table in latency_tables: for table in latency_tables:
for value in table.values: for value in table.values:
@ -52,12 +52,13 @@ class ReportView(FlaskView):
# Query rate # Query rate
rate_tables = q.query(f"""from(bucket: "alma") query = """from(bucket: "alma")
|> range(start: -2m, stop: now()) |> range(start: -2m, stop: now())
|> filter(fn: (r) => r["_measurement"] == "link_rate") |> filter(fn: (r) => r["_measurement"] == "link_rate")
|> timedMovingAverage(every: 30s, period: 1m) |> timedMovingAverage(every: 30s, period: 1m)
|> last() |> last()
|> yield()""") |> yield()"""
rate_tables = influxdb_instance.query_api(query)
for table in rate_tables: for table in rate_tables:
for value in table.values: for value in table.values:
@ -91,19 +92,19 @@ class ReportView(FlaskView):
@route("/client", methods=['GET']) @route("/client", methods=['GET'])
def client_get(self): def client_get(self):
q = influxdb_instance.connection.query_api()
response = {} response = {}
# Query queue # Query queue
latency_tables = q.query(f"""from(bucket: "alma") query = """from(bucket: "alma")
|> range(start: -2m, stop: now()) |> range(start: -2m, stop: now())
|> filter(fn: (r) => r["_measurement"] == "client_queue") |> filter(fn: (r) => r["_measurement"] == "client_queue")
|> timedMovingAverage(every: 30s, period: 1m) |> timedMovingAverage(every: 30s, period: 1m)
|> last() |> last()
|> yield()""") |> yield()"""
queue_tables = influxdb_instance.query_api(query)
for table in latency_tables: for table in queue_tables:
for value in table.values: for value in table.values:
key = value['client'] key = value['client']
if key in response: if key in response:
@ -140,14 +141,15 @@ class ReportView(FlaskView):
# Query queue # Query queue
latency_tables = q.query(f"""from(bucket: "alma") query = """from(bucket: "alma")
|> range(start: -2m, stop: now()) |> range(start: -2m, stop: now())
|> filter(fn: (r) => r["_measurement"] == "site_queue") |> filter(fn: (r) => r["_measurement"] == "site_queue")
|> timedMovingAverage(every: 30s, period: 1m) |> timedMovingAverage(every: 30s, period: 1m)
|> last() |> last()
|> yield()""") |> yield()"""
queue_tables = influxdb_instance.query_api(query)
for table in latency_tables: for table in queue_tables:
for value in table.values: for value in table.values:
key = value['site'] key = value['site']
if key in response: if key in response: