Error using time in Vega

When I use below I got the following error, and I am just trying to use the time range from the dashboard, anyone can help ?

(EsError: failed to parse date field [1738832413539] with format [strict_date_optional_time]: [failed to parse date field [1738832413539] with format [strict_date_optional_time]]
)

{
 "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
 "data": {
   "url": {
     "index": "any-event*",
     "body": {
       "size": 0,
       "query": {
         "bool": {
           "filter": [
             { 
               "range": { 
                 "message.timestamp": {
                   "gte": {"%timefilter%": "min"},
                   "lte": {"%timefilter%": "max"}
                 }
               }
             },
             { "term": { "environment.keyword": "prod" } },
             { "term": { "message.affiliateName.keyword": "xyz" } }
           ]
         }
       },
           "aggs": {
             "false_count": {
               "filter": { "term": { "message.hasException": false } }
             },
             "true_count": {
               "filter": { "term": { "message.hasException": true } }
             },
             "total_count": {
               "value_count": { "field": "message.hasException" }
             }
       }
     }
   },
   "format": { "property": "aggregations.time_buckets.buckets" }
 },
 "transform": [
  {
    "window": [{"op": "rank", "as": "rank"}],
    "sort": [{"field": "key", "order": "descending"}]
  },
  {
    "filter": "datum.rank == 1"
  },
   {
     "calculate": "datum.total_count.value > 0 ? datum.false_count.doc_count / datum.total_count.value * 100 : 0",
     "as": "false_percentage"
   },
   {
     "calculate": "datum.false_percentage >= 80 ? '#3ca951' : datum.false_percentage >= 70 ? '#efb118' : '#d62728'",
     "as": "color"
   }
 ],
 "mark": {
   "type": "text",
   "fontSize": 100,
   "fontWeight": "bold",
   "background": { "field": "color", "type": "nominal" }
 },
 "encoding": {
   "text": { "field": "false_percentage", "type": "quantitative", "format": ".1f" },
   "color": { "field": "color", "type": "nominal", "scale": null }
 }
}

Hey,

It is hard to debug without seeing the data itself. However, this issue seems to be related to date fields. If I look in your code there is the Range query. I assume that this is done to let the timefilter of Kibana have an impact on your visualisation. Could you try to replace that range filter with an %timefield% in the root of the data.url clause? More info on that field can be found here: Custom visualizations with Vega | Kibana Guide [8.17] | Elastic