# \[HTTP-Module\] json: cannot unmarshal object into Go value of type \[\]common.MapStr

**URL:** <https://discuss.elastic.co/t/http-module-json-cannot-unmarshal-object-into-go-value-of-type-common-mapstr/179757>\
**Category:** Beats\
**Tags:** metricbeat\
**Created:** [May 6, 2019, 11:48am UTC](https://discuss.elastic.co/t/http-module-json-cannot-unmarshal-object-into-go-value-of-type-common-mapstr/179757 "2019-05-06T11:48:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![PeterPain](https://avatars.discourse-cdn.com/v4/letter/p/c37758/32.png) [@PeterPain](https://discuss.elastic.co/u/PeterPain)\
**Post date:** [May 6, 2019, 11:48am UTC](https://discuss.elastic.co/t/http-module-json-cannot-unmarshal-object-into-go-value-of-type-common-mapstr/179757/1 "2019-05-06T11:48:13Z")

</div>

Hey there.  
Trying to pull data from a device which supports http protocol and has the option to query for  
different parameters in JSON-Format. Because the device puts the data in an array i have json.is\_array enabled.

Example Device URL:  
[http://localhost:80/json.do?\_P\_SUM3,\_SYSTIME](http://localhost:80/json.do?_P_SUM3,_SYSTIME)  
Output looks like this:  
`{ "_P_SUM3": [413.7307,"W"], "_SYSTIME": [1557142986.0000,"sec"]}`

Here are my http.configs:

```
- module: http
  metricsets:
    - json
  period: 10s
  hosts: ["localhost:80/json.do?_P_SUM3,_SYSTIME"]
  namespace: "Janitza_Monti2"
  path: ""
  #body: ""
  method: "GET"
  #username: "user"
  #password: "secret"
  #request.enabled: true
  #response.enabled: true
  json.is_array: true
  #dedot.enabled: false

```

Im getting this error message:

```
"error": {
      "message": "json: cannot unmarshal object into Go value of type []common.MapStr"
    },

```

thx for any help

---

<div class="post-metadata">

**Author:** ![martinr\_ubi](https://avatars.discourse-cdn.com/v4/letter/m/b5e925/32.png) [@martinr\_ubi](https://discuss.elastic.co/u/martinr_ubi)\
**Post date:** [May 6, 2019, 11:09pm UTC](https://discuss.elastic.co/t/http-module-json-cannot-unmarshal-object-into-go-value-of-type-common-mapstr/179757/2 "2019-05-06T23:09:18Z")

</div>

Hi,

I think you're misinterpreting the json.is\_array setting in that context.  
[ref](https://www.elastic.co/guide/en/beats/metricbeat/current/metricbeat-metricset-http-json.html#_json_is_array)

What you get:

```auto
{ "_P_SUM3": [413.7307,"W"], "_SYSTIME": [1557142986.0000,"sec"]}

```

Is not an array.  
This would be an array for json.is\_array:

```auto
[{"name": "David" }, { "name": "Robert"}]

```

You should remove json.is\_array.  
But I also recommend you read this:  
[https://www.elastic.co/guide/en/elasticsearch/reference/current/array.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/array.html)

Because as far as I'm concerned you will not be able to work with that document because the values are arrays of different types. In ES you can easily push an array for the value of a field like that:

```auto
{"field1": ["V","W"], "field2": [1,2] }

```

But they(values in the array) have to be of the same type, as above, where in your case they are arrays containing values of different types. I do recommend you make your own tests, maybe there is a combination of settings to make ES accept the first value of the array and then refuse the second one... but ignore the error on the bad type of the second one and still index the document? Not sure, I have never tried to index such array of differing types(because it doesn't work).

If that is indeed a dead end because of the types in the arrays the next step would depend on where it is easier for you to intervene in a custom manner... One option is to ship this into an ingest pipeline like this:  
[https://www.elastic.co/guide/en/elasticsearch/reference/7.0/script-processor.html](https://www.elastic.co/guide/en/elasticsearch/reference/7.0/script-processor.html)  
Where possibilities are infinite\*(TM). And fix the problem there.

Maybe someone else has a suggestion too.

---

<div class="post-metadata">

**Author:** ![PeterPain](https://avatars.discourse-cdn.com/v4/letter/p/c37758/32.png) [@PeterPain](https://discuss.elastic.co/u/PeterPain)\
**Post date:** [May 7, 2019, 7:19am UTC](https://discuss.elastic.co/t/http-module-json-cannot-unmarshal-object-into-go-value-of-type-common-mapstr/179757/3 "2019-05-07T07:19:22Z")

</div>

Hi Martin,  
thanks alot for the information. 👍  
Yeah i tried pushing the data without the `json.is_array`-setting.  
when using the same settings as above, i cant see any data output to elastic/kibana.  
I think because these types of array doesnt work, as you mentioned.  
I also tried pushing only one parameter but this doesn't work aswell.

I should get this array:  
`{ "_P_SUM3": [413.7307,"W"],`  
But this is what the http-module push to elastic.

```
{
  "_index": "metricbeat-7.0.0-2019.04.17-000001",
  "_type": "_doc",
  "_id": "i4cckWoB5TWw_WhLMMKM",
  "_version": 1,
  "_score": null,
  "_source": {
    "@timestamp": "2019-05-07T07:05:03.738Z",
    "ecs": {
      "version": "1.0.0"
    },
    "host": {
      "name": "hostname"
    },
    "agent": {
      "type": "metricbeat",
      "ephemeral_id": "2f0b9fd0-d781-40fc-9982-bb4bbe467d0e",
      "hostname": "hostname",
      "id": "de164d55-8cb5-4d01-ad5a-c68afe290c08",
      "version": "7.0.0"
    },
    "http": {
      "Janitza_Monti2": {
        "_P_SUM3=": [
          "var not found !",
          ""
        ]
      }
    },
    "event": {
      "dataset": "http.Janitza_Monti2",
      "module": "http",
      "duration": 25931200
    },
    "metricset": {
      "name": "json"
    },
    "service": {
      "address": "lokalhost:80",
      "type": "http"
    }
  },
  "fields": {
    "@timestamp": [
      "2019-05-07T07:05:03.738Z"
    ]
  },
  "sort": [
    1557212703738
  ]
}

```

Im not sure how the http module parse the data. As you can see the Parameter "\_P\_SUM3" says **""var not found !",** this is the message you get from the device when the parameter name is wrong. I was wondering where the **equal sign** in _\_P\_SUM3=_ in the doc comes from.  
I will give the script processor a try.  
If anyone else has a suggestion too, I would be very grateful.

---

<div class="post-metadata">

**Author:** ![PeterPain](https://avatars.discourse-cdn.com/v4/letter/p/c37758/32.png) [@PeterPain](https://discuss.elastic.co/u/PeterPain)\
**Post date:** [May 7, 2019, 8:43am UTC](https://discuss.elastic.co/t/http-module-json-cannot-unmarshal-object-into-go-value-of-type-common-mapstr/179757/4 "2019-05-07T08:43:07Z")

</div>

Hey Martin,

i was successful with using the script Processor. 🥳  
Thanks again for the help.

---

<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:** [June 4, 2019, 8:43am UTC](https://discuss.elastic.co/t/http-module-json-cannot-unmarshal-object-into-go-value-of-type-common-mapstr/179757/5 "2019-06-04T08:43:08Z")

</div>

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