# Timebased events for JSON POSTs

**URL:** <https://discuss.elastic.co/t/timebased-events-for-json-posts/169929>\
**Category:** Kibana\
**Created:** [February 26, 2019, 2:13am UTC](https://discuss.elastic.co/t/timebased-events-for-json-posts/169929 "2019-02-26T02:13:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mkaka](https://avatars.discourse-cdn.com/v4/letter/m/eb9ed0/32.png) [@mkaka](https://discuss.elastic.co/u/mkaka)\
**Post date:** [February 26, 2019, 2:13am UTC](https://discuss.elastic.co/t/timebased-events-for-json-posts/169929/1 "2019-02-26T02:13:02Z")

</div>

Hello,

How can I create time based events in Kibana when I post something to elastic search?

How and What I am posting:

Function takes Json input in a loop.

def file\_shipper(host\_facts):  
 ES\_HOST = "exampleelasticsearch"  
 es = Elasticsearch(host=ES\_HOST)  
 index = "test"

es\_index = IndicesClient(es)  
if es\_index.exists(index):  
 print(f"{index} already exists, skipping creation")  
else:  
 es\_index.create(index)  
 print(f"{index} is created")

req = requests.post(f'https://{host}/test/test',data=host\_facts, verify=False)  
print(req)

host\_facts looks like this

{  
"\_index": "test",  
"\_type": "test",  
"\_id": "AWjom6txnKgMFUMColSE",  
"\_score": 1,  
"\_source": {  
"ip": "10.40.220.134",  
"hostname": "ARISTA-01-L3",  
"vendor": "Arista",  
"model": "DCS-7160-48YC6-F",  
"os\_version": "4.20.11M-10590868.42011M",  
"uptime": 4243232,  
"cpu": {  
"0": {  
"%usage": 14.1  
}  
},  
"latency": {  
"AWS-END-POINT": {  
"RTT": 17.562,  
"packetloss": 0  
},  
"SG2-END-POINT": {  
"RTT": 0.33,  
"packetloss": 0  
}  
},  
"@timestamp" : October 24th 2018, 10:20:45.67  
}  
}  
Question:  
on kibana I'm not able to create timebased events, it works if I uncheck time based events. How can I populate timestamp correctly, so that I can create timebased events?

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/2/e/2edb0f06c912b2c5d806908e31e6da6f1e2855d0.png)

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![thomasneirynck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thomasneirynck/32/23313_2.png) [@thomasneirynck](https://discuss.elastic.co/u/thomasneirynck)\
**Post date:** [February 27, 2019, 6:56pm UTC](https://discuss.elastic.co/t/timebased-events-for-json-posts/169929/2 "2019-02-27T18:56:09Z")

</div>

Kibana requires the timefield to actual have a date field-type in Elasticsearch.

Ensure that your Elasticsearch index uses a Date data-type ([https://www.elastic.co/guide/en/elasticsearch/reference/current/date.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/date.html)) for that `@timestamp`.

So verify your mapping is correct there in Elasticsearch. If not, you will have to set the mapping explicitly on your index, before adding documents.

---

<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:** [March 27, 2019, 6:56pm UTC](https://discuss.elastic.co/t/timebased-events-for-json-posts/169929/3 "2019-03-27T18:56:11Z")

</div>

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