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

Add JSON options to autodiscover hints #14208

Merged
merged 6 commits into from
Oct 25, 2019
Merged

Conversation

ChrsMark
Copy link
Member

@ChrsMark ChrsMark commented Oct 23, 2019

Closes #12634.

cc: @odacremolbap, @exekias

Manual testing

Configure filebeat autodiscover

filebeat:
  autodiscover.providers:
    - type: docker
      hints.enabled: true

Having filebeat running, launch containers with the proper labels each time.
Make sure that Filebeat has permissions to read from /var/lib/docker/containers/, if not a quick option could be to run with sudo like sudo -E ./filebeat -e -d "*" --strict.perms=false. Note that for testing this a Linux host is needed so as Filebeat to be able to locate and read log files properly.

Test that keys are not copied under top level in the output document

docker run -l co.elastic.logs/json.keys_under_root=false -it busybox echo '{"foo":"bar", "error_msg": "error opening file"}'

You should see in the event the following:

"json": {
      "foo": "bar",
      "error_msg": "error opening file"
    },

Test keys are copied under top level in the output document

docker run -l co.elastic.logs/json.keys_under_root=true -it busybox echo '{"foo":"bar", "error_msg": "error opening file"}'

You should see the foo and error_msg in top level.

Test that error is reported

docker run -l co.elastic.logs/json.keys_under_root=true -l co.elastic.logs/json.add_error_key=true -it busybox echo '{"foo":"bar", "error_msg": "error opening file" and some buggy stuff}'

Event should be enriched with:

"error": {
      "type": "json",
      "message": "Error decoding JSON: invalid character 's' after object key:value pair"
    },

@ChrsMark ChrsMark added enhancement containers Related to containers use case Team:Integrations Label for the Integrations team autodiscovery test-plan Add this PR to be manual test plan v7.6.0 labels Oct 23, 2019
@ChrsMark ChrsMark requested a review from a team as a code owner October 23, 2019 11:01
@ChrsMark ChrsMark self-assigned this Oct 23, 2019
Signed-off-by: chrismark <chrismarkou92@gmail.com>
Signed-off-by: chrismark <chrismarkou92@gmail.com>
@ChrsMark ChrsMark changed the title Add JSON options to hints Add JSON options to autodiscover hints Oct 23, 2019
Signed-off-by: chrismark <chrismarkou92@gmail.com>
Signed-off-by: chrismark <chrismarkou92@gmail.com>
@jsoriano
Copy link
Member

Great addition!

Copy link
Contributor

@exekias exekias left a comment

Choose a reason for hiding this comment

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

Looking good!

Copy link
Contributor

@exekias exekias left a comment

Choose a reason for hiding this comment

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

sorry didn't notice failing tests, this will require a make update, and probably a rebase

@exekias
Copy link
Contributor

exekias commented Oct 24, 2019

Also, outside of the scope of this PR (maybe a followup). What would you think about simplifying these parameters for the user? I'm thinking something like this would make things better:

co.elastic.logs/json.enabled=true

This somehow would be an alias for:

co.elastic.logs/json.message_key=message

which is probably what most users want

Signed-off-by: chrismark <chrismarkou92@gmail.com>
@ChrsMark
Copy link
Member Author

Also, outside of the scope of this PR (maybe a followup). What would you think about simplifying these parameters for the user? I'm thinking something like this would make things better:

co.elastic.logs/json.enabled=true

This somehow would be an alias for:

co.elastic.logs/json.message_key=message

which is probably what most users want

🤔 could you elaborate more?

@exekias
Copy link
Contributor

exekias commented Oct 25, 2019

Sure! sorry for my short explanation 🤕

I think that current config keys are not very straight forward. Having that in most cases what users want is probably to just decode the message field as a JSON, I think we should add a more intuitive setting name, that will just do that. This could be co.elastic.logs/json.enabled=true, which should enable JSON decoding from the message field.

This would be the same behavior as using co.elastic.logs/json.message_key=message today

@exekias
Copy link
Contributor

exekias commented Oct 25, 2019

@ChrsMark had a chat and we decided it probably makes more sense to have the enabled keyword in the original JSON settings if possible, I will create an issue for that

@ChrsMark
Copy link
Member Author

jenkins, test this again please

@ChrsMark
Copy link
Member Author

Merging this since Travis went green and failing tests of Jenkins look irrelevant to this patch.

@ChrsMark ChrsMark merged commit a5d5f91 into elastic:master Oct 25, 2019
@ycombinator
Copy link
Contributor

Assigning myself for manually testing this PR for 7.6.0 release per test-plan label.

@ycombinator
Copy link
Contributor

Tested manually. Works as expected!

@ycombinator ycombinator added test-plan-ok This PR passed manual testing and removed test-plan-ok This PR passed manual testing labels Jan 14, 2020
@ycombinator
Copy link
Contributor

Removed test-plan-ok label for now. Will re-test with BC (previously I tested by building from the 7.x branch).

@ycombinator
Copy link
Contributor

ycombinator commented Jan 16, 2020

Tested with BC1 and this works as expected!

@ycombinator ycombinator added the test-plan-ok This PR passed manual testing label Jan 16, 2020
jorgemarey pushed a commit to jorgemarey/beats that referenced this pull request Jun 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autodiscovery containers Related to containers use case enhancement review Team:Integrations Label for the Integrations team test-plan Add this PR to be manual test plan test-plan-ok This PR passed manual testing v7.6.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add JSON options to hints
6 participants