-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Fix metricbeat http module not parsing headers correctly #8564 #8585
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a changelog entry? Seems like there is no system test generating that with headers and is the reason CI didn't detect it. Should we add one?
@@ -14,7 +14,7 @@ | |||
description: > | |||
HTTP request information | |||
fields: | |||
- name: header | |||
- name: headers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also maps with packetbeat: https://github.com/elastic/beats/blob/master/packetbeat/protos/http/_meta/fields.yml#L17
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean that it can produce a conflict? Means, I think I'm lacking context to understand your comment 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant it positive that it will not cause a conflict which is good.
libbeat/tests/system/beat/beat.py
Outdated
@@ -58,6 +58,8 @@ def start(self): | |||
stderr=subprocess.STDOUT, | |||
bufsize=0, | |||
) | |||
# If a "No such file or directory" error points you here, run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good note, it's an error message I wanted to improve for some time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed these are good comments 🙂
What about handling these exceptions to print these messages so nobody has to look for these comments here? (It can be done in a future PR in any case)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once it's merge, I'll open a new PR to address this errors and print them. It wasn't the good moment then and I'd like to understand better why the error happens instead of assuming some behavior and print some message that could be wrong and misleads the devs.
metricbeat/tests/system/test_http.py
Outdated
@@ -33,12 +41,15 @@ def test_json(self): | |||
self.assertEqual(len(output), 1) | |||
evt = output[0] | |||
|
|||
print(json.dumps(evt)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
left over?
metricbeat/tests/system/test_http.py
Outdated
assert evt["http"]["test"]["hello"] == "world" | ||
|
||
# Delete dynamic namespace part for fields comparison | ||
del evt["http"]["test"] | ||
|
||
self.assertItemsEqual(self.de_dot(HTTP_FIELDS), evt.keys(), evt) | ||
print(json.dumps(evt)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leftover? Did you plan to add here something around the new header you specified above?
Can you rebase and take a look at my comments? |
26c0a57
to
0fd2644
Compare
Rebase done and comments addressed. I was trying hard to improve the tests on this module but I was hitting the wall with some unknown errors. I'll do it in a different PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes LGTM. Needs rebase on top of master to pass ingest phase.
0fd2644
to
061c096
Compare
😕 rebase done but both tests complain about |
I assume if both complain, there is something off with the formatting. Try to run |
Which can be considered actual formatting errors, yes, because they aren't properly aligned. |
When changing to 1.10.3 it seems that the formatter doesn't complain about those two files (althought I still think they aren't properly formatted ¯_(ツ)_/¯ ) Buuuuut tests still complain about @ruflin you told me that you saw some diffs on a Python file so maybe it is something related with the Python version (2.7.10) instead of with Go version? ➜ metricbeat git:(metricbeat-http-headers-bugfix) go version
go version go1.10.3 darwin/amd64
➜ metricbeat git:(metricbeat-http-headers-bugfix) make clean && make fmt
New python executable in /Users/privacy/go/src/github.com/elastic/beats/metricbeat/build/python-env/bin/python
Installing setuptools, pip, wheel...done.
➜ metricbeat git:(metricbeat-http-headers-bugfix) . build/python-env/bin/activate
(python-env) ➜ metricbeat git:(metricbeat-http-headers-bugfix) make fmt
(python-env) ➜ metricbeat git:(metricbeat-http-headers-bugfix) python --version
Python 2.7.10 |
I think the problem is that you are running My pyhton version is 2.7.15 but I don't think it makes a diff here because of the note above. |
Running |
jenkins, test this |
|
||
func serveHeader(w http.ResponseWriter, r *http.Request) { | ||
fmt.Println("Key: " + r.Header.Get("key")) | ||
fmt.Fprintf(w, `{"key":"%s"}`, r.Header.Get("key")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This writes to the body of the http output instead of the headers I think?
dd22a24
to
7001ba6
Compare
7001ba6
to
6ea540a
Compare
@ruflin Changelog is added, although I'm not sure if there's some problem with Github yet because I have seen some conflict with CHANGELOG file which doesn't appear now. |
CHANGELOG.asciidoc
Outdated
@@ -88,6 +88,8 @@ https://github.com/elastic/beats/compare/v6.4.0...master[Check the HEAD diff] | |||
- Avoid mapping issues in kubernetes module. {pull}8487[8487] | |||
- Fix issue that would prevent kafka module to find a proper broker when port is not set {pull}8613[8613] | |||
- Fix range colors in multiple visualizations. {issue}8633[8633] {pull}8634[8634] | |||
- Add Kafka dashboard. {pull}8457[8457] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be here.
b9d567b
to
beda237
Compare
Refer to #8564 for more info