# Couchbase module throws json parse exception on basicStats.opsPerSec

**URL:** <https://discuss.elastic.co/t/couchbase-module-throws-json-parse-exception-on-basicstats-opspersec/235455>\
**Category:** Beats\
**Tags:** beats-module\
**Created:** [June 3, 2020, 4:08am UTC](https://discuss.elastic.co/t/couchbase-module-throws-json-parse-exception-on-basicstats-opspersec/235455 "2020-06-03T04:08:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![amrishraje](https://avatars.discourse-cdn.com/v4/letter/a/9de053/32.png) [@amrishraje](https://discuss.elastic.co/u/amrishraje)\
**Post date:** [June 3, 2020, 4:08am UTC](https://discuss.elastic.co/t/couchbase-module-throws-json-parse-exception-on-basicstats-opspersec/235455/1 "2020-06-03T04:08:44Z")

</div>

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](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.

---

<div class="post-metadata">

**Author:** ![kvch](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kvch/32/72058_2.png) [@kvch](https://discuss.elastic.co/u/kvch)\
**Post date:** [June 3, 2020, 4:40pm UTC](https://discuss.elastic.co/t/couchbase-module-throws-json-parse-exception-on-basicstats-opspersec/235455/2 "2020-06-03T16:40:09Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 1, 2020, 4:40pm UTC](https://discuss.elastic.co/t/couchbase-module-throws-json-parse-exception-on-basicstats-opspersec/235455/3 "2020-07-01T16:40:22Z")

</div>

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