From b153044e8e2e4105b3f57447d8b9e2d04309404b Mon Sep 17 00:00:00 2001 From: Blake Rouse Date: Thu, 6 Aug 2020 13:58:01 -0400 Subject: [PATCH] [Elastic Agent] Add support for synthetics inputs that run heartbeat (#20387) * Add support for synthetics inputs that run heartbeat. * Run mage fmt. * Add changelog. * Update test configs to use host instead of hosts. * Enable support for top-level inputs from Elastic Agent. --- dev-tools/packaging/packages.yml | 41 +++++++++++++++++++ heartbeat/beater/heartbeat.go | 2 + heartbeat/monitors/active/http/http.go | 1 + heartbeat/monitors/active/icmp/icmp.go | 1 + heartbeat/monitors/active/tcp/tcp.go | 1 + x-pack/elastic-agent/CHANGELOG.asciidoc | 1 + x-pack/elastic-agent/magefile.go | 2 +- .../pkg/agent/program/program_test.go | 12 +++--- .../pkg/agent/program/supported.go | 3 +- .../endpoint_basic-endpoint-security.yml | 1 + .../agent/program/testdata/endpoint_basic.yml | 1 + .../program/testdata/endpoint_no_fleet.yml | 1 + .../testdata/endpoint_unknown_output.yml | 1 + .../testdata/monitor_config-heartbeat.yml | 18 -------- .../agent/program/testdata/monitor_config.yml | 23 ----------- .../single_config-endpoint-security.yml | 1 + .../testdata/single_config-heartbeat.yml | 18 ++++++++ .../agent/program/testdata/single_config.yml | 8 ++++ .../testdata/synthetics_config-heartbeat.yml | 33 +++++++++++++++ .../program/testdata/synthetics_config.yml | 31 ++++++++++++++ .../pkg/agent/transpiler/rules.go | 4 +- x-pack/elastic-agent/spec/heartbeat.yml | 22 ++++++++++ .../elastic-agent/spec/heartbeat.yml.disabled | 27 ------------ 23 files changed, 175 insertions(+), 78 deletions(-) delete mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/monitor_config-heartbeat.yml delete mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/monitor_config.yml create mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/single_config-heartbeat.yml create mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/synthetics_config-heartbeat.yml create mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/synthetics_config.yml create mode 100644 x-pack/elastic-agent/spec/heartbeat.yml delete mode 100644 x-pack/elastic-agent/spec/heartbeat.yml.disabled diff --git a/dev-tools/packaging/packages.yml b/dev-tools/packaging/packages.yml index 6c3752fb2fa1..ea3ddfe76e07 100644 --- a/dev-tools/packaging/packages.yml +++ b/dev-tools/packaging/packages.yml @@ -64,6 +64,16 @@ shared: source: '{{.AgentDropPath}}/filebeat-{{ beat_version }}{{if .Snapshot}}-SNAPSHOT{{end}}-{{.GOOS}}-{{.AgentArchName}}.tar.gz.asc' mode: 0644 skip_on_missing: true + /var/lib/{{.BeatName}}/downloads/heartbeat-{{ beat_version }}{{if .Snapshot}}-SNAPSHOT{{end}}-{{.GOOS}}-{{.AgentArchName}}.tar.gz: + source: '{{.AgentDropPath}}/heartbeat-{{ beat_version }}{{if .Snapshot}}-SNAPSHOT{{end}}-{{.GOOS}}-{{.AgentArchName}}.tar.gz' + mode: 0644 + /var/lib/{{.BeatName}}/downloads/heartbeat-{{ beat_version }}{{if .Snapshot}}-SNAPSHOT{{end}}-{{.GOOS}}-{{.AgentArchName}}.tar.gz.sha512: + source: '{{.AgentDropPath}}/heartbeat-{{ beat_version }}{{if .Snapshot}}-SNAPSHOT{{end}}-{{.GOOS}}-{{.AgentArchName}}.tar.gz.sha512' + mode: 0644 + /var/lib/{{.BeatName}}/downloads/heartbeat-{{ beat_version }}{{if .Snapshot}}-SNAPSHOT{{end}}-{{.GOOS}}-{{.AgentArchName}}.tar.gz.asc: + source: '{{.AgentDropPath}}/heartbeat-{{ beat_version }}{{if .Snapshot}}-SNAPSHOT{{end}}-{{.GOOS}}-{{.AgentArchName}}.tar.gz.asc' + mode: 0644 + skip_on_missing: true /var/lib/{{.BeatName}}/downloads/metricbeat-{{ beat_version }}{{if .Snapshot}}-SNAPSHOT{{end}}-{{.GOOS}}-{{.AgentArchName}}.tar.gz: source: '{{.AgentDropPath}}/metricbeat-{{ beat_version }}{{if .Snapshot}}-SNAPSHOT{{end}}-{{.GOOS}}-{{.AgentArchName}}.tar.gz' mode: 0644 @@ -135,6 +145,17 @@ shared: source: '{{.AgentDropPath}}/filebeat-{{ beat_version }}{{if .Snapshot}}-SNAPSHOT{{end}}-{{.GOOS}}-{{.AgentArchName}}.tar.gz.asc' mode: 0644 skip_on_missing: true + /etc/{{.BeatName}}/data/downloads/heartbeat-{{ beat_version }}{{if .Snapshot}}-SNAPSHOT{{end}}-{{.GOOS}}-{{.AgentArchName}}.tar.gz: + source: '{{.AgentDropPath}}/heartbeat-{{ beat_version }}{{if .Snapshot}}-SNAPSHOT{{end}}-{{.GOOS}}-{{.AgentArchName}}.tar.gz' + mode: 0644 + /etc/{{.BeatName}}/data/downloads/heartbeat-{{ beat_version }}{{if .Snapshot}}-SNAPSHOT{{end}}-{{.GOOS}}-{{.AgentArchName}}.tar.gz.sha512: + source: '{{.AgentDropPath}}/heartbeat-{{ beat_version }}{{if .Snapshot}}-SNAPSHOT{{end}}-{{.GOOS}}-{{.AgentArchName}}.tar.gz.sha512' + mode: 0644 + skip_on_missing: true + /etc/{{.BeatName}}/data/downloads/heartbeat-{{ beat_version }}{{if .Snapshot}}-SNAPSHOT{{end}}-{{.GOOS}}-{{.AgentArchName}}.tar.gz.asc: + source: '{{.AgentDropPath}}/heartbeat-{{ beat_version }}{{if .Snapshot}}-SNAPSHOT{{end}}-{{.GOOS}}-{{.AgentArchName}}.tar.gz.asc' + mode: 0644 + skip_on_missing: true /etc/{{.BeatName}}/data/downloads/metricbeat-{{ beat_version }}{{if .Snapshot}}-SNAPSHOT{{end}}-{{.GOOS}}-{{.AgentArchName}}.tar.gz: source: '{{.AgentDropPath}}/metricbeat-{{ beat_version }}{{if .Snapshot}}-SNAPSHOT{{end}}-{{.GOOS}}-{{.AgentArchName}}.tar.gz' mode: 0644 @@ -195,6 +216,16 @@ shared: source: '{{.AgentDropPath}}/filebeat-{{ beat_version }}{{if .Snapshot}}-SNAPSHOT{{end}}-{{.GOOS}}-{{.AgentArchName}}.tar.gz.asc' mode: 0644 skip_on_missing: true + 'data/downloads/heartbeat-{{ beat_version }}{{if .Snapshot}}-SNAPSHOT{{end}}-{{.GOOS}}-{{.AgentArchName}}.tar.gz': + source: '{{.AgentDropPath}}/heartbeat-{{ beat_version }}{{if .Snapshot}}-SNAPSHOT{{end}}-{{.GOOS}}-{{.AgentArchName}}.tar.gz' + mode: 0644 + 'data/downloads/heartbeat-{{ beat_version }}{{if .Snapshot}}-SNAPSHOT{{end}}-{{.GOOS}}-{{.AgentArchName}}.tar.gz.sha512': + source: '{{.AgentDropPath}}/heartbeat-{{ beat_version }}{{if .Snapshot}}-SNAPSHOT{{end}}-{{.GOOS}}-{{.AgentArchName}}.tar.gz.sha512' + mode: 0644 + 'data/downloads/heartbeat-{{ beat_version }}{{if .Snapshot}}-SNAPSHOT{{end}}-{{.GOOS}}-{{.AgentArchName}}.tar.gz.asc': + source: '{{.AgentDropPath}}/heartbeat-{{ beat_version }}{{if .Snapshot}}-SNAPSHOT{{end}}-{{.GOOS}}-{{.AgentArchName}}.tar.gz.asc' + mode: 0644 + skip_on_missing: true 'data/downloads/metricbeat-{{ beat_version }}{{if .Snapshot}}-SNAPSHOT{{end}}-{{.GOOS}}-{{.AgentArchName}}.tar.gz': source: '{{.AgentDropPath}}/metricbeat-{{ beat_version }}{{if .Snapshot}}-SNAPSHOT{{end}}-{{.GOOS}}-{{.AgentArchName}}.tar.gz' mode: 0644 @@ -239,6 +270,16 @@ shared: source: '{{.AgentDropPath}}/filebeat-{{ beat_version }}{{if .Snapshot}}-SNAPSHOT{{end}}-{{.GOOS}}-{{.AgentArchName}}.zip.asc' mode: 0644 skip_on_missing: true + 'data/downloads/heartbeat-{{ beat_version }}{{if .Snapshot}}-SNAPSHOT{{end}}-{{.GOOS}}-{{.AgentArchName}}.zip': + source: '{{.AgentDropPath}}/heartbeat-{{ beat_version }}{{if .Snapshot}}-SNAPSHOT{{end}}-{{.GOOS}}-{{.AgentArchName}}.zip' + mode: 0644 + 'data/downloads/heartbeat-{{ beat_version }}{{if .Snapshot}}-SNAPSHOT{{end}}-{{.GOOS}}-{{.AgentArchName}}.zip.sha512': + source: '{{.AgentDropPath}}/heartbeat-{{ beat_version }}{{if .Snapshot}}-SNAPSHOT{{end}}-{{.GOOS}}-{{.AgentArchName}}.zip.sha512' + mode: 0644 + 'data/downloads/heartbeat-{{ beat_version }}{{if .Snapshot}}-SNAPSHOT{{end}}-{{.GOOS}}-{{.AgentArchName}}.zip.asc': + source: '{{.AgentDropPath}}/heartbeat-{{ beat_version }}{{if .Snapshot}}-SNAPSHOT{{end}}-{{.GOOS}}-{{.AgentArchName}}.zip.asc' + mode: 0644 + skip_on_missing: true 'data/downloads/metricbeat-{{ beat_version }}{{if .Snapshot}}-SNAPSHOT{{end}}-{{.GOOS}}-{{.AgentArchName}}.zip': source: '{{.AgentDropPath}}/metricbeat-{{ beat_version }}{{if .Snapshot}}-SNAPSHOT{{end}}-{{.GOOS}}-{{.AgentArchName}}.zip' mode: 0644 diff --git a/heartbeat/beater/heartbeat.go b/heartbeat/beater/heartbeat.go index 7e0f2aa75a1e..15185c707deb 100644 --- a/heartbeat/beater/heartbeat.go +++ b/heartbeat/beater/heartbeat.go @@ -139,6 +139,8 @@ func (bt *Heartbeat) RunStaticMonitors(b *beat.Beat) error { func (bt *Heartbeat) RunCentralMgmtMonitors(b *beat.Beat) { monitors := cfgfile.NewRunnerList(management.DebugK, bt.dynamicFactory, b.Publisher) reload.Register.MustRegisterList(b.Info.Beat+".monitors", monitors) + inputs := cfgfile.NewRunnerList(management.DebugK, bt.dynamicFactory, b.Publisher) + reload.Register.MustRegisterList("inputs", inputs) } // RunReloadableMonitors runs the `heartbeat.config.monitors` portion of the yaml config if present. diff --git a/heartbeat/monitors/active/http/http.go b/heartbeat/monitors/active/http/http.go index cf0f98338422..744636635674 100644 --- a/heartbeat/monitors/active/http/http.go +++ b/heartbeat/monitors/active/http/http.go @@ -33,6 +33,7 @@ import ( func init() { monitors.RegisterActive("http", create) + monitors.RegisterActive("synthetics/http", create) } var debugf = logp.MakeDebug("http") diff --git a/heartbeat/monitors/active/icmp/icmp.go b/heartbeat/monitors/active/icmp/icmp.go index 45fdf8a54b32..f9119ab19ec9 100644 --- a/heartbeat/monitors/active/icmp/icmp.go +++ b/heartbeat/monitors/active/icmp/icmp.go @@ -36,6 +36,7 @@ var debugf = logp.MakeDebug("icmp") func init() { monitors.RegisterActive("icmp", create) + monitors.RegisterActive("synthetics/icmp", create) } func create( diff --git a/heartbeat/monitors/active/tcp/tcp.go b/heartbeat/monitors/active/tcp/tcp.go index 26f96d2e0102..6be682ee560d 100644 --- a/heartbeat/monitors/active/tcp/tcp.go +++ b/heartbeat/monitors/active/tcp/tcp.go @@ -40,6 +40,7 @@ import ( func init() { monitors.RegisterActive("tcp", create) + monitors.RegisterActive("synthetics/tcp", create) } var debugf = logp.MakeDebug("tcp") diff --git a/x-pack/elastic-agent/CHANGELOG.asciidoc b/x-pack/elastic-agent/CHANGELOG.asciidoc index f4ad19cc290e..068a2134980e 100644 --- a/x-pack/elastic-agent/CHANGELOG.asciidoc +++ b/x-pack/elastic-agent/CHANGELOG.asciidoc @@ -102,3 +102,4 @@ - Improved version CLI {pull}20359[20359] - Enroll CLI now restarts running daemon {pull}20359[20359] - Add restart CLI cmd {pull}20359[20359] +- Add new `synthetics/*` inputs to run Heartbeat {pull}20387[20387] diff --git a/x-pack/elastic-agent/magefile.go b/x-pack/elastic-agent/magefile.go index 638537f3d7c9..2d634d6fce14 100644 --- a/x-pack/elastic-agent/magefile.go +++ b/x-pack/elastic-agent/magefile.go @@ -523,7 +523,7 @@ func packageAgent(requiredPackages []string, packagingFn func()) { defer os.RemoveAll(dropPath) defer os.Unsetenv(agentDropPath) - packedBeats := []string{"filebeat", "metricbeat"} + packedBeats := []string{"filebeat", "heartbeat", "metricbeat"} for _, b := range packedBeats { pwd, err := filepath.Abs(filepath.Join("..", b)) diff --git a/x-pack/elastic-agent/pkg/agent/program/program_test.go b/x-pack/elastic-agent/pkg/agent/program/program_test.go index c9c4f9eb9d04..8c46e15deec9 100644 --- a/x-pack/elastic-agent/pkg/agent/program/program_test.go +++ b/x-pack/elastic-agent/pkg/agent/program/program_test.go @@ -385,8 +385,8 @@ func TestConfiguration(t *testing.T) { err bool }{ "single_config": { - programs: []string{"filebeat", "metricbeat", "endpoint"}, - expected: 3, + programs: []string{"filebeat", "heartbeat", "metricbeat", "endpoint"}, + expected: 4, }, "constraints_config": { programs: []string{"filebeat"}, @@ -400,10 +400,10 @@ func TestConfiguration(t *testing.T) { // programs: []string{"journalbeat"}, // expected: 1, // }, - // "monitor_config": { - // programs: []string{"heartbeat"}, - // expected: 1, - // }, + "synthetics_config": { + programs: []string{"heartbeat"}, + expected: 1, + }, "enabled_true": { programs: []string{"filebeat"}, expected: 1, diff --git a/x-pack/elastic-agent/pkg/agent/program/supported.go b/x-pack/elastic-agent/pkg/agent/program/supported.go index b72add5682df..3fd53db7b556 100644 --- a/x-pack/elastic-agent/pkg/agent/program/supported.go +++ b/x-pack/elastic-agent/pkg/agent/program/supported.go @@ -19,8 +19,9 @@ func init() { // Packed Files // spec/endpoint.yml // spec/filebeat.yml + // spec/heartbeat.yml // spec/metricbeat.yml - unpacked := packer.MustUnpack("eJy8mN9zozqyx9/vnzGv99ZdEOPsslXnwSbLLztkTBJJ6A1JNmBLmB1jbNja/31LgDE4yZwze6rmIZWYyFJ3q/vbn+ZfX47Fhv1lk/PikOXl/9dSfPn7FyrtkrwekhDN9swxC5qvkzcAdxz7BXf3ywjo++dsIagMzxSIE7f0hqBAZ1Jom3WRsjwsiLR3/PGQkNseJXEgsPJAsJwUEXh78B4j4/kxWUYgFREotzGaNdyxj/TxsFy9LMTGgTsMSEGdtwcrmyeetThHODw8Z/NsvC+72Zb161ImefOcHBLPmierl3nGJaxjRGZe/4w7oiTI1JWNT818yRyz4bbaL9AidDk+J4fSc+BXgoItkeJIXg9L9T3PXaTcSR48y//Y/xevW+fYNTGeervnpWf5w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po/2oaK5rFbE7U8fWyI+E013RUGTuyYv+dYGV7jsWnRb9nnC67Y/DiqM7keWYGVECpZocG+L1qO8J8nVS+VyBCneEjFri2xQWq8yC4LCKUdAV2qxkRjianbXJ0RKB0exqNM/RS+I2Wv9ErIYMKZJ+WiO9n9Wo5qDiTfDqQQEOBWFT1Au5KpkhagVWi0wU1Joo4nUVCvPbDOHjwh8KrhhN9gRvrw2wIRFP6ezqY902THGKZTMr6YiLvmGuX0YA1gyYfRFRMNlEwDwReclb4ShODMCK22ZCsrAnEb0A7PKtI+WVyh2K+lmjZNIs3hPzsLw9C672dHbqCXu8mxN+IDY+IfhNs8bAPlL7EyHVnn07cwAS732flNSYDomkWDuBYO6qaVK9SKmausg7gdfnajs0GAm2FK/ubDXCEoNLzozVeC50FUKDOxqJup/yo7/DlCDSgNovFmvvSDE2eM6dZMMkzAhOemH/ARFum1P69W0BOhwzlvvvkr1fSxD/oBCFnzfr7wlT11c1vp4/mqtv7bDk/xfpMX8fo66hqjMeD1t/OMttRdMpQroYC51O+I/W3oiuwm+OLuJGzPUkBnATYb+K7uebXY70OAGgNrKryZWrzYG4NejfI+gG7/2MgLybMf9a0dl8r4ez118lXO8E90+JGzriFd/F+lFvXciPhkd93/wZoTTu2Z/Pqd8IVn3VrFR9fkbeRv60g9mmRv8QmWsJXCuuq4bAfZ/M/fv//hMAAP//vkWPgA==") SupportedMap = make(map[string]Spec) for f, v := range unpacked { diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/endpoint_basic-endpoint-security.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/endpoint_basic-endpoint-security.yml index 31cdc7282619..f0505a5f3237 100644 --- a/x-pack/elastic-agent/pkg/agent/program/testdata/endpoint_basic-endpoint-security.yml +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/endpoint_basic-endpoint-security.yml @@ -21,6 +21,7 @@ output: inputs: - id: endpoint-id + type: endpoint name: endpoint-1 enabled: true package: diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/endpoint_basic.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/endpoint_basic.yml index 9dff3f786910..832dc4704de9 100644 --- a/x-pack/elastic-agent/pkg/agent/program/testdata/endpoint_basic.yml +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/endpoint_basic.yml @@ -20,6 +20,7 @@ outputs: inputs: - id: endpoint-id + type: endpoint name: endpoint-1 enabled: true package: diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/endpoint_no_fleet.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/endpoint_no_fleet.yml index 8ac4e997c074..de7ccd2a11cd 100644 --- a/x-pack/elastic-agent/pkg/agent/program/testdata/endpoint_no_fleet.yml +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/endpoint_no_fleet.yml @@ -11,6 +11,7 @@ outputs: inputs: - id: endpoint-id + type: endpoint name: endpoint-1 enabled: true package: diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/endpoint_unknown_output.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/endpoint_unknown_output.yml index dbd492e4e259..48e362849bed 100644 --- a/x-pack/elastic-agent/pkg/agent/program/testdata/endpoint_unknown_output.yml +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/endpoint_unknown_output.yml @@ -16,6 +16,7 @@ outputs: inputs: - id: endpoint-id + type: endpoint name: endpoint-1 enabled: true package: diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/monitor_config-heartbeat.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/monitor_config-heartbeat.yml deleted file mode 100644 index 59feb7568854..000000000000 --- a/x-pack/elastic-agent/pkg/agent/program/testdata/monitor_config-heartbeat.yml +++ /dev/null @@ -1,18 +0,0 @@ -heartbeat: - monitors: - - type: icmp - name: icmp - schedule: "*/5 * * * * * *" - hosts: ["localhost"] - ipv4: true - ipv6: true - mode: any - timeout: 16s - wait: 1s - - type: tcp - name: tcp -output: - elasticsearch: - hosts: [127.0.0.1:9200, 127.0.0.1:9300] - username: elastic - password: changeme diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/monitor_config.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/monitor_config.yml deleted file mode 100644 index 97e5d9d8980a..000000000000 --- a/x-pack/elastic-agent/pkg/agent/program/testdata/monitor_config.yml +++ /dev/null @@ -1,23 +0,0 @@ -streams: -- type: monitor/icmp - name: icmp - schedule: '*/5 * * * * * *' - hosts: ["localhost"] - ipv4: true - ipv6: true - mode: any - timeout: 16s - wait: 1s -- type: log/file -- type: monitor/tcp - name: tcp -management: - host: "localhost" -config: - reload: 123 -outputs: - default: - type: elasticsearch - hosts: [127.0.0.1:9200, 127.0.0.1:9300] - username: elastic - password: changeme diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-endpoint-security.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-endpoint-security.yml index 4b58a1466ae2..42d78b09ca53 100644 --- a/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-endpoint-security.yml +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-endpoint-security.yml @@ -21,6 +21,7 @@ output: inputs: - id: endpoint-id + type: endpoint name: endpoint-1 enabled: true package: diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-heartbeat.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-heartbeat.yml new file mode 100644 index 000000000000..f6be90698f65 --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-heartbeat.yml @@ -0,0 +1,18 @@ +inputs: +- type: synthetics/http + id: unique-http-id + name: my-http + schedule: '*/5 * * * * * *' + host: "http://localhost:80/service/status" + timeout: 16s + wait: 1s + dataset.namespace: default +output: + elasticsearch: + hosts: + - 127.0.0.1:9200 + - 127.0.0.1:9300 + username: elastic + password: changeme + api_key: TiNAGG4BaaMdaH1tRfuU:KnR6yE41RrSowb0kQ0HWoA + ca_sha256: 7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y= diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/single_config.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/single_config.yml index be0d2abdf02f..01d511004082 100644 --- a/x-pack/elastic-agent/pkg/agent/program/testdata/single_config.yml +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/single_config.yml @@ -67,7 +67,15 @@ inputs: metricset: info hosts: ["http://apache.remote"] hosts: ["http://apache.local"] +- type: synthetics/http + id: unique-http-id + name: my-http + schedule: '*/5 * * * * * *' + host: "http://localhost:80/service/status" + timeout: 16s + wait: 1s - id: endpoint-id + type: endpoint name: endpoint-1 enabled: true package: diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/synthetics_config-heartbeat.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/synthetics_config-heartbeat.yml new file mode 100644 index 000000000000..564d01afc15d --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/synthetics_config-heartbeat.yml @@ -0,0 +1,33 @@ +inputs: +- type: synthetics/http + id: unique-http-id + name: my-http + schedule: '*/5 * * * * * *' + host: "http://localhost:80/service/status" + timeout: 16s + wait: 1s + dataset.namespace: default +- type: synthetics/tcp + id: unique-tcp-id + name: my-tcp + schedule: '*/5 * * * * * *' + host: "localhost:777" + timeout: 16s + wait: 1s + dataset.namespace: default +- type: synthetics/icmp + id: unique-icmp-id + name: my-icmp + schedule: '@every 5s' + host: "localhost" + ipv4: true + ipv6: true + mode: any + timeout: 16s + wait: 1s + dataset.namespace: default +output: + elasticsearch: + hosts: [127.0.0.1:9200, 127.0.0.1:9300] + username: elastic + password: changeme diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/synthetics_config.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/synthetics_config.yml new file mode 100644 index 000000000000..74aa9916a658 --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/synthetics_config.yml @@ -0,0 +1,31 @@ +inputs: +- type: synthetics/http + id: unique-http-id + name: my-http + schedule: '*/5 * * * * * *' + host: "http://localhost:80/service/status" + timeout: 16s + wait: 1s +- type: synthetics/tcp + id: unique-tcp-id + name: my-tcp + schedule: '*/5 * * * * * *' + host: "localhost:777" + timeout: 16s + wait: 1s +- type: synthetics/icmp + id: unique-icmp-id + name: my-icmp + schedule: '@every 5s' + host: "localhost" + ipv4: true + ipv6: true + mode: any + timeout: 16s + wait: 1s +outputs: + default: + type: elasticsearch + hosts: [127.0.0.1:9200, 127.0.0.1:9300] + username: elastic + password: changeme diff --git a/x-pack/elastic-agent/pkg/agent/transpiler/rules.go b/x-pack/elastic-agent/pkg/agent/transpiler/rules.go index cf18593c408a..5ad790eb31e6 100644 --- a/x-pack/elastic-agent/pkg/agent/transpiler/rules.go +++ b/x-pack/elastic-agent/pkg/agent/transpiler/rules.go @@ -1199,7 +1199,7 @@ func (r *FilterValuesWithRegexpRule) Apply(ast *AST) error { newAST, ok := Lookup(newRoot, r.Key) if !ok { - newNodes = append(newNodes, item) + // doesn't have key so its filtered out continue } @@ -1210,7 +1210,7 @@ func (r *FilterValuesWithRegexpRule) Apply(ast *AST) error { } if n.name != r.Key { - newNodes = append(newNodes, item) + // doesn't match so its filtered out continue } diff --git a/x-pack/elastic-agent/spec/heartbeat.yml b/x-pack/elastic-agent/spec/heartbeat.yml new file mode 100644 index 000000000000..b13ea46059bb --- /dev/null +++ b/x-pack/elastic-agent/spec/heartbeat.yml @@ -0,0 +1,22 @@ +name: Heartbeat +cmd: heartbeat +args: ["-E", "setup.ilm.enabled=false", "-E", "setup.template.enabled=false", "-E", "management.mode=x-pack-fleet", "-E", "management.enabled=true", "-E", "logging.level=debug"] +artifact: beats/heartbeat +rules: + - fix_stream: {} + - filter_values_with_regexp: + key: type + re: ^synthetics/.+ + selector: inputs + - filter_values: + selector: inputs + key: enabled + values: + - true + - filter: + selectors: + - inputs + - output + - keystore +when: HasItems(%{[inputs]}) && HasNamespace('output', 'elasticsearch', 'redis', + 'kafka', 'logstash') diff --git a/x-pack/elastic-agent/spec/heartbeat.yml.disabled b/x-pack/elastic-agent/spec/heartbeat.yml.disabled deleted file mode 100644 index 14aaa1d3da47..000000000000 --- a/x-pack/elastic-agent/spec/heartbeat.yml.disabled +++ /dev/null @@ -1,27 +0,0 @@ -name: Heartbeat -cmd: heartbeat -rules: -- filter_values_with_regexp: - key: type - re: ^monitor/.+ - selector: streams -- map: - path: streams - rules: - - translate_with_regexp: - path: type - re: ^monitor/(?P.+) - with: $type -- copy: - from: streams - to: heartbeat -- rename: - from: heartbeat.streams - to: monitors -- filter: - selectors: - - heartbeat - - output - - keystore -when: HasItems(%{[heartbeat.monitors]}) && HasNamespace('output', 'elasticsearch', - 'redis', 'kafka', 'logstash')