# How to generate visualization for an item of an array in another array

**URL:** <https://discuss.elastic.co/t/how-to-generate-visualization-for-an-item-of-an-array-in-another-array/57472>\
**Category:** Kibana\
**Created:** [August 8, 2016, 12:22pm UTC](https://discuss.elastic.co/t/how-to-generate-visualization-for-an-item-of-an-array-in-another-array/57472 "2016-08-08T12:22:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ayotunde\_Salako](https://avatars.discourse-cdn.com/v4/letter/a/bbe5ce/32.png) [@Ayotunde\_Salako](https://discuss.elastic.co/u/Ayotunde_Salako)\
**Post date:** [August 8, 2016, 12:22pm UTC](https://discuss.elastic.co/t/how-to-generate-visualization-for-an-item-of-an-array-in-another-array/57472/1 "2016-08-08T12:22:19Z")

</div>

Hello,

I am new to Kibana and I have the data below in JSON format. I need to generate visualiztion for the fuel variable inside the attribute array.

`{ "_index": "positions", "_type": "position", "_id": "2727459", "_score": null, "_source": { "id": 2727459, "protocol": "noran", "deviceid": 10, "servertime": "2016-08-08T11:48:56.000Z", "devicetime": "2016-08-08T11:48:53.000Z", "fixtime": "2016-08-08T11:48:53.000Z", "valid": true, "latitude": 6.439499855041504, "longitude": 3.456439971923828, "altitude": 0, "speed": 0, "course": 237, "address": null, "attributes": "{\"alarm\":128,\"io1\":0,\"fuel\":40,\"ip\":\"197.210.225.60\"}", "@version": "1", "@timestamp": "2016-08-08T11:49:00.020Z" }, "fields": { "servertime": [1470656936000], "fixtime": [1470656933000], "@timestamp": [1470656940020], "devicetime": [1470656933000] }, "sort": [1470656936000] }`

I want to be able to create an histogram visualization of fuel level per hour. Kindly help.

---

<div class="post-metadata">

**Author:** ![LeeDr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leedr/32/9289_2.png) [@LeeDr](https://discuss.elastic.co/u/LeeDr)\
**Post date:** [August 8, 2016, 4:55pm UTC](https://discuss.elastic.co/t/how-to-generate-visualization-for-an-item-of-an-array-in-another-array/57472/2 "2016-08-08T16:55:22Z")

</div>

Hi,

Please see this documentation on how to add nested data;  
[https://www.elastic.co/guide/en/elasticsearch/guide/current/nested-mapping.html](https://www.elastic.co/guide/en/elasticsearch/guide/current/nested-mapping.html)

I made this very crude test below and I can use the values of the attributes in Kibana. Note that I'm sure this is NOT the correct mapping you would want. This mapping doesn't add a date field so it doesn't allow you to create charts over time. It's just to show how to do the nested attributes.

Lee

```auto
curl -XDELETE 'http://elastic:notsecure@localhost:9200/test101'

curl --basic -XPOST 'http://elastic:notsecure@localhost:9200/test101' -d '{
    "settings" : {
        "number_of_shards" : 1
    },
  "mappings": {
    "test": {
      "properties": {
        "attributes": {
          "type": "nested", 
          "properties": {
            "fuel": { "type": "string" },
            "ip": { "type": "string" },
            "alarm": { "type": "int" },
            "io1": { "type": "int" }
          }
        }
      }
    }
  }
}'

curl -XPUT 'http://elastic:notsecure@localhost:9200/test101/test/1' -d '{
	"protocol": "noran",
	"deviceid": 10,
	"servertime": "2016-08-08T11:48:56.000Z",
	"devicetime": "2016-08-08T11:48:53.000Z",
	"fixtime": "2016-08-08T11:48:53.000Z",
	"valid": true,
	"latitude": 6.439499855041504,
	"longitude": 3.456439971923828,
	"altitude": 0,
	"speed": 0,
	"course": 237,
	"address": null,
	"attributes": {"alarm":128,"io1":0,"fuel":40,"ip":"197.210.225.60"},
	"@version": "1",
	"@timestamp": "2016-08-08T11:49:00.020Z"
}'

curl -XPUT 'http://elastic:notsecure@localhost:9200/test101/test/2' -d '{
	"protocol": "noran",
	"deviceid": 10,
	"servertime": "2016-08-08T11:48:56.000Z",
	"devicetime": "2016-08-08T11:48:53.000Z",
	"fixtime": "2016-08-08T11:48:53.000Z",
	"valid": true,
	"latitude": 6.439499855041504,
	"longitude": 3.456439971923828,
	"altitude": 0,
	"speed": 0,
	"course": 237,
	"address": null,
	"attributes": {"alarm":121,"io1":0,"fuel":40,"ip":"197.210.225.60"},
	"@version": "1",
	"@timestamp": "2016-08-08T11:49:00.020Z"
}'

curl -XPUT 'http://elastic:notsecure@localhost:9200/test101/test/3' -d '{
	"protocol": "noran",
	"deviceid": 10,
	"servertime": "2016-08-08T11:48:56.000Z",
	"devicetime": "2016-08-08T11:48:53.000Z",
	"fixtime": "2016-08-08T11:48:53.000Z",
	"valid": true,
	"latitude": 6.439499855041504,
	"longitude": 3.456439971923828,
	"altitude": 0,
	"speed": 0,
	"course": 237,
	"address": null,
	"attributes": {"alarm":321,"io1":0,"fuel":40,"ip":"197.210.225.60"},
	"@version": "1",
	"@timestamp": "2016-08-08T11:49:00.020Z"
}'

```

 ![](https://us1.discourse-cdn.com/elastic/original/2X/8/8cd8dfb83c21430807e0c2278df0ed7f8d90efe9.png)

 ![](https://us1.discourse-cdn.com/elastic/original/2X/0/0555545021d7084fa22bf06a74f362302500ccab.png)

 ![](https://us1.discourse-cdn.com/elastic/original/2X/f/f8222fd411d43f148e01f8cc8b342c606b9c27bb.png)

---

<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 6, 2017, 1:41pm UTC](https://discuss.elastic.co/t/how-to-generate-visualization-for-an-item-of-an-array-in-another-array/57472/3 "2017-07-06T13:41:43Z")

</div>


