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

libbeat/kibana: add ClientConfig.Headers #20580

Merged
merged 7 commits into from
Aug 20, 2020

Conversation

axw
Copy link
Member

@axw axw commented Aug 13, 2020

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.

axw added 2 commits August 13, 2020 10:27
Add configurable headers to include in every
request sent to Kibana. This is needed in some
security applications, for authenticating the
Beat.
@axw axw added enhancement needs_backport PR is waiting to be backported to other branches. Team:Integrations Label for the Integrations team Team:Services (Deprecated) Label for the former Integrations-Services team labels Aug 13, 2020
@axw axw requested review from a team as code owners August 13, 2020 03:21
@elasticmachine
Copy link
Collaborator

Pinging @elastic/integrations (Team:Integrations)

@elasticmachine
Copy link
Collaborator

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

@botelastic botelastic bot added needs_team Indicates that the issue/PR needs a Team:* label and removed needs_team Indicates that the issue/PR needs a Team:* label labels Aug 13, 2020
@elasticmachine
Copy link
Collaborator

elasticmachine commented Aug 13, 2020

💔 Tests Failed

Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: [Pull request #20580 updated]

  • Start Time: 2020-08-19T12:40:38.665+0000

  • Duration: 73 min 51 sec

Test stats 🧪

Test Results
Failed 2
Passed 17891
Skipped 1824
Total 19717

Test errors

Expand to view the tests failures

  • Name: Build and Test / Libbeat / Libbeat oss / TestReplaceClientWorker – pipeline

    • Age: 1
    • Duration: 22.17
    • Error Details: Failed
  • Name: Build and Test / Libbeat / Libbeat oss / TestReplaceClientWorker/network_client – pipeline

    • Age: 1
    • Duration: 20.87
    • Error Details: Failed

Steps errors

Expand to view the steps failures

  • Name: Mage build test

    • Description: mage build test

    • Duration: 21 min 39 sec

    • Start Time: 2020-08-19T13:05:38.352+0000

    • log

  • Name: Make test

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

    • Duration: 6 min 57 sec

    • Start Time: 2020-08-19T13:15:47.642+0000

    • log

  • Name: Recursively delete the current directory from the workspace

    • Description: script returned exit code 2

    • Duration: 1 min 9 sec

    • Start Time: 2020-08-19T13:21:59.007+0000

    • log

Log output

Expand to view the last 100 lines of log output

[2020-08-19T13:52:50.610Z] + tar -xpf source.tgz
[2020-08-19T13:53:00.916Z] + rm source.tgz
[2020-08-19T13:53:00.932Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20580/src/github.com/elastic/beats
[2020-08-19T13:53:00.953Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20580/src/github.com/elastic/beats/Lint
[2020-08-19T13:53:01.037Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20580/src/github.com/elastic/beats/Elastic-Agent-Mac-OS-X
[2020-08-19T13:53:01.113Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20580/src/github.com/elastic/beats/Elastic-Agent-x-pack
[2020-08-19T13:53:01.186Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20580/src/github.com/elastic/beats/Auditbeat-oss-Mac-OS-X
[2020-08-19T13:53:01.273Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20580/src/github.com/elastic/beats/Winlogbeat-oss
[2020-08-19T13:53:01.362Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20580/src/github.com/elastic/beats/Filebeat-x-pack-Mac-OS-X
[2020-08-19T13:53:01.450Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20580/src/github.com/elastic/beats/Auditbeat-crosscompile
[2020-08-19T13:53:01.526Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20580/src/github.com/elastic/beats/dockerlogbeat
[2020-08-19T13:53:01.615Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20580/src/github.com/elastic/beats/Journalbeat
[2020-08-19T13:53:01.692Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20580/src/github.com/elastic/beats/Auditbeat-x-pack-Mac-OS-X
[2020-08-19T13:53:01.768Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20580/src/github.com/elastic/beats/Generators-Metricbeat-Linux
[2020-08-19T13:53:01.849Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20580/src/github.com/elastic/beats/Functionbeat-x-pack
[2020-08-19T13:53:01.951Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20580/src/github.com/elastic/beats/Filebeat-Mac-OS-X
[2020-08-19T13:53:02.032Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20580/src/github.com/elastic/beats/Elastic-Agent-x-pack-Windows
[2020-08-19T13:53:02.119Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20580/src/github.com/elastic/beats/Packetbeat-Linux
[2020-08-19T13:53:02.196Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20580/src/github.com/elastic/beats/Metricbeat-OSS-Unit-tests
[2020-08-19T13:53:02.289Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20580/src/github.com/elastic/beats/Heartbeat-Mac-OS-X
[2020-08-19T13:53:02.371Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20580/src/github.com/elastic/beats/Functionbeat-Mac-OS-X-x-pack
[2020-08-19T13:53:02.461Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20580/src/github.com/elastic/beats/Metricbeat-Mac-OS-X
[2020-08-19T13:53:02.539Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20580/src/github.com/elastic/beats/Heartbeat-oss
[2020-08-19T13:53:02.631Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20580/src/github.com/elastic/beats/Packetbeat-Mac-OS-X
[2020-08-19T13:53:02.719Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20580/src/github.com/elastic/beats/Auditbeat-x-pack-Windows
[2020-08-19T13:53:02.806Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20580/src/github.com/elastic/beats/Heartbeat-Windows
[2020-08-19T13:53:02.892Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20580/src/github.com/elastic/beats/Auditbeat-x-pack
[2020-08-19T13:53:02.984Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20580/src/github.com/elastic/beats/Generators-Beat-Mac-OS-X
[2020-08-19T13:53:03.067Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20580/src/github.com/elastic/beats/Auditbeat-oss-Windows
[2020-08-19T13:53:03.157Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20580/src/github.com/elastic/beats/Winlogbeat-Windows-x-pack
[2020-08-19T13:53:03.232Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20580/src/github.com/elastic/beats/Winlogbeat-Windows
[2020-08-19T13:53:03.309Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20580/src/github.com/elastic/beats/Auditbeat-oss-Linux
[2020-08-19T13:53:03.386Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20580/src/github.com/elastic/beats/Metricbeat-x-pack-Mac-OS-X
[2020-08-19T13:53:03.464Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20580/src/github.com/elastic/beats/Filebeat-x-pack-Windows
[2020-08-19T13:53:03.557Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20580/src/github.com/elastic/beats/Functionbeat-Windows
[2020-08-19T13:53:03.644Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20580/src/github.com/elastic/beats/Metricbeat-crosscompile
[2020-08-19T13:53:03.729Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20580/src/github.com/elastic/beats/Libbeat-x-pack
[2020-08-19T13:53:03.816Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20580/src/github.com/elastic/beats/Filebeat-Windows
[2020-08-19T13:53:03.893Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20580/src/github.com/elastic/beats/Packetbeat-Windows
[2020-08-19T13:53:03.976Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20580/src/github.com/elastic/beats/Metricbeat-Windows
[2020-08-19T13:53:04.060Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20580/src/github.com/elastic/beats/Metricbeat-x-pack-Windows
[2020-08-19T13:53:04.152Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20580/src/github.com/elastic/beats/Generators-Metricbeat-Mac-OS-X
[2020-08-19T13:53:04.228Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20580/src/github.com/elastic/beats/Libbeat-oss
[2020-08-19T13:53:04.314Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20580/src/github.com/elastic/beats/Generators-Beat-Linux
[2020-08-19T13:53:04.392Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20580/src/github.com/elastic/beats/Filebeat-x-pack
[2020-08-19T13:53:04.470Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20580/src/github.com/elastic/beats/Filebeat-oss
[2020-08-19T13:53:04.546Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20580/src/github.com/elastic/beats/Metricbeat-OSS-Go-Integration-tests
[2020-08-19T13:53:04.621Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20580/src/github.com/elastic/beats/Metricbeat-OSS-Python-Integration-tests
[2020-08-19T13:53:04.696Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20580/src/github.com/elastic/beats/Metricbeat-x-pack
[2020-08-19T13:53:05.107Z] + cat
[2020-08-19T13:53:05.108Z] + /usr/local/bin/runbld ./runbld-script --job-name elastic+beats+pull-request
[2020-08-19T13:53:05.108Z] Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8
[2020-08-19T13:53:11.698Z] runbld>>> runbld started
[2020-08-19T13:53:11.698Z] runbld>>> 1.6.12/f45d832f2ba0aa2722ab4ec1fda8ad140f027f8b
[2020-08-19T13:53:13.620Z] runbld>>> The following profiles matched the job 'elastic+beats+pull-request' in order of occurrence in the config (last value wins).
[2020-08-19T13:53:13.620Z] runbld>>> Matches in the system config:
[2020-08-19T13:53:13.620Z] runbld>>> - Matched ^elastic\+beats
[2020-08-19T13:53:13.620Z] runbld>>> - Matched ^elastic\+beats\+pull-request
[2020-08-19T13:53:15.035Z] runbld>>> Debug logging enabled.
[2020-08-19T13:53:15.035Z] runbld>>> Storing result
[2020-08-19T13:53:15.035Z] runbld>>> Store result: created {:total 2, :successful 2, :failed 0} 1
[2020-08-19T13:53:15.035Z] runbld>>> BUILD: https://c150076387b5421f9154dfbf536e5c60.us-west1.gcp.cloud.es.io:9243/build-1597739501209/t/20200819135314-030BEFB4
[2020-08-19T13:53:15.035Z] runbld>>> Adding system facts.
[2020-08-19T13:53:16.015Z] runbld>>> Adding vcs info for the latest commit:  1c1f701a5fb768f52c73ef28b2ac16167b77fe68
[2020-08-19T13:53:16.015Z] runbld>>> >>>>>>>>>>>> SCRIPT EXECUTION BEGIN >>>>>>>>>>>>
[2020-08-19T13:53:16.015Z] runbld>>> Adding /usr/lib/jvm/java-8-openjdk-amd64/bin to the path.
[2020-08-19T13:53:16.275Z] Processing JUnit reports with runbld...
[2020-08-19T13:53:16.275Z] + echo 'Processing JUnit reports with runbld...'
[2020-08-19T13:53:16.536Z] runbld>>> <<<<<<<<<<<< SCRIPT EXECUTION END <<<<<<<<<<<<
[2020-08-19T13:53:16.536Z] runbld>>> DURATION: 45ms
[2020-08-19T13:53:16.536Z] runbld>>> STDOUT: 40 bytes
[2020-08-19T13:53:16.536Z] runbld>>> STDERR: 49 bytes
[2020-08-19T13:53:16.536Z] runbld>>> WRAPPED PROCESS: SUCCESS (0)
[2020-08-19T13:53:16.536Z] runbld>>> Searching for build metadata in /var/lib/jenkins/workspace/Beats_beats_PR-20580
[2020-08-19T13:53:17.522Z] runbld>>> Storing build metadata: 
[2020-08-19T13:53:17.522Z] runbld>>> Adding test report.
[2020-08-19T13:53:17.522Z] runbld>>> Searching for junit test output files with the pattern: TEST-.*\.xml$ in: /var/lib/jenkins/workspace/Beats_beats_PR-20580/src/github.com/elastic/beats
[2020-08-19T13:53:18.126Z] runbld>>> Found 136 test output files
[2020-08-19T13:53:20.110Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats_PR-20580/src/github.com/elastic/beats/Metricbeat-x-pack/x-pack/metricbeat/build/TEST-go-integration-openmetrics.xml
[2020-08-19T13:53:20.111Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats_PR-20580/src/github.com/elastic/beats/Metricbeat-x-pack/x-pack/metricbeat/build/TEST-go-integration-activemq.xml
[2020-08-19T13:53:20.111Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats_PR-20580/src/github.com/elastic/beats/Metricbeat-x-pack/x-pack/metricbeat/build/TEST-go-integration-iis.xml
[2020-08-19T13:53:20.111Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats_PR-20580/src/github.com/elastic/beats/Metricbeat-x-pack/x-pack/metricbeat/build/TEST-go-integration-istio.xml
[2020-08-19T13:53:20.111Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats_PR-20580/src/github.com/elastic/beats/Metricbeat-x-pack/x-pack/metricbeat/build/TEST-go-integration-tomcat.xml
[2020-08-19T13:53:20.111Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats_PR-20580/src/github.com/elastic/beats/Metricbeat-OSS-Go-Integration-tests/metricbeat/build/TEST-go-integration-graphite.xml
[2020-08-19T13:53:20.111Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats_PR-20580/src/github.com/elastic/beats/Metricbeat-OSS-Go-Integration-tests/metricbeat/build/TEST-go-integration-windows.xml
[2020-08-19T13:53:21.095Z] runbld>>> Test output logs contained: Errors: 0 Failures: 2 Tests: 19566 Skipped: 1557
[2020-08-19T13:53:21.096Z] runbld>>> Storing result
[2020-08-19T13:53:21.096Z] runbld>>> FAILURES: 2
[2020-08-19T13:53:21.723Z] runbld>>> Store result: updated {:total 2, :successful 2, :failed 0} 2
[2020-08-19T13:53:21.723Z] runbld>>> BUILD: https://c150076387b5421f9154dfbf536e5c60.us-west1.gcp.cloud.es.io:9243/build-1597739501209/t/20200819135314-030BEFB4
[2020-08-19T13:53:22.032Z] runbld>>> Email notification disabled by environment variable.
[2020-08-19T13:53:22.032Z] runbld>>> Slack notification disabled by environment variable.
[2020-08-19T13:53:28.388Z] Running on Jenkins in /var/lib/jenkins/workspace/Beats_beats_PR-20580
[2020-08-19T13:53:28.712Z] [INFO] getVaultSecret: Getting secrets
[2020-08-19T13:53:28.822Z] Masking supported pattern matches of $VAULT_ADDR or $VAULT_ROLE_ID or $VAULT_SECRET_ID
[2020-08-19T13:53:29.781Z] + chmod 755 generate-build-data.sh
[2020-08-19T13:53:29.781Z] + ./generate-build-data.sh https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-20580/ https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-20580/runs/6 FAILURE 4370844
[2020-08-19T13:53:29.781Z] INFO: curl https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-20580/runs/6/steps/?limit=10000 -o steps-info.json
[2020-08-19T13:53:35.007Z] INFO: curl https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-20580/runs/6/tests/?status=FAILED -o tests-errors.json
[2020-08-19T13:53:35.258Z] INFO: curl https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-20580/runs/6/log/ -o pipeline-log.txt

@andresrc andresrc requested review from jsoriano and urso August 19, 2020 05:39
@axw
Copy link
Member Author

axw commented Aug 20, 2020

Test failures are unrelated AFAICT.

@axw axw merged commit 38fc1ed into elastic:master Aug 20, 2020
@axw axw deleted the libbeat-kibana-config-headers branch August 20, 2020 00:58
@axw axw removed the needs_backport PR is waiting to be backported to other branches. label Aug 20, 2020
axw added a commit to axw/beats that referenced this pull request Aug 20, 2020
* 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 added a commit to axw/beats that referenced this pull request Aug 20, 2020
* 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 added a commit that referenced this pull request Aug 20, 2020
* 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 added a commit that referenced this pull request Aug 21, 2020
* 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)
melchiormoulin pushed a commit to melchiormoulin/beats that referenced this pull request Oct 14, 2020
* 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
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
enhancement Team:Integrations Label for the Integrations team Team:Services (Deprecated) Label for the former Integrations-Services team v7.9.1 v7.10.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow Kibana endpoint configuration to accept custom headers
5 participants