Unsupported script value error in visual

Hi,

I am using ELK 7.6.2.
In my index, there are two fields, timestamp and duration (duration is in ms). I have created a new field using painless script to find the start time (timestamp - duration). Below is my scripted field,

    if (doc['duration_ms'].size() != 0) { 
          return new Date(doc['@timestamp'].value.getMillis()-doc['duration_ms'].value)
    }

The preview works as expected and able to see the correct data in "Discover" too. But when i create a visual, i get "unsupported script value error".

    {
      "took": 152,
      "timed_out": false,
      "_shards": {
        "total": 180,
        "successful": 179,
        "skipped": 178,
        "failed": 1,
        "failures": [
          {
            "shard": 0,
            "index": "logstash_access_sshd-2020.12.29",
            "node": "3Lg1Rhn9RqWYnSXA68z17A",
            "reason": {
              "type": "aggregation_execution_exception",
              "reason": "Unsupported script value [Tue Dec 29 11:08:30 EET 2020], expected a number, date, or boolean"
            }
          }
        ]
      },
      "hits": {
        "total": 0,
        "max_score": null,
        "hits": []
      },
      "aggregations": {
        "2": {
          "doc_count_error_upper_bound": 0,
          "sum_other_doc_count": 0,
          "buckets": []
        }
      }
    }

is still the custom scripted fields not supported on visuals(mainly i need in data table)?

-Thanks

Unfortunately it's not supported currently. There's an open issue for it at https://github.com/elastic/kibana/issues/69121 which has more details. Probably the closest workaround is to create a secondary field at index time.

Thanks @jbudz. I'll follow the issue on GitHub and try the workaround. :slightly_smiling_face:

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