I have a python worker that sends measurements to influxDB with a tags value whenever the value is present. When this tags value is not present, I set the tags as an empty dictonary.
def emit_measurements(self, values: Dict, tags: Optional[Dict[str, str]] = None):
if tags is None:
tags = {}
measurement = {
"measurement": "some_name",
"tags": tags,
"time": datetime.now(tz=pytz.UTC).isoformat(),
"fields": values,
}
self._influx_client.write_points([measurement])
In my influx database I see the correct values for the fields whenever tags is not present, but as soon as one event gets emitted with tags all fields get turned to 0 and stay like that.
(I'm assuming the measurement table gets corrupted whenever tags is present which causes every field value to be 0)
Can this tags be optional where some events don't emit it?
Yes, tags are optional meta-data for a measurement.
Quoting the tags documentation