-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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 event format #4091
Heartbeat event format #4091
Conversation
|
||
func UDPDialer(name string, to time.Duration) NetDialer { | ||
return NetDialer{name, transport.NetDialer(to)} | ||
func (c *DialerChain) TestBuild() error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported method DialerChain.TestBuild should have comment or be unexported
f1b1ea0
to
9f2f09d
Compare
heartbeat/monitors/util.go
Outdated
@@ -53,16 +52,16 @@ func (s IPSettings) Network() string { | |||
return "" | |||
} | |||
|
|||
func MakeSimpleJob(name, typ string, f func() (common.MapStr, error)) Job { | |||
return MakeJob(name, typ, func() (common.MapStr, []TaskRunner, error) { | |||
func MakeSimpleJob(jobName string, f func() (common.MapStr, error)) Job { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported function MakeSimpleJob should have comment or be unexported
heartbeat/monitors/util.go
Outdated
func MakeJob(name, typ string, f func() (common.MapStr, []TaskRunner, error)) Job { | ||
return &funcJob{name, typ, funcTask{func() (common.MapStr, []TaskRunner, error) { | ||
return annotated(time.Now(), typ, f).Run() | ||
func MakeJob(jobName string, f func() (common.MapStr, []TaskRunner, error)) Job { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported function MakeJob should have comment or be unexported
heartbeat/monitors/util.go
Outdated
type IPSettings struct { | ||
IPv4 bool `config:"ipv4"` | ||
IPv6 bool `config:"ipv6"` | ||
Mode PingMode `config:"mode"` | ||
} | ||
|
||
type JobSettings struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported type JobSettings should have comment or be unexported
heartbeat/monitors/util.go
Outdated
Fields common.MapStr | ||
} | ||
|
||
type HostJobSettings struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported type HostJobSettings should have comment or be unexported
heartbeat/monitors/util.go
Outdated
@@ -342,3 +444,42 @@ func filterIPs(ips []net.IP, filt func(net.IP) bool) []net.IP { | |||
} | |||
return out | |||
} | |||
|
|||
func MakeJobSetting(name string) JobSettings { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported function MakeJobSetting should have comment or be unexported
heartbeat/monitors/util.go
Outdated
return JobSettings{Name: name} | ||
} | ||
|
||
func (s JobSettings) WithFields(m common.MapStr) JobSettings { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported method JobSettings.WithFields should have comment or be unexported
heartbeat/monitors/util.go
Outdated
return s | ||
} | ||
|
||
func (s *JobSettings) AddFields(m common.MapStr) { addFields(&s.Fields, m) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported method JobSettings.AddFields should have comment or be unexported
heartbeat/monitors/util.go
Outdated
|
||
func (s *JobSettings) AddFields(m common.MapStr) { addFields(&s.Fields, m) } | ||
|
||
func MakeHostJobSettings(name, host string, ip IPSettings) HostJobSettings { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported function MakeHostJobSettings should have comment or be unexported
heartbeat/monitors/util.go
Outdated
return HostJobSettings{Name: name, Host: host, IP: ip} | ||
} | ||
|
||
func (s HostJobSettings) WithFields(m common.MapStr) HostJobSettings { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported method HostJobSettings.WithFields should have comment or be unexported
heartbeat/monitors/util.go
Outdated
return s | ||
} | ||
|
||
func (s *HostJobSettings) AddFields(m common.MapStr) { addFields(&s.Fields, m) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported method HostJobSettings.AddFields should have comment or be unexported
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice cleanup. It makes the dialer part much easier to follow. As this is a major change on how it works I'm happy to merge it after the minor comments are adressed and then to further iterations from there.
|
||
- name: validate_body | ||
type: group | ||
description: | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Normally we use a >
. I assume |
also works?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, oversight from my side. in YAML one can use >
, >-
or |
.
>
: folded-style. Replace newlines with space. Multiple blank lines are replaced with newline (or space in some implementations)
|
: literal block. Keeps newlines and blank lines.
I wanted to enforce the newline (or better blank line?) before "Note:" in the hopes of the asciidoc putting the note in a separate new line. That's why I used |
.
If I remember correctly >-
replaces a blank line (\n\n
) by one newline (\n
).
@@ -9,6 +9,7 @@ import ( | |||
"net/http" | |||
"strconv" | |||
"strings" | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
empty line too much?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interesting. so gimport woes here? Will fix.
@@ -41,25 +42,25 @@ func newHTTPMonitorHostJob( | |||
return nil, err | |||
} | |||
|
|||
hostname, port, err := splitHostnamePort(request) | |||
hostname, _, err := splitHostnamePort(request) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
port is excluded because it is already in the tcp layer, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Port is missing here. This constructor is used when a proxy is configured + name lookup happens by proxy itself. I did undo the tcp dialer to report the port number due to potential use of proxies.
heartbeat/monitors/util.go
Outdated
case 1: | ||
return makeTask(cont[0]) | ||
case | ||
1: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is the 1:
intentional on a new line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ups.
heartbeat/monitors/util.go
Outdated
return MakeCont(func() (common.MapStr, []TaskRunner, error) { | ||
fmt.Println("run task") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
leftover?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
heartbeat/monitors/util.go
Outdated
event, cont, err := fn() | ||
fmt.Println("task returns: ", event, cont, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
left over?
heartbeat/monitors/util.go
Outdated
if err != nil { | ||
if event == nil { | ||
event = common.MapStr{} | ||
} | ||
fmt.Println("set error: ", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
left over?
heartbeat/monitors/util.go
Outdated
event["error"] = look.Reason(err) | ||
} | ||
|
||
if event != nil { | ||
event.Update(common.MapStr{ | ||
status := look.Status(err) | ||
fmt.Println("set status: ", status) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
left over?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you rebase and squash?
c0ead6e
to
2b7cff7
Compare
See PR elastic#4091 for detailed list of event format changes and sample events. - export transport.DialWith - update heartbeat look: - add look.Status - add some missing godoc - rewrite heartbeat dialchain package - simplify package - have connection layers add standardized connection data to the final event - add some more helpers - add some godocs - update event format. See PR elastic#4091 - add more detailed duration measure to HTTP module - update job settings - introduce explicit structs for job settings - job settings can contain static monitor fields to be added to every event - helpers can add more static monitor fields to settings - update fields.yml structure - update kibana dashboard
2b7cff7
to
6b4ee71
Compare
PR addresses #3406 and #3838.
Additional work on extracting meta-data from connection layers should be done in follow-up PR.
Work done:
Event format changes:
type
fields with default 'monitor' untiltype
is not required anymoreNew fields:
type
: always set to"monitor"
. Can be removed when not required by libbeat anymoremonitor.type
: the monitor type, e.g. "tcp", "icmp", "http".http.rtt.validate
: Duration between first byte of HTTP request being written and response being processed by validator. Duration based on already available network connection.http.rtt.validate_body
: Duration of validator required to read and validate the responsehttp.rtt.write_request
: Duration of writing the complete HTTP request. Duration based on already available network connection.Sample Events:
ICMP Event:
ICMP event for unknown host:
TCP Event:
TCP + TLS Event:
HTTP Event with 404:
HTTPS event: