I'm successfully pulling _cat/indices with a watcher but can't get the results split based on each line.
The below works, but the output is all one document.
{
"trigger": {
"schedule": {
"interval": "12h"
}
},
"input": {
"http": {
"request": {
"scheme": "https",
"host": "es.myhost.com",
"port": 9200,
"method": "get",
"path": "/_cat/indices",
"params": {},
"headers": {
"Authorization": "ApiKey <api_key>"
}
}
}
},
"condition": {
"always": {}
},
"actions": {
"index_payload": {
"transform": {
"script": {
"source": "ctx.payload",
"lang": "painless"
}
},
"index": {
"index": "cat_indices_results"
}
}
}
}
However, when I try to split the result into separate docs, splitting on new line it doesn't work.
Neither of these work:
"source": """return [ 'docs': ctx.payload._value.splitOnToken('\n') ]""",
"source": """return [ 'docs': ctx.payload._value.splitOnToken((String)(char)0x0a) ]""",