Displaying a "Scripted Field" in "Metrics" visual

I've created a "Scripted Field" named AgeInSeconds using this: (System.currentTimeMillis() - doc['@timestamp'].date.getMillis()) / 1000. It is displayed as expected in the Discovery tab.

For my metric I've created a filter and chosen Top Hits to get the most recent @timestamp, but I don't see a way to choose a different metrics from that document.

An alternate (and probably preferable) approach using the JSON Input box isn't working eitiher:

{
  "script": {
    "inline": "(long) (System.currentTimeMillis() - doc['@timestamp'].date.getMillis())  / 1000",
    "lang": "painless"
  }
}

In this case the age is formatted as a Date which gives me something just past the epoch.

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