Skip to content

Commit

Permalink
Accept decimal point when parsing kibana uptime (#7768)
Browse files Browse the repository at this point in the history
  • Loading branch information
krzysdabro authored Jul 1, 2020
1 parent 3fa4acf commit e81031d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions plugins/inputs/kibana/kibana.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type overallStatus struct {
}

type metrics struct {
UptimeInMillis int64 `json:"uptime_in_millis"`
UptimeInMillis float64 `json:"uptime_in_millis"`
ConcurrentConnections int64 `json:"concurrent_connections"`
CollectionIntervalInMilles int64 `json:"collection_interval_in_millis"`
ResponseTimes responseTimes `json:"response_times"`
Expand All @@ -57,9 +57,9 @@ type responseTimes struct {
}

type process struct {
Mem mem `json:"mem"`
Memory memory `json:"memory"`
UptimeInMillis int64 `json:"uptime_in_millis"`
Mem mem `json:"mem"`
Memory memory `json:"memory"`
UptimeInMillis float64 `json:"uptime_in_millis"`
}

type requests struct {
Expand Down Expand Up @@ -220,12 +220,12 @@ func (k *Kibana) gatherKibanaStatus(baseUrl string, acc telegraf.Accumulator) er
// Same value will be assigned to both the metrics [heap_max_bytes and heap_total_bytes ]
// Which keeps the code backward compatible
if versionNumber >= 6.4 {
fields["uptime_ms"] = kibanaStatus.Metrics.Process.UptimeInMillis
fields["uptime_ms"] = int64(kibanaStatus.Metrics.Process.UptimeInMillis)
fields["heap_max_bytes"] = kibanaStatus.Metrics.Process.Memory.Heap.TotalInBytes
fields["heap_total_bytes"] = kibanaStatus.Metrics.Process.Memory.Heap.TotalInBytes
fields["heap_used_bytes"] = kibanaStatus.Metrics.Process.Memory.Heap.UsedInBytes
} else {
fields["uptime_ms"] = kibanaStatus.Metrics.UptimeInMillis
fields["uptime_ms"] = int64(kibanaStatus.Metrics.UptimeInMillis)
fields["heap_max_bytes"] = kibanaStatus.Metrics.Process.Mem.HeapMaxInBytes
fields["heap_total_bytes"] = kibanaStatus.Metrics.Process.Mem.HeapMaxInBytes
fields["heap_used_bytes"] = kibanaStatus.Metrics.Process.Mem.HeapUsedInBytes
Expand Down
4 changes: 2 additions & 2 deletions plugins/inputs/kibana/testdata_test6_5.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ const kibanaStatusResponse6_5 = `
},
"event_loop_delay": 0.5314235687255859,
"pid": 6,
"uptime_in_millis": 2173595336
"uptime_in_millis": 2173595336.9999999998
},
"os": {
"load": {
Expand Down Expand Up @@ -219,7 +219,7 @@ var kibanaStatusExpected6_5 = map[string]interface{}{
"heap_total_bytes": int64(149954560),
"heap_max_bytes": int64(149954560),
"heap_used_bytes": int64(126274392),
"uptime_ms": int64(2173595336),
"uptime_ms": int64(2173595337),
"response_time_avg_ms": float64(12.5),
"response_time_max_ms": int64(123),
"concurrent_connections": int64(10),
Expand Down

0 comments on commit e81031d

Please sign in to comment.