# Error when using lens with time shift

**URL:** <https://discuss.elastic.co/t/error-when-using-lens-with-time-shift/289802>\
**Category:** Kibana\
**Tags:** lens\
**Created:** [November 22, 2021, 11:54am UTC](https://discuss.elastic.co/t/error-when-using-lens-with-time-shift/289802 "2021-11-22T11:54:44Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![lifer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lifer/32/94603_2.png) [@lifer](https://discuss.elastic.co/u/lifer)\
**Post date:** [November 22, 2021, 11:54am UTC](https://discuss.elastic.co/t/error-when-using-lens-with-time-shift/289802/1 "2021-11-22T11:54:44Z")

</div>

Hi guys!

I've tried the new lens time shift feature, everything works fine with dates indexed as "strict\_date\_time", but when I try that on index with dates indexed as "epoch\_millis" I get the following error:

 ![Screenshot 2021-11-22 at 13.54.05](https://us1.discourse-cdn.com/elastic/original/3X/8/4/84ca1e571dd19308724f46643ca9124161969d4b.png)

Is this something yet to be fixed by Kibana developers?

---

<div class="post-metadata">

**Author:** ![flash1293](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/flash1293/32/41227_2.png) [@flash1293](https://discuss.elastic.co/u/flash1293)\
**Post date:** [November 22, 2021, 1:03pm UTC](https://discuss.elastic.co/t/error-when-using-lens-with-time-shift/289802/2 "2021-11-22T13:03:15Z")

</div>

Hey, this is not a known problem. Could you share your mapping and maybe an example document to reproduce the issue?

---

<div class="post-metadata">

**Author:** ![lifer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lifer/32/94603_2.png) [@lifer](https://discuss.elastic.co/u/lifer)\
**Post date:** [November 22, 2021, 3:03pm UTC](https://discuss.elastic.co/t/error-when-using-lens-with-time-shift/289802/3 "2021-11-22T15:03:02Z")

</div>

```auto
PUT /test
{
  "settings" : {
    "index" : {
      "number_of_shards" : 1,
      "number_of_replicas" : 0,
      "refresh_interval" : "1s"
    }
  },
  "mappings" : {
    "dynamic" : "strict",
    "date_detection" : false,
    "properties" : {
      "timestamp" : {
        "type" : "date",
        "format" : "epoch_millis"
      }
    }
  }
}

```

```auto
POST test/_doc/
{
  "timestamp": 1636749579080
}

```

 ![Screenshot 2021-11-22 at 17.00.58](https://us1.discourse-cdn.com/elastic/original/3X/1/e/1e1fc68ee7c9c12f7e3cd3d0c5f4721abe22a71f.png)  
 ![Screenshot 2021-11-22 at 17.02.10](https://us1.discourse-cdn.com/elastic/original/3X/9/6/96072bf70b507690bb834bb29911eb95942bb1b1.png)  
 ![Screenshot 2021-11-22 at 17.02.29](https://us1.discourse-cdn.com/elastic/original/3X/c/9/c9e72d201f811d794302e452fd5957a00483e871.png)

---

<div class="post-metadata">

**Author:** ![lifer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lifer/32/94603_2.png) [@lifer](https://discuss.elastic.co/u/lifer)\
**Post date:** [November 22, 2021, 3:05pm UTC](https://discuss.elastic.co/t/error-when-using-lens-with-time-shift/289802/4 "2021-11-22T15:05:50Z")

</div>

I've just figured out that timestamp on the error message is related to the time range of the visualization, not the timestamp from the document.

---

<div class="post-metadata">

**Author:** ![flash1293](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/flash1293/32/41227_2.png) [@flash1293](https://discuss.elastic.co/u/flash1293)\
**Post date:** [November 23, 2021, 10:56am UTC](https://discuss.elastic.co/t/error-when-using-lens-with-time-shift/289802/5 "2021-11-23T10:56:00Z")

</div>

Thank you, this is very helpful. This is indeed a bug in the time shift logic (and also in the field existence logic, but that one is not as severe). I opened issues here:

> <https://github.com/elastic/kibana/issues/119444>
>
> \*\*Kibana version:\*\* 7.15
> 
> \*\*Describe the bug:\*\* Time shift fails if some docum…ents in the index are using epoch\_millis dates
> 
> \<img width="648" alt="Screenshot 2021-11-23 at 11 50 09" src="https://user-images.githubusercontent.com/1508364/143011313-fb8e21b9-04b2-4f25-a845-d6dc386eff6f.png"\>
> 
> 
> \*\*Steps to reproduce:\*\*
> \`\`\`
> PUT /test
> {
> "settings" : {
> "index" : {
> "number\_of\_shards" : 1,
> "number\_of\_replicas" : 0,
> "refresh\_interval" : "1s"
> }
> },
> "mappings" : {
> "dynamic" : "strict",
> "date\_detection" : false,
> "properties" : {
> "timestamp" : {
> "type" : "date",
> "format" : "epoch\_millis"
> }
> }
> }
> }
> POST test/\_doc/
> {
> "timestamp": 1636749579080
> }
> \`\`\`
> 
> \<img width="697" alt="Screenshot 2021-11-23 at 11 50 27" src="https://user-images.githubusercontent.com/1508364/143011277-e73c3ce5-0147-4834-8bd4-1c11748f319e.png"\>
> 
> \*\*Any additional context:\*\*
> 
> https://discuss.elastic.co/t/error-when-using-lens-with-time-shift/289802/3
> 
> This is happening because the filter building logic is not setting the \`"format": "strict\_date\_optional\_time"\` property of the range filter.
> 
> Right now the only workaround is to only use time shift with \`strict\_date\_time\` dates.

> <https://github.com/elastic/kibana/issues/119445>
>
> \*\*Kibana version:\*\* 7.15
> 
> \*\*Describe the bug:\*\* Similar to https://github.com/…elastic/kibana/issues/119444, field existence fails if \`epoch\_millis\` dates are used for the default time field of the index pattern
> 
> \*\*Steps to reproduce:\*\*
> \`\`\`
> PUT /test
> {
> "settings" : {
> "index" : {
> "number\_of\_shards" : 1,
> "number\_of\_replicas" : 0,
> "refresh\_interval" : "1s"
> }
> },
> "mappings" : {
> "dynamic" : "strict",
> "date\_detection" : false,
> "properties" : {
> "timestamp" : {
> "type" : "date",
> "format" : "epoch\_millis"
> }
> }
> }
> }
> POST test/\_doc/
> {
> "timestamp": 1636749579080
> }
> 
> \`\`\`
> 
> \<img width="143" alt="Screenshot 2021-11-23 at 11 53 52" src="https://user-images.githubusercontent.com/1508364/143011747-0903f3bb-1fb9-4ff7-a87c-b2e0dee8776d.png"\>
> 
> \*\*Any additional context:\*\*
> 
> This is happening because the filter building logic is not setting the "format": "strict\_date\_optional\_time" property of the range filter.
> 
> Right now the only workaround is to only use time shift with strict\_date\_time dates.
> 
> 
> 
> https://github.com/elastic/kibana/blob/1ac885e428f9fc1006d9908534370c642098019e/x-pack/plugins/lens/server/routes/existing\_fields.ts#L186
> 
> https://github.com/elastic/kibana/issues/119444

We are going to fix them as soon as possible.

---

<div class="post-metadata">

**Author:** ![lifer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lifer/32/94603_2.png) [@lifer](https://discuss.elastic.co/u/lifer)\
**Post date:** [November 23, 2021, 11:51am UTC](https://discuss.elastic.co/t/error-when-using-lens-with-time-shift/289802/6 "2021-11-23T11:51:53Z")

</div>

no problem, thanks for your support!

---

<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:** [December 21, 2021, 11:52am UTC](https://discuss.elastic.co/t/error-when-using-lens-with-time-shift/289802/7 "2021-12-21T11:52:25Z")

</div>

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