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

Setting user_agent as root key for all events, and canonicalize http headers. #1966

Merged
merged 7 commits into from
Mar 4, 2019

Conversation

simitt
Copy link
Contributor

@simitt simitt commented Feb 28, 2019

Copies user-agent information from context.request.headers information
to root level user_agent key, and apply ua pipeline on this field.

fixes #1960

This should be backported as a bugfix to 7.x and 7.0 branches.

Copies user-agent information from `context.request.headers` information
to root level user_agent key, and apply ua pipeline on this field.

fixes elastic#1960
@simitt simitt self-assigned this Feb 28, 2019
@simitt
Copy link
Contributor Author

simitt commented Feb 28, 2019

@watson @felixbarny @jahtalab after some offline discussions I adapted the current handling for enabling user-agent pipelines, to ensure the user-agent information is always indexed within the top level key user_agent.

model/context.go Outdated
if http == nil || http.Request == nil || http.Request.Headers == nil {
return nil
}
for _, ua := range []string{"user-agent", "User-Agent"} {
Copy link
Member

Choose a reason for hiding this comment

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

I'm a bit torn on whether this is good enough or if we should use the same approach the stdlib does. Another option is to decode headers specially and pull the user agent one out while we're decoding anyway, thoughts?

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 like the ideas, investigating a bit.

Copy link
Member

@graphaelli graphaelli Mar 1, 2019

Choose a reason for hiding this comment

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

I really like where you've taken this. One side effect of this change is that all headers are canonicalized where they weren't before (right?). I think that's a great change (appearance and opt-in searchability wise should a user choose to index any of these) but should be documented - can we add http.request.headers to the fields doc?

Also, what do you think about having the UI display these specially? As a user, I'd expect single valued headers not to be displayed as lists.

with this change we'd have:

image

I think a better display would be:

Array: foo
Array: bar
Array: baz
User-Agent: Mozilla Chrome Edge

and then there is no difference between repeated headers and single valued ones.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I understand your suggestion regarding showing the headers right, then this would involve work from @elastic/apm-ui.

I think it is ok to label canonicalizing headers as a bugfix. However, I was thinking if we also need to address this in the migration script? From my perspective, we don't have to, as the data would still be readable from the UI. Would appreciate your thoughts on this.

I also added the restrictions on the Intake API to the context.response.headers as it belongs to both.

Copy link
Member

Choose a reason for hiding this comment

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

If I understand your suggestion regarding showing the headers right, then this would involve work from @elastic/apm-ui.

Yes, exactly. This work could follow in any future release.

I think it is ok to label canonicalizing headers as a bugfix. However, I was thinking if we also need to address this in the migration script? From my perspective, we don't have to

Agreed on bugfix and also that the migration script does not need (or even could, well) to handle this.

Copy link
Member

Choose a reason for hiding this comment

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

This sound good to me. @formgeist do you have any opinion on this?

Copy link
Contributor

Choose a reason for hiding this comment

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

The values would be displayed as cells when we merge elastic/kibana#32199, correct? I think that's the right way to go.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently they would be displayed as Lists yes. I second @graphaelli 's suggestion to better display as

Array: foo
Array: bar
Array: baz
User-Agent: Mozilla Chrome Edge

I don't see this urgent, but rather as an UI improvement.

Copy link
Member

Choose a reason for hiding this comment

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

@formgeist This is how it looks after the change we did:

screenshot 2019-03-05 at 13 22 59

This is what they want:

screenshot 2019-03-05 at 13 25 13

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, I didn't see it was another nested level. I reckon we should allow for that, it's nicer presentation.

@simitt simitt changed the title Fix setting user_agent as root key for all events. Setting user_agent as root key for all events, and canonicalize http headers. Mar 4, 2019
@simitt simitt merged commit ace70de into elastic:master Mar 4, 2019
simitt added a commit to simitt/apm-server that referenced this pull request Mar 4, 2019
…eaders. (elastic#1966)

Copies user-agent information from `context.request.headers` information
to root level user_agent key, and apply ua pipeline on this field.
Canonicalizes the http headers stored in ES.

fixes elastic#1960
simitt added a commit to simitt/apm-server that referenced this pull request Mar 4, 2019
…eaders. (elastic#1966)

Copies user-agent information from `context.request.headers` information
to root level user_agent key, and apply ua pipeline on this field.
Canonicalizes the http headers stored in ES.

fixes elastic#1960
simitt added a commit that referenced this pull request Mar 6, 2019
…eaders. (#1966) (#1974)

Copies user-agent information from `context.request.headers` information
to root level user_agent key, and apply ua pipeline on this field.
Canonicalizes the http headers stored in ES.

fixes #1960
simitt added a commit that referenced this pull request Mar 6, 2019
…eaders. (#1966) (#1973)

Copies user-agent information from `context.request.headers` information
to root level user_agent key, and apply ua pipeline on this field.
Canonicalizes the http headers stored in ES.

fixes #1960
@simitt simitt deleted the 1960-move-user-agent branch May 6, 2019 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move user_agent information derived by user agent pipeline to root key.
5 participants