Reputation: 354
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?
Upvotes: 0
Views: 1539
Reputation: 8717
Yes, tags are optional meta-data for a measurement.
Quoting the tags documentation
The key-value pair in the InfluxDB data structure that records metadata. Tags are an optional part of the data structure, but they are useful for storing commonly-queried metadata; tags are indexed so queries on tags are performant. Query tip: Compare tags to fields; fields are not indexed.
Upvotes: 1