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 #20580 to 7.9: libbeat/kibana: add ClientConfig.Headers #20699

Merged
merged 1 commit into from
Aug 21, 2020

Conversation

axw
Copy link
Member

@axw axw commented Aug 20, 2020

Cherry-pick of PR #20580 to 7.9 branch. Original message:

What does this PR do?

Add configurable headers to include in every request sent to Kibana.

Why is it important?

This is needed in some security applications, for authenticating the Beat. Specifically, this is needed to fix elastic/apm-server#4065

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.

How to test this PR locally

  1. Run nc -l 1234
  2. Configure filebeat with setup.kibana.host: localhost:1234, and a custom header in setup.kibana.headers
  3. Run filebeat setup

Observe the custom header is logged by netcat:

GET /api/status HTTP/1.1
Host: localhost:1234
User-Agent: Go-http-client/1.1
Accept: application/json
Content-Type: application/json
Foo: bar
Kbn-Xsrf: 1
Accept-Encoding: gzip

Related issues

elastic/apm-server#4065

Use cases

Introduces a means of specifying custom HTTP headers to add to all requests sent to Kibana. As above, needed in some security use cases.

* libbeat/kibana: add ClientConfig.Headers

Add configurable headers to include in every
request sent to Kibana. This is needed in some
security applications, for authenticating the
Beat.

* Add setup.kibana.headers to config/docs

* libbeat/kibana: prevent overridding Content-Type

... and Accept, and kbn-xsrf

(cherry picked from commit 38fc1ed)
@axw axw requested review from a team as code owners August 20, 2020 01:29
@axw axw added [zube]: In Review backport Team:Integrations Label for the Integrations team Team:Services (Deprecated) Label for the former Integrations-Services team labels Aug 20, 2020
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Aug 20, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/integrations-services (Team:Services)

@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Aug 20, 2020
@axw
Copy link
Member Author

axw commented Aug 20, 2020

This is being backported for 7.9.1 to address an APM Server / ESS bug. @andresrc and @urso have given +1

@elasticmachine
Copy link
Collaborator

💔 Build Failed

Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: [Pull request #20699 opened]

  • Start Time: 2020-08-20T01:31:02.542+0000

  • Duration: 76 min 37 sec

Test stats 🧪

Test Results
Failed 0
Passed 17846
Skipped 1838
Total 19684

Steps errors

Expand to view the steps failures

  • Name: Make test

    • Description: make -C generator/_templates/metricbeat test

    • Duration: 1 min 10 sec

    • Start Time: 2020-08-20T01:57:05.240+0000

    • log

  • Name: Make test

    • Description: make -C generator/_templates/metricbeat test

    • Duration: 1 min 54 sec

    • Start Time: 2020-08-20T02:03:10.654+0000

    • log

  • Name: Recursively delete the current directory from the workspace

    • Description: script returned exit code 2

    • Duration: 0 min 15 sec

    • Start Time: 2020-08-20T02:04:13.384+0000

    • log

  • Name: Make test

    • Description: make -C generator/_templates/beat test

    • Duration: 3 min 15 sec

    • Start Time: 2020-08-20T02:08:50.335+0000

    • log

  • Name: Recursively delete the current directory from the workspace

    • Description: script returned exit code 2

    • Duration: 0 min 19 sec

    • Start Time: 2020-08-20T02:13:54.364+0000

    • log

Log output

Expand to view the last 100 lines of log output

[2020-08-20T02:46:06.655Z] + rm source.tgz
[2020-08-20T02:46:06.681Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20699/src/github.com/elastic/beats
[2020-08-20T02:46:06.731Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20699/src/github.com/elastic/beats/Lint
[2020-08-20T02:46:06.898Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20699/src/github.com/elastic/beats/Generators-Metricbeat-Linux
[2020-08-20T02:46:07.058Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20699/src/github.com/elastic/beats/Auditbeat-oss-Mac-OS-X
[2020-08-20T02:46:07.221Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20699/src/github.com/elastic/beats/Elastic-Agent-x-pack
[2020-08-20T02:46:07.382Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20699/src/github.com/elastic/beats/Winlogbeat-oss
[2020-08-20T02:46:07.544Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20699/src/github.com/elastic/beats/Auditbeat-crosscompile
[2020-08-20T02:46:07.709Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20699/src/github.com/elastic/beats/Filebeat-x-pack-Mac-OS-X
[2020-08-20T02:46:07.876Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20699/src/github.com/elastic/beats/dockerlogbeat
[2020-08-20T02:46:08.038Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20699/src/github.com/elastic/beats/Journalbeat
[2020-08-20T02:46:08.204Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20699/src/github.com/elastic/beats/Functionbeat-x-pack
[2020-08-20T02:46:08.367Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20699/src/github.com/elastic/beats/Metricbeat-Mac-OS-X
[2020-08-20T02:46:08.529Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20699/src/github.com/elastic/beats/Filebeat-Mac-OS-X
[2020-08-20T02:46:08.693Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20699/src/github.com/elastic/beats/Packetbeat-Linux
[2020-08-20T02:46:08.858Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20699/src/github.com/elastic/beats/Elastic-Agent-x-pack-Windows
[2020-08-20T02:46:09.019Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20699/src/github.com/elastic/beats/Generators-Metricbeat-Mac-OS-X
[2020-08-20T02:46:09.180Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20699/src/github.com/elastic/beats/Auditbeat-x-pack-Mac-OS-X
[2020-08-20T02:46:09.342Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20699/src/github.com/elastic/beats/Heartbeat-Mac-OS-X
[2020-08-20T02:46:09.508Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20699/src/github.com/elastic/beats/Metricbeat-x-pack-Mac-OS-X
[2020-08-20T02:46:09.670Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20699/src/github.com/elastic/beats/Metricbeat-OSS-Unit-tests
[2020-08-20T02:46:09.830Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20699/src/github.com/elastic/beats/Elastic-Agent-Mac-OS-X
[2020-08-20T02:46:09.992Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20699/src/github.com/elastic/beats/Packetbeat-Mac-OS-X
[2020-08-20T02:46:10.154Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20699/src/github.com/elastic/beats/Functionbeat-Mac-OS-X-x-pack
[2020-08-20T02:46:10.313Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20699/src/github.com/elastic/beats/Heartbeat-oss
[2020-08-20T02:46:10.473Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20699/src/github.com/elastic/beats/Auditbeat-oss-Windows
[2020-08-20T02:46:10.633Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20699/src/github.com/elastic/beats/Metricbeat-crosscompile
[2020-08-20T02:46:10.793Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20699/src/github.com/elastic/beats/Heartbeat-Windows
[2020-08-20T02:46:10.955Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20699/src/github.com/elastic/beats/Auditbeat-x-pack
[2020-08-20T02:46:11.115Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20699/src/github.com/elastic/beats/Auditbeat-x-pack-Windows
[2020-08-20T02:46:11.277Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20699/src/github.com/elastic/beats/Winlogbeat-Windows-x-pack
[2020-08-20T02:46:11.437Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20699/src/github.com/elastic/beats/Auditbeat-oss-Linux
[2020-08-20T02:46:11.602Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20699/src/github.com/elastic/beats/Packetbeat-Windows
[2020-08-20T02:46:11.763Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20699/src/github.com/elastic/beats/Libbeat-x-pack
[2020-08-20T02:46:11.928Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20699/src/github.com/elastic/beats/Winlogbeat-Windows
[2020-08-20T02:46:12.087Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20699/src/github.com/elastic/beats/Filebeat-Windows
[2020-08-20T02:46:12.249Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20699/src/github.com/elastic/beats/Filebeat-x-pack-Windows
[2020-08-20T02:46:12.410Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20699/src/github.com/elastic/beats/Functionbeat-Windows
[2020-08-20T02:46:12.574Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20699/src/github.com/elastic/beats/Generators-Beat-Mac-OS-X
[2020-08-20T02:46:12.739Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20699/src/github.com/elastic/beats/Metricbeat-x-pack-Windows
[2020-08-20T02:46:12.904Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20699/src/github.com/elastic/beats/Metricbeat-Windows
[2020-08-20T02:46:13.067Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20699/src/github.com/elastic/beats/Filebeat-oss
[2020-08-20T02:46:13.230Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20699/src/github.com/elastic/beats/Filebeat-x-pack
[2020-08-20T02:46:13.394Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20699/src/github.com/elastic/beats/Libbeat-oss
[2020-08-20T02:46:13.556Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20699/src/github.com/elastic/beats/Metricbeat-OSS-Integration-tests
[2020-08-20T02:46:13.716Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20699/src/github.com/elastic/beats/Metricbeat-Python-integration-tests
[2020-08-20T02:46:13.880Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20699/src/github.com/elastic/beats/Libbeat-crosscompile
[2020-08-20T02:46:14.041Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20699/src/github.com/elastic/beats/Libbeat-stress-tests
[2020-08-20T02:46:14.200Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20699/src/github.com/elastic/beats/Metricbeat-x-pack
[2020-08-20T02:46:14.723Z] + cat
[2020-08-20T02:46:14.723Z] + /usr/local/bin/runbld ./runbld-script --job-name elastic+beats+pull-request
[2020-08-20T02:46:14.723Z] Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8
[2020-08-20T02:46:22.902Z] runbld>>> runbld started
[2020-08-20T02:46:22.902Z] runbld>>> 1.6.12/f45d832f2ba0aa2722ab4ec1fda8ad140f027f8b
[2020-08-20T02:46:24.293Z] runbld>>> The following profiles matched the job 'elastic+beats+pull-request' in order of occurrence in the config (last value wins).
[2020-08-20T02:46:24.293Z] runbld>>> Matches in the system config:
[2020-08-20T02:46:24.294Z] runbld>>> - Matched ^elastic\+beats
[2020-08-20T02:46:24.294Z] runbld>>> - Matched ^elastic\+beats\+pull-request
[2020-08-20T02:46:25.238Z] runbld>>> Debug logging enabled.
[2020-08-20T02:46:25.499Z] runbld>>> Storing result
[2020-08-20T02:46:25.499Z] runbld>>> Store result: created {:total 2, :successful 2, :failed 0} 1
[2020-08-20T02:46:25.499Z] runbld>>> BUILD: https://c150076387b5421f9154dfbf536e5c60.us-west1.gcp.cloud.es.io:9243/build-1597739501209/t/20200820024625-CCE00E20
[2020-08-20T02:46:25.499Z] runbld>>> Adding system facts.
[2020-08-20T02:46:26.886Z] runbld>>> Adding vcs info for the latest commit:  bfe698ad61873ea97140ef9c2ba51ee381687d31
[2020-08-20T02:46:26.886Z] runbld>>> >>>>>>>>>>>> SCRIPT EXECUTION BEGIN >>>>>>>>>>>>
[2020-08-20T02:46:26.886Z] runbld>>> Adding /usr/lib/jvm/java-8-openjdk-amd64/bin to the path.
[2020-08-20T02:46:26.886Z] + echo 'Processing JUnit reports with runbld...'
[2020-08-20T02:46:26.886Z] Processing JUnit reports with runbld...
[2020-08-20T02:46:27.150Z] runbld>>> <<<<<<<<<<<< SCRIPT EXECUTION END <<<<<<<<<<<<
[2020-08-20T02:46:27.150Z] runbld>>> DURATION: 29ms
[2020-08-20T02:46:27.150Z] runbld>>> STDOUT: 40 bytes
[2020-08-20T02:46:27.150Z] runbld>>> STDERR: 49 bytes
[2020-08-20T02:46:27.150Z] runbld>>> WRAPPED PROCESS: SUCCESS (0)
[2020-08-20T02:46:27.150Z] runbld>>> Searching for build metadata in /var/lib/jenkins/workspace/Beats_beats_PR-20699
[2020-08-20T02:46:28.547Z] runbld>>> Storing build metadata: 
[2020-08-20T02:46:28.547Z] runbld>>> Adding test report.
[2020-08-20T02:46:28.547Z] runbld>>> Searching for junit test output files with the pattern: TEST-.*\.xml$ in: /var/lib/jenkins/workspace/Beats_beats_PR-20699/src/github.com/elastic/beats
[2020-08-20T02:46:29.122Z] runbld>>> Found 137 test output files
[2020-08-20T02:46:31.054Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats_PR-20699/src/github.com/elastic/beats/Metricbeat-OSS-Integration-tests/metricbeat/build/TEST-go-integration-graphite.xml
[2020-08-20T02:46:31.054Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats_PR-20699/src/github.com/elastic/beats/Metricbeat-OSS-Integration-tests/metricbeat/build/TEST-go-integration-windows.xml
[2020-08-20T02:46:31.054Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats_PR-20699/src/github.com/elastic/beats/Metricbeat-x-pack/x-pack/metricbeat/build/TEST-go-integration-openmetrics.xml
[2020-08-20T02:46:31.054Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats_PR-20699/src/github.com/elastic/beats/Metricbeat-x-pack/x-pack/metricbeat/build/TEST-go-integration-activemq.xml
[2020-08-20T02:46:31.317Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats_PR-20699/src/github.com/elastic/beats/Metricbeat-x-pack/x-pack/metricbeat/build/TEST-go-integration-iis.xml
[2020-08-20T02:46:31.317Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats_PR-20699/src/github.com/elastic/beats/Metricbeat-x-pack/x-pack/metricbeat/build/TEST-go-integration-istio.xml
[2020-08-20T02:46:31.317Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats_PR-20699/src/github.com/elastic/beats/Metricbeat-x-pack/x-pack/metricbeat/build/TEST-go-integration-tomcat.xml
[2020-08-20T02:46:32.261Z] runbld>>> Test output logs contained: Errors: 0 Failures: 0 Tests: 19533 Skipped: 1560
[2020-08-20T02:46:32.522Z] runbld>>> Storing result
[2020-08-20T02:46:32.522Z] runbld>>> FAILURES: 0
[2020-08-20T02:46:32.782Z] runbld>>> Store result: updated {:total 2, :successful 2, :failed 0} 2
[2020-08-20T02:46:32.782Z] runbld>>> BUILD: https://c150076387b5421f9154dfbf536e5c60.us-west1.gcp.cloud.es.io:9243/build-1597739501209/t/20200820024625-CCE00E20
[2020-08-20T02:46:32.783Z] runbld>>> Email notification disabled by environment variable.
[2020-08-20T02:46:32.783Z] runbld>>> Slack notification disabled by environment variable.
[2020-08-20T02:46:38.785Z] Running on Jenkins in /var/lib/jenkins/workspace/Beats_beats_PR-20699
[2020-08-20T02:46:39.078Z] [INFO] getVaultSecret: Getting secrets
[2020-08-20T02:46:39.151Z] Masking supported pattern matches of $VAULT_ADDR or $VAULT_ROLE_ID or $VAULT_SECRET_ID
[2020-08-20T02:46:40.237Z] + chmod 755 generate-build-data.sh
[2020-08-20T02:46:40.237Z] + ./generate-build-data.sh https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-20699/ https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-20699/runs/1 FAILURE 4537422
[2020-08-20T02:46:40.237Z] INFO: curl https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-20699/runs/1/steps/?limit=10000 -o steps-info.json
[2020-08-20T02:46:43.466Z] INFO: curl https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-20699/runs/1/tests/?status=FAILED -o tests-errors.json
[2020-08-20T02:46:43.716Z] INFO: curl https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-20699/runs/1/log/ -o pipeline-log.txt

@axw axw merged commit 89a7faf into elastic:7.9 Aug 21, 2020
@axw axw deleted the backport_20580_7.9 branch August 21, 2020 01:24
@zube zube bot removed the [zube]: Done label Nov 19, 2020
leweafan pushed a commit to leweafan/beats that referenced this pull request Apr 28, 2023
* libbeat/kibana: add ClientConfig.Headers

Add configurable headers to include in every
request sent to Kibana. This is needed in some
security applications, for authenticating the
Beat.

* Add setup.kibana.headers to config/docs

* libbeat/kibana: prevent overridding Content-Type

... and Accept, and kbn-xsrf

(cherry picked from commit 88f95a7)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport Team:Integrations Label for the Integrations team Team:Services (Deprecated) Label for the former Integrations-Services team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants