# Convert unix timestamp to epoch\_second and assign to @timestamp

**URL:** https://discuss.elastic.co/t/convert-unix-timestamp-to-epoch-second-and-assign-to-timestamp/328133
**Category:** Elasticsearch
**Tags:** ingest-pipeline
**Created:** [March 21, 2023, 6:58am UTC](https://discuss.elastic.co/t/convert-unix-timestamp-to-epoch-second-and-assign-to-timestamp/328133 "2023-03-21T06:58:08Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![nika](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nika/32/118462_2.png) [@nika](https://discuss.elastic.co/u/nika)
#### Post date: [March 21, 2023, 6:58am UTC](https://discuss.elastic.co/t/convert-unix-timestamp-to-epoch-second-and-assign-to-timestamp/328133/1 "2023-03-21T06:58:08Z")

</div>

I'm sorry if this is covered elsewhere, but I have been having trouble getting this to work.

I have a field in a log being sent to elasticsearch from filebeat. The log is ndjson formatted.

The field is called time and contains a value formatted like so: "1679266923.890941"

I first tried doing the following:

```auto
PUT _ingest/pipeline/id
{
  processors [
  {
    "date": {
      "field": "time",
      "formats": ["epoch_second"]
  }
]
}

```

This does not put a proper, correct date (the date is several years before the actual date of this timestamp).

So I tried this:

```auto
PUT _ingest/pipeline/id
{
  processors [
  {
    "convert" {
      "field": "time",
      "type": "long"
    }
  },
  {
    "date": {
      "field": "time",
      "formats": ["epoch_second"]
    }
  }
]
}

```

This produces an error with filebeat.

Any suggestions would be very helpful.

Thanks.

---

<div class="post-metadata">

### Author: ![nika](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nika/32/118462_2.png) [@nika](https://discuss.elastic.co/u/nika)
#### Post date: [March 22, 2023, 4:54pm UTC](https://discuss.elastic.co/t/convert-unix-timestamp-to-epoch-second-and-assign-to-timestamp/328133/2 "2023-03-22T16:54:11Z")

</div>

Doing the following solved the issue:

```auto
PUT _ingest/pipeline/my_pipeline
{
  "processors": [
    {
      "date":: {
        "field": "time",
        "formats": ["UNIX"]
      }
    }
  ]
}

```

---

<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: [April 19, 2023, 4:54pm UTC](https://discuss.elastic.co/t/convert-unix-timestamp-to-epoch-second-and-assign-to-timestamp/328133/3 "2023-04-19T16:54:16Z")

</div>

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