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

Cherry-pick #22320 to 7.x: [filebeat][httpjson] Initial implementation of httpjson v2 #22920

Merged
merged 1 commit into from
Dec 9, 2020

Conversation

marc-gr
Copy link
Contributor

@marc-gr marc-gr commented Dec 4, 2020

Cherry-pick of PR #22320 to 7.x branch. Original message:

What does this PR do?

Creates an initial implementation of the new Httpjson input.

Why is it important?

HTTPJSON is too specific to our particular modules use cases and is hard to extend or reuse out of them. For this we wanted to do an effort to generalize the input so it can be used in a more flexible way.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

Author's Checklist

  • The possible values that a transform modifies are defined by where it is configured
  • Load cursor from registry
  • Store cursor in registry
  • Custom cursor values
  • Supports oauth
  • Supports basic auth
  • Supports automatic retries
  • Rate limit with custom values
  • Values can have a default in case of empty or failure
  • Value templates use predefined helper functions
    • now
    • parseDuration
    • parseDate
    • formatDate
    • parseTimestamp
    • parseTimestampMilli
    • parseTimestamlNano
    • getRFC5988Link
  • Request transforms
    • Set
    • Append
    • Delete
  • Response transforms
    • Set
    • Append
    • Delete
    • Split
      • Arrays
      • Maps
  • Response pagination
    • Set
    • Append
    • Delete
  • Redirects can forward headers
  • Documentation for the new input
  • Update old documentation to mention deprecation and migration steps
  • Add missing tests

How to test this PR locally

  • Set a mock endpoint to respond to http requests
  • Set up a config that uses the new input
- type: httpjson
  is_v2: true
  interval: 10s
  request.method: post
  request.url: https://example.com
  request.transforms:
    - set:
        target: body.foo
        value: bazz
  response.transforms:
    - delete:
        target: body.this_is_private
  response.pagination:
    - set:
        target: url.value
        value: "https://example.com/page"
    - set:
        target: url.params.p
        value: "{{.last_response.body.page}}"

output.console:
  pretty: true

Then in x-pack/filebeat run mage build && ./filebeat -e -v and check the output.

Related issues

@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Dec 4, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/security-external-integrations (Team:Security-External Integrations)

@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Dec 4, 2020
@marc-gr marc-gr requested a review from a team December 4, 2020 10:35
@elasticmachine
Copy link
Collaborator

elasticmachine commented Dec 4, 2020

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: Pull request #22920 updated

  • Start Time: 2020-12-09T08:48:06.836+0000

  • Duration: 55 min 42 sec

Test stats 🧪

Test Results
Failed 0
Passed 2411
Skipped 259
Total 2670

💚 Flaky test report

Tests succeeded.

Expand to view the summary

Test stats 🧪

Test Results
Failed 0
Passed 2411
Skipped 259
Total 2670

@marc-gr marc-gr force-pushed the backport_22320_7.x branch from 840fd52 to 18bce3a Compare December 4, 2020 13:02
…2320)

* Add oauth config

* Add stateless input

* Add request and basic config

* Create v2 input and basic transforms

* Refactor and set up basic requester structure

* Run fmt

* Set tests and fix tpl

* basic processing structure

* Add pagination mechanism

* Publish the events

* Add check redirect and oauth tests

* Deprecate old httpjson and include both

* Return default value if execution is empty

* wip

* Add split

* Handle request errors and pagination end

* Add date functions for templates and tests

* Add getRFC5988Link functionality to templates

* Switch between v1/v2 based on config flag

* Add cursor

* Add rate limit

* Put back original filebeat.yml

* Add deprecation warning for old httpjson version

* Add transform tests

* Initial doc changes

* Add more debug logs and split tests

* Ignore empty values on set and append

* Allow content type and accept override and change redirect default

* Add add and toInt functions

* Support array responses

* Add tests cases and minor changes

* Add changelog entry

* Do not copy mutex on delete transform

* Add PR suggestions:
  - Modify context done error log
  - Change is_v2 config bool for string config_version
  - Change retryable logger to be created from input logger

* Documentation fixes

(cherry picked from commit 47d8941)
@marc-gr marc-gr force-pushed the backport_22320_7.x branch from 18bce3a to b862b8f Compare December 9, 2020 08:47
@marc-gr marc-gr merged commit 385f9e3 into elastic:7.x Dec 9, 2020
@marc-gr marc-gr deleted the backport_22320_7.x branch December 9, 2020 09:43
@zube zube bot removed the [zube]: Done label Mar 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants