27 lines
805 B
Python
27 lines
805 B
Python
#!/usr/bin/env python3
|
|
from flask import jsonify, request, abort, current_app, Response
|
|
from flask_classful import FlaskView
|
|
from utils import json_required, influxdb_instance
|
|
from influxdb_client import Point
|
|
|
|
|
|
class ReportView(FlaskView):
|
|
|
|
@json_required
|
|
def post(self):
|
|
data = request.json
|
|
|
|
points = []
|
|
|
|
for type_ in ['latency', 'queue', 'rate']:
|
|
if type_ in data['measurements']:
|
|
points.append(
|
|
Point(type_)
|
|
.tag("client", data['client'])
|
|
.tag("cloud", data['cloud'])
|
|
.field("latency", data['measurements'][type_])
|
|
)
|
|
|
|
influxdb_instance.connection.write_api().write("alma", "alma", points)
|
|
return Response(status=201)
|