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

[Heartbeat] Add httpcommon options to ZipURL #27699

Merged
merged 9 commits into from
Sep 8, 2021

Conversation

andrewvc
Copy link
Contributor

@andrewvc andrewvc commented Sep 1, 2021

What does this PR do?

Support httpcommon options for zip_url sources for browser based monitors. This adds custom SSL, proxy, and timeout options.

Fixes #27597

Why is it important?

In large enterprises its common to use custom CAs, proxies, etc.

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

You'll need to run this in the x-pack/heartbeat directory with the following monitor config that proves the ssl options provided by httpcommon are in effect. The below config intentionally uses an outdated protocol (TLSv1.0) which github will refuse to serve.

heartbeat.monitors:
- name: Todos
  id: todos
  type: browser
  enabled: true
  schedule: "@every 3m"
  tags: todos-app
  params:
    url: "https://elastic.github.io/synthetics-demo/"
  source:
    zip_url: 
      url: "https://github.com/elastic/synthetics-demo/archive/refs/heads/main.zip"
      folder: "todos/synthetics-tests"
      ssl:
        supported_protocols: ["TLSv1.0"]

Should yield the following error event (which I've helpfully JSON formatted here. It can be easier to test this with the output.console: ~ instead of the default output.elasticsearch option.

{
	"@timestamp": "0001-01-01T00:00:00.000Z",
	"@metadata": {
		"beat": "heartbeat",
		"type": "_doc",
		"version": "8.0.0"
	},
	"error": {
		"message": "could not fetch for suite job: could not check if zip source changed for https://github.com/elastic/synthetics-demo/archive/refs/heads/main.zip: Head \"https://github.com/elastic/synthetics-demo/archive/refs/heads/main.zip\": remote error: tls: protocol version not supported",
		"type": "io"
	},
	"tags": ["todos-app"],
	"event": {
		"dataset": "browser"
	},
	"ecs": {
		"version": "1.11.0"
	},
	"agent": {
		"ephemeral_id": "75134b46-d5df-4c86-afd0-f0edeb98b471",
		"id": "676de04f-0e18-4be3-ac13-eaa611089369",
		"name": "LAPTOP-80O11FM2",
		"type": "heartbeat",
		"version": "8.0.0"
	},
	"observer": {
		"ip": ["172.31.124.252", "fe80::215:5dff:feab:a8f0"],
		"mac": ["ce:16:bd:46:2b:a8", "1a:2f:00:7f:96:e6", "00:15:5d:ab:a8:f0"],
		"hostname": "LAPTOP-80O11FM2"
	},
	"monitor": {
		"timespan": {
			"lt": "2021-09-02T01:39:54.310Z",
			"gte": "2021-09-02T01:36:54.310Z"
		},
		"id": "todos",
		"name": "Todos",
		"status": "down",
		"type": "browser"
	}
}

@andrewvc andrewvc requested a review from a team as a code owner September 1, 2021 19:22
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Sep 1, 2021
@andrewvc andrewvc self-assigned this Sep 1, 2021
@andrewvc andrewvc added enhancement Heartbeat Team:obs-ds-hosted-services Label for the Observability Hosted Services team v7.16.0 labels Sep 1, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/uptime (Team:Uptime)

@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Sep 1, 2021
@andrewvc andrewvc marked this pull request as draft September 1, 2021 19:22
@elasticmachine
Copy link
Collaborator

elasticmachine commented Sep 1, 2021

💚 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 preview

Expand to view the summary

Build stats

  • Start Time: 2021-09-07T23:32:22.524+0000

  • Duration: 67 min 2 sec

  • Commit: abff168

Test stats 🧪

Test Results
Failed 0
Passed 3493
Skipped 80
Total 3573

Trends 🧪

Image of Build Times

Image of Tests

💚 Flaky test report

Tests succeeded.

Expand to view the summary

Test stats 🧪

Test Results
Failed 0
Passed 3493
Skipped 80
Total 3573

Copy link
Contributor

@justinkambic justinkambic left a comment

Choose a reason for hiding this comment

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

I'm seeing the desired output, and it goes away when I remove the unsupported protocol from the config. Smoke test is looking good. Unsure if there are any other variables to check.

Copy link
Member

@vigneshshanmugam vigneshshanmugam left a comment

Choose a reason for hiding this comment

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

Code changes LGTM, Would need to cleanup heartbeat.yml before merging in.

@andrewvc andrewvc marked this pull request as ready for review September 7, 2021 22:49
@andrewvc andrewvc merged commit acb4fd5 into elastic:master Sep 8, 2021
@andrewvc andrewvc deleted the zip-ssl-opts branch September 8, 2021 02:29
@andrewvc
Copy link
Contributor Author

andrewvc commented Sep 8, 2021

@Mergifyio backport 7.x

mergify bot pushed a commit that referenced this pull request Sep 8, 2021
Support httpcommon options for zip_url sources for browser based monitors. This adds custom SSL, proxy, and timeout options.

Fixes #27597

(cherry picked from commit acb4fd5)
@mergify
Copy link
Contributor

mergify bot commented Sep 8, 2021

Command backport 7.x: success

Backports have been created

mdelapenya added a commit to mdelapenya/beats that referenced this pull request Sep 9, 2021
* master: (39 commits)
  [Heartbeat] Move JSON tests from python->go (elastic#27816)
  docs: simplify permissions for Dockerfile COPY (elastic#27754)
  Osquerybeat: Fix osquery logger plugin severy levels mapping (elastic#27789)
  [Filebeat] Update compatibility function to remove processor description on ES < 7.9.0 (elastic#27774)
  warn log entry and no validation failure when both queue_url and buck… (elastic#27612)
  libbeat/cmd/instance: ensure test config file has appropriate permissions (elastic#27178)
  [Heartbeat] Add httpcommon options to ZipURL (elastic#27699)
  Add a header round tripper option to httpcommon (elastic#27509)
  [Elastic Agent] Add validation to ensure certificate paths are absolute. (elastic#27779)
  Rename dashboards according to module.yml files for master (elastic#27749)
  Refactor vagrantfile, add scripts for provisioning with docker/kind (elastic#27726)
  Accept syslog dates with leading 0 (elastic#27775)
  [Filebeat] Add timezone config option to decode_cef and syslog input (elastic#27727)
  [Filebeat] Threatintel compatibility updates (elastic#27323)
  Add support for ephemeral containers in elastic agent dynamic provider (elastic#27707)
  [Filebeat] Integration tests in CI for AWS-S3 input (elastic#27491)
  Fix flakyness of TestFilestreamEmptyLine (elastic#27705)
  [Filebeat] kafka v2 using parsers (elastic#27335)
  Update Kafka version parsing / supported range (elastic#27720)
  Update Sarama to 1.29.1 (elastic#27717)
  ...
Icedroid pushed a commit to Icedroid/beats that referenced this pull request Nov 1, 2021
Support httpcommon options for zip_url sources for browser based monitors. This adds custom SSL, proxy, and timeout options.

Fixes elastic#27597
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Heartbeat Team:obs-ds-hosted-services Label for the Observability Hosted Services team v7.16.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Heartbeat] Support private CAs for zip_url
4 participants