Fine tuned measurement recording
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
3ea9174692
commit
ef69940f2f
@ -1,26 +1,63 @@
|
||||
#!/usr/bin/env python3
|
||||
from flask import jsonify, request, abort, current_app, Response
|
||||
from flask_classful import FlaskView
|
||||
from flask import request, current_app, Response
|
||||
from flask_classful import FlaskView, route
|
||||
from utils import json_required, influxdb_instance
|
||||
from influxdb_client import Point
|
||||
|
||||
|
||||
class ReportView(FlaskView):
|
||||
|
||||
@route("/link", methods=['POST'])
|
||||
@json_required
|
||||
def post(self):
|
||||
def link(self):
|
||||
data = request.json
|
||||
|
||||
points = []
|
||||
|
||||
for type_ in ['latency', 'queue', 'rate']:
|
||||
for type_ in ['latency', 'rate']:
|
||||
if type_ in data['measurements']:
|
||||
points.append(
|
||||
Point(type_)
|
||||
Point(f"link_{type_}")
|
||||
.tag("client", data['client'])
|
||||
.tag("cloud", data['cloud'])
|
||||
.field("latency", data['measurements'][type_])
|
||||
.tag("site", data['site'])
|
||||
.field("value", data['measurements'][type_])
|
||||
)
|
||||
|
||||
influxdb_instance.connection.write_api().write("alma", "alma", points)
|
||||
influxdb_instance.connection.write_api().write("alma", current_app.config['INFLUXDB_V2_ORG'], points)
|
||||
return Response(status=201)
|
||||
|
||||
@route("/client", methods=['POST'])
|
||||
@json_required
|
||||
def client(self):
|
||||
data = request.json
|
||||
|
||||
points = []
|
||||
|
||||
for type_ in ['queue']:
|
||||
if type_ in data['measurements']:
|
||||
points.append(
|
||||
Point(f"client_{type_}")
|
||||
.tag("client", data['client'])
|
||||
.field("value", data['measurements'][type_])
|
||||
)
|
||||
|
||||
influxdb_instance.connection.write_api().write("alma", current_app.config['INFLUXDB_V2_ORG'], points)
|
||||
return Response(status=201)
|
||||
|
||||
@route("/site", methods=['POST'])
|
||||
@json_required
|
||||
def site(self):
|
||||
data = request.json
|
||||
|
||||
points = []
|
||||
|
||||
for type_ in ['queue']:
|
||||
if type_ in data['measurements']:
|
||||
points.append(
|
||||
Point(f"site_{type_}")
|
||||
.tag("site", data['site'])
|
||||
.field("value", data['measurements'][type_])
|
||||
)
|
||||
|
||||
influxdb_instance.connection.write_api().write("alma", current_app.config['INFLUXDB_V2_ORG'], points)
|
||||
return Response(status=201)
|
||||
|
Loading…
Reference in New Issue
Block a user