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] Fix fields generation #21874

Merged
merged 15 commits into from
Dec 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions heartbeat/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,7 @@ TEST_ENVIRONMENT?=true

# Collects all dependencies and then calls update
.PHONY: collect
collect: imports kibana

# Generate imports for all monitors
.PHONY: imports
imports:
@mkdir -p include
mage imports
collect: kibana

# Collects all module dashboards
.PHONY: kibana
Expand Down
233 changes: 233 additions & 0 deletions heartbeat/_meta/fields.common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,236 @@
type: long
description: Duration in microseconds

- key: http
title: "HTTP monitor"
description:
fields:
- name: http
type: group
description: >
HTTP related fields.
fields:
- name: url
type: alias
path: url.full
migration: true
description: >
Service url used by monitor.
- name: response
type: group
fields:
- name: body
type: group
fields:
- name: hash
type: keyword
description: >
Hash of the full response body. Can be used to group responses with identical hashes.
- name: redirects
type: keyword
description: >
List of redirects followed to arrive at final content. Last item on the list is the URL for which
body content is shown.
- name: headers.*
type: object
enabled: false
description: >
The canonical headers of the monitored HTTP response.
- name: rtt
type: group
description: >
HTTP layer round trip times.
fields:
- name: validate
type: group
description: |
Duration between first byte of HTTP request being written and
response being processed by validator. Duration based on already
available network connection.

Note: if validator is not reading body or only a prefix, this
number does not fully represent the total time needed
to read the body.
fields:
- name: us
type: long
description: Duration in microseconds

- name: validate_body
type: group
description: |
Duration of validator required to read and validate the response
body.

Note: if validator is not reading body or only a prefix, this
number does not fully represent the total time needed
to read the body.
fields:
- name: us
type: long
description: Duration in microseconds

- name: write_request
type: group
description:
Duration of sending the complete HTTP request. Duration based on
already available network connection.
fields:
- name: us
type: long
description: Duration in microseconds

- name: response_header
type: group
description:
Time required between sending the start of sending the HTTP
request and first byte from HTTP response being read. Duration
based on already available network connection.
fields:
- name: us
type: long
description: Duration in microseconds

- name: content.us
type: long
description: Time required to retrieved the content in micro seconds.

- name: total
type: group
description: |
Duration required to process the HTTP transaction. Starts with
the initial TCP connection attempt. Ends with after validator
did check the response.

Note: if validator is not reading body or only a prefix, this
number does not fully represent the total time needed.
fields:
- name: us
type: long
description: Duration in microseconds
- key: tcp
title: "TCP layer"
description:
fields:
- name: tcp
type: group
description: >
TCP network layer related fields.
fields:
- name: port
type: alias
path: url.port
migration: true
description: >
Service port number.

- name: rtt
type: group
description: >
TCP layer round trip times.
fields:
- name: connect
type: group
description: >
Duration required to establish a TCP connection based on already
available IP address.
fields:
- name: us
type: long
description: Duration in microseconds

- name: validate
type: group
description: >
Duration of validation step based on existing TCP connection.
fields:
- name: us
type: long
description: Duration in microseconds
- key: socks5
title: "SOCKS5 proxy"
description:
fields:
- name: socks5
type: group
description: >
SOCKS5 proxy related fields:
fields:
- name: rtt
type: group
description: >
TLS layer round trip times.
fields:
- name: connect
type: group
description: >
Time required to establish a connection via SOCKS5 to endpoint
based on available connection to SOCKS5 proxy.
fields:
- name: us
type: long
description: Duration in microseconds

- key: tls
title: "TLS encryption layer"
description:
fields:
- name: tls
type: group
description: >
TLS layer related fields.
fields:
- name: certificate_not_valid_before
type: date
deprecated: 7.8.0
description: Deprecated in favor of `tls.server.x509.not_before`. Earliest time at which the connection's certificates are valid.
- name: certificate_not_valid_after
deprecated: 7.8.0
type: date
description: Deprecated in favor of `tls.server.x509.not_after`. Latest time at which the connection's certificates are valid.
- name: rtt
type: group
description: >
TLS layer round trip times.
fields:
- name: handshake
type: group
description: >
Time required to finish TLS handshake based on already available network
connection.
fields:
- name: us
type: long
description: Duration in microseconds
- name: server
type: group
description: Detailed x509 certificate metadata
fields:
- name: version_number
type: keyword
ignore_above: 1024
description: Version of x509 format.
example: 3
default_field: false

- key: icmp
title: "ICMP"
description:
fields:
- name: icmp
type: group
description: >
IP ping fields.
fields:
- name: requests
type: integer
description: >
Number if ICMP EchoRequests send.

- name: rtt
type: group
description: ICMP Echo Request and Reply round trip time
fields:
- name: us
type: long
description: Duration in microseconds
7 changes: 5 additions & 2 deletions heartbeat/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,15 @@ import (
// include all heartbeat specific autodiscovery builders
_ "github.com/elastic/beats/v7/heartbeat/autodiscover/builder/hints"

// register default heartbeat monitors
_ "github.com/elastic/beats/v7/heartbeat/monitors/defaults"
Copy link
Member

Choose a reason for hiding this comment

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

This package looks broken. In the OSS magefile.go there is a generator for it. It looks like it's supposed to be creating imports for each monitor. I'd remove the package and the generation code if it's unused.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The weird thing is this used to work, and somehow broke at some point. Now, when I run mage update these lines just get deleted. That said, probably easier to just remove it and make it manual since we don't add monitor types frequently.

cmd "github.com/elastic/beats/v7/libbeat/cmd"
"github.com/elastic/beats/v7/libbeat/cmd/instance"
"github.com/elastic/beats/v7/libbeat/common"
"github.com/elastic/beats/v7/libbeat/publisher/processing"

// Import packages that need to register themselves.
_ "github.com/elastic/beats/v7/heartbeat/monitors/active/http"
_ "github.com/elastic/beats/v7/heartbeat/monitors/active/icmp"
_ "github.com/elastic/beats/v7/heartbeat/monitors/active/tcp"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion heartbeat/include/fields.go

Large diffs are not rendered by default.

12 changes: 1 addition & 11 deletions heartbeat/magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,7 @@ func Fields() error {

// Update updates the generated files (aka make update).
func Update() {
mg.SerialDeps(Fields, Config, Imports)
}

// Imports generates an include/list.go file containing
// a import statement for each module and dataset.
func Imports() error {
options := devtools.DefaultIncludeListOptions()
options.ModuleDirs = []string{"monitors"}
options.Outfile = "monitors/defaults/default.go"
options.Pkg = "defaults"
return devtools.GenerateIncludeListGo(options)
mg.SerialDeps(Fields, Config)
}

// Config generates both the short/reference/docker configs.
Expand Down
67 changes: 0 additions & 67 deletions heartbeat/monitors/active/dialchain/_meta/fields.yml

This file was deleted.

Loading