# Automatically add current timestamp when indexing

**URL:** https://discuss.elastic.co/t/automatically-add-current-timestamp-when-indexing/185110
**Category:** Elasticsearch
**Created:** [June 11, 2019, 7:27am UTC](https://discuss.elastic.co/t/automatically-add-current-timestamp-when-indexing/185110 "2019-06-11T07:27:51Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![i333](https://avatars.discourse-cdn.com/v4/letter/i/8491ac/32.png) [@i333](https://discuss.elastic.co/u/i333)
#### Post date: [June 11, 2019, 7:27am UTC](https://discuss.elastic.co/t/automatically-add-current-timestamp-when-indexing/185110/1 "2019-06-11T07:27:51Z")

</div>

Can I have elasticsearch include the current timestamp when indexing a document, or is it necessary to add this from the application code that does the indexing? Any kind of default value feature where I could make it set the field to the current timestamp if no value is provided?

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [June 11, 2019, 7:36am UTC](https://discuss.elastic.co/t/automatically-add-current-timestamp-when-indexing/185110/2 "2019-06-11T07:36:22Z")

</div>

You can do that using an ingest pipeline.

---

<div class="post-metadata">

### Author: ![i333](https://avatars.discourse-cdn.com/v4/letter/i/8491ac/32.png) [@i333](https://discuss.elastic.co/u/i333)
#### Post date: [June 11, 2019, 11:32am UTC](https://discuss.elastic.co/t/automatically-add-current-timestamp-when-indexing/185110/3 "2019-06-11T11:32:48Z")

</div>

Ive only used ingest pipelines when reindexing. How can I use them in this way?

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [June 11, 2019, 2:00pm UTC](https://discuss.elastic.co/t/automatically-add-current-timestamp-when-indexing/185110/4 "2019-06-11T14:00:12Z")

</div>

I believe there is a link to a similar example towards the end of [this blog post](https://www.elastic.co/blog/should-i-use-logstash-or-elasticsearch-ingest-nodes) where a current timestamp is added to calculate the ingest delay.

---

<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 9, 2019, 2:07pm UTC](https://discuss.elastic.co/t/automatically-add-current-timestamp-when-indexing/185110/5 "2019-07-09T14:07:09Z")

</div>

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