Kibana JSON Input Painless Scripting

From Knowledge Center
Jump to: navigation, search

In Kibana we can manipulate the data with Painless scripting language, for example to split characters from a certain character like a period ".", for example:

Kibana split string.png

Examples

Multiple the value with 2:

{
  "script": {
    "inline": "doc['docker.info.containers.running'].value * 2",
    "lang": "painless"
  }
}

Only display the first 14 characters of a string:

{
  "script": "_value.substring(0,14)"
}

Strip everything from the left side of the period character:


{
    "script": "( _value.indexOf('.') > 0 ? _value.substring(0, _value.indexOf('.')) : _value )"
}

Resources:

- https://www.elastic.co/guide/en/kibana/current/data-table.html

- https://www.elastic.co/blog/using-painless-kibana-scripted-fields

- https://discuss.elastic.co/t/string-size-limit-in-painless-keyword-field/108366