Added influx stuff
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Pünkösd Marcell 2021-11-17 23:07:46 +01:00
parent eb9193451e
commit b4c7d2b12d
6 changed files with 91 additions and 10 deletions

View File

@ -8,10 +8,8 @@ class Config:
RELEASE_ID = os.environ.get("RELEASE_ID", "test")
RELEASEMODE = os.environ.get("RELEASEMODE", "dev")
INFLUXDB_HOST = os.environ['INFLUXDB_HOST']
INFLUXDB_PORT = os.environ['INFLUXDB_PORT']
INFLUXDB_USER = os.environ['INFLUXDB_USER']
INFLUXDB_PASSWORD = os.environ['INFLUXDB_PASSWORD']
INFLUXDB_DATABASE = os.environ['INFLUXDB_DATABASE']
INFLUXDB_V2_URL = os.environ['INFLUXDB_URL']
INFLUXDB_V2_TOKEN = os.environ['INFLUXDB_TOKEN']
INFLUXDB_V2_ORG = os.environ['INFLUXDB_ORG']
INFLUXDB_TIMEOUT = 30

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python3
from flask_influxdb import InfluxDB
from flask_influxdb2 import InfluxDB2
influxdb_instance = InfluxDB()
influxdb_instance = InfluxDB2()

View File

@ -1,7 +1,26 @@
#!/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):
pass
@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)

View File

@ -9,4 +9,6 @@ data:
SENTRY_DSN:
RELEASE_ID: kmlabz-k8s
RELEASEMODE: release
INFLUXDB_URL: http://birb-latency-influxdb:8086
INFLUXDB_TOKEN: my-super-secret-auth-token
INFLUXDB_ORG: alma

62
k8s/influxdb.yaml Normal file
View File

@ -0,0 +1,62 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: birb-latency-influxdb
namespace: birbnetes
labels:
app: birb-latency-influxdb
spec:
replicas: 1
selector:
matchLabels:
app: birb-latency-influxdb
strategy:
type: Recreate
template:
metadata:
labels:
app: birb-latency-influxdb
spec:
containers:
- image: "influxdb:2.1"
imagePullPolicy: Always
name: birb-latency-influxdb
envFrom:
- configMapRef:
name: birb-latency-influxdb
ports:
- containerPort: 8086
imagePullSecrets:
- name: regcred
---
apiVersion: v1
kind: Service
metadata:
name: birb-latency-influxdb
namespace: birbnetes
labels:
app: birb-latency-influxdb
spec:
ports:
- name: birb-latency-influxdb
port: 8086
targetPort: 8086
protocol: TCP
selector:
app: birb-latency-influxdb
type: ClusterIP
---
apiVersion: v1
kind: ConfigMap
metadata:
name: birb-latency-influxdb
labels:
app: birb-latency-influxdb
namespace: birbnetes
data:
DOCKER_INFLUXDB_INIT_USERNAME: admin
DOCKER_INFLUXDB_INIT_PASSWORD: adminadmin
DOCKER_INFLUXDB_INIT_ORG: alma
DOCKER_INFLUXDB_INIT_BUCKET: alma
DOCKER_INFLUXDB_INIT_ADMIN_TOKEN: my-super-secret-auth-token

View File

@ -9,7 +9,7 @@ sentry_sdk
flask_minio
py-healthcheck
Flask-InfluxDB~=0.3.3
Flask-InfluxDB2~=0.3
jaeger-client
Flask-Opentracing