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
Preserve tags to join/window #371
Comments
@yosiat You need to group by the tags you want preserved. For example: var windows = stream.from('some_measurement')
.where(lambda: 'dc' = 'europe')
.groupBy('dc')
.window()
.every(10s)
.period(40s)
... |
@yosiat But you are using selector functions |
@nathanielc I can check this out as well thanks to the log function, I will see this tomorrow and let you know. |
@yosiat OK, FYI I was discovered that without changes to the InfluxDB influxql package and the way it handles Aux fields this will not be possible. The tag information is lost when it goes through the |
@nathanielc can you explain? are you talking about influxql.first or first ? |
These lines:
end up calling functions here https://github.com/influxdata/influxdb/blob/master/influxql/call_iterator.go#L266 and https://github.com/influxdata/influxdb/blob/master/influxql/call_iterator.go#L330 Those function do not preserve the tags on the selected points, only the Aux information. The Aux information is a list of values but the keys are stored elsewhere. For InfluxDB it knows ahead of time which tags it wants to preserve when performing a selector function like |
@nathanielc Ok, and this dosen't neither on windows.mapReuce(influxql.first('value')) .. Is there some hack/patch solution that I can do in my tick script to solve this? |
@yosiat adding a |
@nathanielc I think as well it will be the behaviour of my alert. |
@nathanielc I tried the gropuBy(*) and now it looks that is works.. we will do extensive testing and then we will know finally if it works. |
I just had an idea of how this could work without requiring any changes to InfluxQL. Basically we just set the tags and fields maps as the first two values of the Aux slice. The Aux fields are completely opaque interface{} values to the InfluxQL code, so we can use them however we need. |
@nathanielc this sound really cool, If this is an easy (It sounds easy) I can implement and submit a PR |
It should be pretty easy but it deals with some complex features of go. I'll do my best to explain how this could work First there are different types of InfluxQL functions, aggregators, transformations, and selectors See https://docs.influxdata.com/influxdb/v0.12/query_language/functions/ This change only applies to the Selector functions. The pieces that need to change:
Also notice that the code linked is generated code because of the typed handling of the data. So you will need to modify the original templates and the regen the code. How to do so is explained in the CONTRIBUTING.md doc. Finally I started writing a test for this use case in this branch https://github.com/influxdata/kapacitor/tree/nc-issue%23371 The test is a bit old but should get you started. |
@nathanielc I will need to add to ReduceCreator add selectors for first and last like: FirstCallInfo
LastCallInfo using the generator and then do the second and last step? |
@yosiat There isn't any info to convey about the Here for example https://github.com/influxdata/kapacitor/blob/master/pipeline/influxql.go#L180 add and the rest that follow, in the |
@nathanielc OK, I understand :) by the way, I think I will call it SelectorInfo instead of IsSmileSelector ;) |
@yosiat that was a typo ;). I meant |
@nathanielc We only to copy the tags, am I right? If we need to copy only tags, we are copying them to Aux and not to FloatPoint.Tags ? |
@yosiat We need to copy both fields and tags. Fields because while we may be finding the last point in time we want to preserve all fields on the point. These are selection functions so the selected point should be unmodified.
Correct the Aux fields for various reasons are the preserved values during selection not the .Tags field. So the Aux fields should contains something like []interface{}{p.Fields, p.Tags} Then later p.Fields = aux[0] and p.Tags = aux[1]. If you want to create constants for the fields and tags index so its clear what is going on that would be great. |
@nathanielc And do we want to change the topBottom aux to be []interface{fields, tags} as well? |
by the way, can you merge your test please or do you want me to copy them? and I found bug in your test: you need to add another tag "type" with value of "idle" |
No, topBottom need to use the Aux fields as they are, their implementation uses the Aux fields differently.
Go ahead and add the test yourself. Since it won't pass until your changes are in anyways.
I am not sure here, seems like a select function should just return the point unmodified but currently it renames the field to last and drops all other fields. I guess let's not preserve fields for now and keep the existing fields behavior. We can change it later. So this change will only preserve tags. We can start a new discussion on whether fields should also be preserved. Once the work is done to preserve tags, fields will be easy if we decided its the right thing to do. |
@nathanielc so to sum it up: the Aux for simple selectors will contain only tags? |
@yosiat Correct |
@nathanielc ok, this sounds easy :) I will do this tomorrow |
Closing due to pull request - #425 |
Hi,
I am creating tick script with measurement with tags (server_group, dc, etc), my
tick script is something like this:
In the json I am getting on the service I don't have all tags I have in "some_measurement" whom I need.
Is there a way to preserve the tags?
The text was updated successfully, but these errors were encountered: