Couchbase module throws json parse exception on basicStats.opsPerSec

I am trying to use Metricbeats couchbase module. I keep getting the below error

Error: %!(EXTRA *json.UnmarshalTypeError=json: cannot unmarshal number 790.2097902097902 into Go struct field BucketBasicStats.opsPerSec of type int64)

I did some research and I see that there is an issue in the below code
[https://github.com/elastic/beats/blob/master/metricbeat/module/couchbase/bucket/data.go]

The metricbeat couchbase module has defined BucketBasicStats Struct as:

type BucketBasicStats struct {
QuotaPercentUsed float64 json:"quotaPercentUsed"
OpsPerSec int64 json:"opsPerSec"
DiskFetches int64 json:"diskFetches"
ItemCount int64 json:"itemCount"
DiskUsed int64 json:"diskUsed"
DataUsed int64 json:"dataUsed"
MemUsed int64 json:"memUsed"
}

It is making an assumption that OpsPerSec is an int64 where as it really is a float. Couchbase API pools/default/buckets always returns this field as a float (unless it is 0 !!). Looking at their APIs, they haven't really indicated that this field is an int. This should be a simple enough fix to change the field from int to float in the above module.

Could you please open an issue on GH referencing this post? Also, if you feel like it we are happy to review your PR if you provide a fix.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.