-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Kibana Input Plugin: added compatibility for all 6.X.X versions #6923
Conversation
@danielnelson can we get some eyes on this PR ? |
With these changes the plugin seems to work up to version 7.5 (there are no changes to these metrics even in master branch: https://github.com/elastic/kibana/blob/master/src/legacy/server/status/lib/metrics.js) @vikkyomkar The change on kibana that needs the fix happened on version 6.4, not 6.5, so it would be better to change the PR to reflect that. Also, there is a metric name change, but the underlying metric seems to be the same: I don't know if it is a good practice to change the metric name on telegraf. OTOH I think the metric name in the updated kibana makes more sense. @danielnelson what do you recommend? |
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.
I think we should either record this only as the older name heap_max_bytes
or as both heap_total_bytes
and heap_max_bytes
.
plugins/inputs/kibana/kibana.go
Outdated
fields["response_time_avg_ms"] = kibanaStatus.Metrics.ResponseTimes.AvgInMillis | ||
fields["response_time_max_ms"] = kibanaStatus.Metrics.ResponseTimes.MaxInMillis | ||
fields["requests_per_sec"] = float64(kibanaStatus.Metrics.Requests.Total) / float64(kibanaStatus.Metrics.CollectionIntervalInMilles) * 1000 | ||
|
||
Version, err := strconv.ParseFloat(strings.Join(strings.Split(kibanaStatus.Version.Number, ".")[:2], "."), 64) |
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.
This line could panic with unexpected version info, in particular when indexing [:2]
. Check the length of the split item to ensure it is long enough. To match Go naming convention use a lowercase variable version :=
.
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.
@danielnelson code is updated to handle any panic situation
|
||
if Version >= 6.5 { | ||
fields["uptime_ms"] = kibanaStatus.Metrics.Process.UptimeInMillis | ||
fields["heap_total_bytes"] = kibanaStatus.Metrics.Process.Memory.Heap.TotalInBytes |
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.
For backwards compatibility, either record this only as only heap_max_bytes
or as both heap_total_bytes
and heap_max_bytes
. Make sure to add a comment so we can remember why we did this.
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.
code updated along with the comments as per the suggestions
plugins/inputs/kibana/README.md
Outdated
``` | ||
Kibana Version < 6.5 | ||
kibana,host=myhost,name=my-kibana,source=localhost:5601,status=green,version=6.3.2 concurrent_connections=0i,heap_max_bytes=136478720i,heap_used_bytes=119231088i,requests_per_sec=1,response_time_avg_ms=59i,response_time_max_ms=300i,status_code=1i,uptime_ms=2187428019i 1534864502000000000 | ||
|
||
kibana,host=myhost,name=my-kibana,source=localhost:5601,version=6.3.2 concurrent_connections=0i,heap_max_bytes=136478720i,heap_used_bytes=119231088i,response_time_avg_ms=0i,response_time_max_ms=0i,status="green",status_code=1i,uptime_ms=2187428019i 1534864502000000000 | ||
Kibana Version > 6.5 | ||
kibana,host=myhost,name=my-kibana,source=localhost:5601,status=green,version=6.5.4 concurrent_connections=8i,heap_total_bytes=447778816i,heap_used_bytes=380603352i,requests_per_sec=1,response_time_avg_ms=57.6,response_time_max_ms=220i,status_code=1i,uptime_ms=6717489805i 1534864502000000000 | ||
``` |
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.
Only show the >6.5 version
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.
Plugin output is made generic for all the versions
(cherry picked from commit bc3429e)
closes #6894
closes #5744
Required for all PRs: