Skip to content

Commit

Permalink
Merge pull request #1154 from ruflin/mb-response-time
Browse files Browse the repository at this point in the history
Add round trip time to metricset request
  • Loading branch information
tsg committed Mar 17, 2016
2 parents b2a4481 + 78a0f5e commit 2bfc1c4
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 8 deletions.
5 changes: 5 additions & 0 deletions libbeat/scripts/generate_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ def fill_field_properties(field, defaults):
"type": "float",
"doc_values": "true"
}
elif field.get("type") == "integer":
properties[field["name"]] = {
"type": "integer",
"doc_values": "true"
}
elif field.get("type") == "group":
prop = fill_section_properties(field, defaults)

Expand Down
4 changes: 2 additions & 2 deletions metricbeat/docs/fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ required: True
The timestamp when the log line was read. The precision is in milliseconds. The timezone is UTC.


==== response_time
==== rtt

type: long

required: True

Event Reponse time in nano seconds
Event round trip time time in nano seconds


[[exported-fields-redis-info]]
Expand Down
5 changes: 3 additions & 2 deletions metricbeat/etc/fields.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@ common:
The timestamp when the log line was read. The precision is in
milliseconds. The timezone is UTC.
- name: response_time
- name: rtt
type: long
required: true
description: >
Event Reponse time in nano seconds
Event round trip time time in nano seconds
mysql-status:
type: group
description: >
Expand Down
5 changes: 3 additions & 2 deletions metricbeat/etc/fields_base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ common:
The timestamp when the log line was read. The precision is in
milliseconds. The timezone is UTC.
- name: response_time
- name: rtt
type: long
required: true
description: >
Event Reponse time in nano seconds
Event round trip time in nano seconds
50 changes: 49 additions & 1 deletion metricbeat/etc/metricbeat.template.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,56 @@
"@timestamp": {
"type": "date"
},
"mysql-status": {
"properties": {
"aborted": {
"properties": {
"Aborted_clients": {
"doc_values": "true",
"type": "integer"
},
"Aborted_connects": {
"doc_values": "true",
"type": "integer"
}
}
},
"bytes": {
"properties": {
"Bytes_received": {
"doc_values": "true",
"type": "integer"
},
"Bytes_sent": {
"doc_values": "true",
"type": "integer"
}
}
}
}
},
"redis-info": {
"properties": {
"clients": {
"properties": {
"blocked_clients": {
"doc_values": "true",
"type": "integer"
},
"client_biggest_input_buf": {
"doc_values": "true",
"type": "integer"
},
"client_longest_output_list": {
"doc_values": "true",
"type": "integer"
},
"connected_clients": {
"doc_values": "true",
"type": "integer"
}
}
},
"cpu": {
"properties": {
"used_cpu_sys": {
Expand All @@ -48,7 +96,7 @@
}
}
},
"response_time": {
"rtt": {
"doc_values": "true",
"type": "long"
}
Expand Down
6 changes: 6 additions & 0 deletions metricbeat/helper/metricset.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ func (m *MetricSet) Fetch() error {
go func(h string) {
defer m.Module.wg.Done()

starttime := time.Now()
event, err := m.MetricSeter.Fetch(m, h)
elapsed := time.Since(starttime)

if err != nil {
// Most of the time, event is nil in case of error (not required)
Expand All @@ -62,8 +64,12 @@ func (m *MetricSet) Fetch() error {
}
event["error"] = err
}

event = m.createEvent(event)

// Add round trip time
event["rtt"] = elapsed.Nanoseconds()

m.Module.Publish <- event

}(host)
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/helper/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func (m *Module) Run(period time.Duration, b *beat.Beat) {
ch <- struct{}{}
}

// TODO: A fetch event should take a maximum until the next ticker and
// TODO: A fetch event should take a maximum until the next ticker and - @ruflin,20160315
// be stopped before the next request is sent. If a fetch is not successful
// until the next it means it is a failure and a "error" event should be sent to es
fetch := func(set *MetricSet) {
Expand Down

0 comments on commit 2bfc1c4

Please sign in to comment.