# @timestamp missing exception for datastream

**URL:** <https://discuss.elastic.co/t/timestamp-missing-exception-for-datastream/317633>\
**Category:** Elasticsearch\
**Tags:** ingest-pipeline\
**Created:** [October 27, 2022, 5:24pm UTC](https://discuss.elastic.co/t/timestamp-missing-exception-for-datastream/317633 "2022-10-27T17:24:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sankar\_S](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sankar_s/32/112213_2.png) [@Sankar\_S](https://discuss.elastic.co/u/Sankar_S)\
**Post date:** [October 27, 2022, 5:24pm UTC](https://discuss.elastic.co/t/timestamp-missing-exception-for-datastream/317633/1 "2022-10-27T17:24:20Z")

</div>

Getting the below exception while indexing the document into datastream

org.elasticsearch.ElasticsearchException: Elasticsearch exception [type=illegal\_argument\_exception, reason=data stream timestamp field [@timestamp] is missing]

Injest Pipeline  
PUT \_ingest/pipeline/auto\_now\_add  
{  
"description": "Assigns the current date if not yet present and if the index name is whitelisted",  
"processors": [  
{  
"script": {  
"source": """  
// skip if not whitelisted  
if (![ "cp\_monitoring\_data\_tenantid"  
].contains(ctx['\_index'])) { return; }

```
       // always update updated_at
      ctx['@timestamp'] = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").format(new Date());
      // don't overwrite if present
      if (ctx != null && ctx['created_at'] != null) { return; }
      
      ctx['created_at'] = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").format(new Date());
    """
  }
}

```

]  
}

Model Object  
public class Message {  
@Id  
private String id;

```
public Date getDate() {
    return date;
}

public void setDate(Date date) {
    this.date = date;
}

@Field(type= FieldType.Date)
Date date;

@Field(type = FieldType.Keyword)
private String message;

@Field(type= FieldType.Date)
private Date timestamp;

public String getId() {
    return id;
}

public void setId(String id) {
    this.id = id;
}

public String getMessage() {
    return message;
}

public void setMessage(String message) {
    this.message = message;
}

```

Mappings

```auto
<code>{
  "dynamic": true,
  "properties": {
    "date": {
      "format": "strict_date_time",
      "type": "date"
    },
    "index_age": {
      "type": "long"
    },
    "@timestamp": {
      "format": "yyyy-MM-dd'T'HH:mm:ss.SSSZ",
      "type": "date"
    },
    "timestamp": {
      "format": "yyyy-MM-dd'T'HH:mm:ss.SSSZ",
      "type": "date"
    }
  }
}
</>
Please let me know why is it failing how to fix it.
```

---

<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:** [November 24, 2022, 5:24pm UTC](https://discuss.elastic.co/t/timestamp-missing-exception-for-datastream/317633/2 "2022-11-24T17:24:36Z")

</div>

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