influxdb: Add ability to specify tags#467
Open
BrianJKoopman wants to merge 7 commits intokoopman/influxdb-format-data-refactorfrom
Open
influxdb: Add ability to specify tags#467BrianJKoopman wants to merge 7 commits intokoopman/influxdb-format-data-refactorfrom
BrianJKoopman wants to merge 7 commits intokoopman/influxdb-format-data-refactorfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR (built on top of the refactor in #466) adds the ability to specify tags for each field published to InfluxDB by including the new
'influxdb_tags'dict in the message published on an OCS Feed.The new tagging structure is only applied for agents that publish this new
'influxdb_tags'dict. Messages with this dict will now look like:Each 'tag' provided for the (ocs) fields will be applied, the data will be published to a measurement set by the 'agent_class' and the (influx) field will be the string provided in '_field'.
With the new tags, this changes the structure of a write from something like:
to:
Motivation and Context
Resolves #175.
Some agents in socs have a large number of fields and writing Grafana dashboards to query all of their fields results in a large number of queries to the InfluxDB. Tagging, as performed here, should enable writing more efficient queries.
The old structure in OCS was violating essentially every suggestion for schema and data layout made by InfluxDB. We were encoding data in both the measurements and the field keys. This new structure fixes both of these issues.
How Has This Been Tested?
I have run the agent locally in both 'json' and 'line' protocol modes and verified how the data is presented in InfluxDB through Grafana while running the modified FakeDataAgent.
This results in being able to make queries like this:

I also ran an unmodified FakeDataAgent alongside the modified one. While writing to InfluxDB I also wrote to
.g3file via the Aggregator agent.I'm not 100% sure, so checking me on this would be great in this review, but I don't see the
influxdb_tagsmaking it into the.g3files:Trying to look more closely:
So I think the old structure remains in place within
.g3.Types of changes
Checklist: