Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InfluxDBWriter : Add "attributesAsTag" parameter #686

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

nlaurent9816
Copy link
Contributor

In InfluxDB, you can store values as tag or as fields. Tags are indexed but can only be Strings, fields are not indexed but suuports more data formats. (See here.) Actually, the InfluxDbWriter stores every attributes value (results from queries) as fields. If this format is adapted for metrics (counters, averages, etc...), you can have performance issues when reading if you try to filter with them. Tags are more adapted for filtering, that's why it is recommended to store IDs, names, metadata, etc... as tags. Actually, only JMX port (with reportJmxPortAsTag parameter), typeName, objDomain, className, attributeName (with resultTags parameter) and full custom tags are written. "attributesAsTag" is a list of attributes to write as tags instead of fields.

I also have a question: How can I also edit the Wiki pages in order to document features?

@nlaurent9816
Copy link
Contributor Author

2 months after, anybody wants to check this PR?

/**
* The {@link ImmutableSet} of {@link ResultAttribute} attributes of
* {@link Result} that will be written as {@link Point} tags
*/
private final ImmutableSet<ResultAttribute> resultAttributesToWriteAsTags;
@Nonnull private final ImmutableSet<ResultAttribute> resultAttributesToWriteAsTags;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tags, resultAttributesToWriteAsTags, typeNamesAsTags, attributesAsTags...
I wonder whether it would be cleaner to have a List<TagSupplier>, TagSupplier being a poorly named functional interface to extract tags from server/query/result.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll see if I can do something like that.

//Creates a tag map, associated by the typeName.
//Results fields with the same typeName will receive the same tag values.
HashMap<String,HashMap<String, String>> attrTagByTypeName = newHashMap();
if (!attributesAsTags.isEmpty()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extracting a method may make it more readable.
Is it possible to convert HashMap<HashMap> into a Map<Map>?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem, it will be done in the next commit.

List of attributes which won't be written as fields in InfluxDB, but as
tags associated to the results-fields with the same typeNames value.
- Change HashMap to Map
- extract "attributeAsTag" process into a method
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants