# How to add time of ingestion to the document?

**URL:** https://discuss.elastic.co/t/how-to-add-time-of-ingestion-to-the-document/243042
**Category:** Elasticsearch
**Created:** [July 29, 2020, 11:31am UTC](https://discuss.elastic.co/t/how-to-add-time-of-ingestion-to-the-document/243042 "2020-07-29T11:31:56Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![vasek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vasek/32/136636_2.png) [@vasek](https://discuss.elastic.co/u/vasek)
#### Post date: [July 29, 2020, 11:31am UTC](https://discuss.elastic.co/t/how-to-add-time-of-ingestion-to-the-document/243042/1 "2020-07-29T11:31:56Z")

</div>

Hi Elasticians,  
I've created pipeline `pipeline_add_ingest_timestamp`. I would like to achieve add time of ingesting by elasticsearch to the document using this pipeline. What am I doing wrong? The field is not populate to the document using this pipeline:

```
PUT _ingest/pipeline/pipeline_add_ingest_timestamp
{ 
  "description": "Adds event.ingested field which represents time of ingestion.",
  "processors": [
    {
      "set": {
        "field": "event.ingested",
        "value": "{{_ingest.timestamp}}"
      }
    }
  ]
}

```

&nbsp;

```
GET _ingest/pipeline

```

&nbsp;

```
  "pipeline_add_ingest_timestamp" : {
    "description" : "Adds event.ingested field which represents time of ingestion.",
    "processors" : [
      {
        "set" : {
          "field" : "event.ingested",
          "value" : "{{_ingest.timestamp}}"
        }
      }
    ]
  }
```

---

<div class="post-metadata">

### Author: ![Bernt\_Rostad](https://avatars.discourse-cdn.com/v4/letter/b/3ab097/32.png) [@Bernt\_Rostad](https://discuss.elastic.co/u/Bernt_Rostad)
#### Post date: [July 29, 2020, 1:56pm UTC](https://discuss.elastic.co/t/how-to-add-time-of-ingestion-to-the-document/243042/2 "2020-07-29T13:56:02Z")

</div>

Your ingest pipeline looks good, I copied it to my own Kibana and used the [Simulate pipeline API](https://www.elastic.co/guide/en/elasticsearch/reference/7.8/simulate-pipeline-api.html) to test it - and it resulted in an event.ingested field with a timestamp in each document.

So I assume your problem is how to trigger the pipeline when you index new documents? For that you need to supply the **pipeline** -parameter with the name of your pipeline. Let's say you name it "my\_timestamp\_pipeline" then you need to index new documents like this:

```
PUT my-index/_doc/my-id?pipeline=my_timestamp_pipeline
{
  "foo": "bar"
}

```

If you use a specific programming language on the client side (Perl, PHP, Python etc) you'll need to look up the documentation for that language to learn how to add the pipeline-parameter with each indexing request.

For more info see the [Ingest node documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/ingest.html).

---

<div class="post-metadata">

### Author: ![vasek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vasek/32/136636_2.png) [@vasek](https://discuss.elastic.co/u/vasek)
#### Post date: [July 30, 2020, 10:02am UTC](https://discuss.elastic.co/t/how-to-add-time-of-ingestion-to-the-document/243042/3 "2020-07-30T10:02:30Z")

</div>

Thank you @Bernt_Rostad. I've had missing parameter `pipeline` in Logstash configuration of **logstash-output-elasticsearch** plugin. Now it works.

Thank you!

---

<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: [August 27, 2020, 10:02am UTC](https://discuss.elastic.co/t/how-to-add-time-of-ingestion-to-the-document/243042/4 "2020-08-27T10:02:40Z")

</div>

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