This commit is contained in:
parent
5b9d982ffc
commit
62f35d53d2
11
src/app.py
11
src/app.py
@ -39,19 +39,20 @@ async def on_message(message: IncomingMessage):
|
||||
r = requests.get(f"http://input-service/sample/{msg_json['tag']}")
|
||||
r.raise_for_status()
|
||||
|
||||
fields = {
|
||||
k: float(v) for k, v in msg_json['all_predictions']
|
||||
}
|
||||
fields['_classification_duration'] = float(msg_json['classification_duration'])
|
||||
|
||||
point = {
|
||||
'time': now,
|
||||
'measurement': 'sturnus',
|
||||
'tags': {
|
||||
'device': r.json()['device_id']
|
||||
},
|
||||
'fields': {
|
||||
'probability': float(msg_json['probability']) # This is required because otherwise of the json serialization and de-serialization round values would interpret as ints and influxdb would fail
|
||||
}
|
||||
'fields': fields
|
||||
}
|
||||
|
||||
|
||||
|
||||
async with InfluxDBClient(username=config.INFLUXDB_USERNAME, password=config.INFLUXDB_PASSWORD,
|
||||
host=config.INFLUXDB_HOST, port=config.INFLUXDB_PORT, ssl=False,
|
||||
database=config.INFLUXDB_DB) as client:
|
||||
|
Loading…
Reference in New Issue
Block a user