Hello I am trying to do some data manipulation on a scripted field in Kibana. I'm having an issue where I can return all other key values in the log except the message and error.message keys. They return 0 results even with data in the fields.
Using Kibana Version: 6.4.2
Here is a example document:
{
"_index": "filelogbeat-production-6.4.2-2019.02.09",
"_type": "doc",
"_id": "Dje50mgB3uHiSvgnLMBn",
"_score": 1,
"_source": {
"offset": 309376,
"prospector": {
"type": "log"
},
"source": """C:\inetpub\logs\ct-data-service\error.log""",
"message": "================================================================================",
"fileset": {
"module": "iis",
"name": "access"
},
"error": {
"message": "Provided Grok expressions do not match field value: [================================================================================]"
},
"input": {
"type": "log"
},
"@timestamp": "2019-02-09T14:46:07.646Z",
"beat": {
"hostname": "Removed",
"name": "Removed",
"version": "6.4.2"
},
"host": {
"name": "Removed"
}
}
},
I can reference
doc['host.name'].value; //these return values
doc['offset'].value;
doc['source'].value;
Here is the scripted field return on the source key.
[
{
"_id": "RVW50mgBvqEbiJJnH8Vp",
"ipAddress": [
"C:\\inetpub\\logs\\LogFiles\\W3SVC5\\u_extend192.log"
]
},
I've tried scripting if the field exist with:
if (doc.containsKey('message')) {
return doc['message'].value;
}
or
if (doc.containsKey('error')) {
return doc['error'].value;
}
or
if (doc.containsKey('error.message')) {
return doc['error.message'].value;
}
returns
First 10 results
[]
This still returns no results.
With iis logs message field isn't always present so I ran an es query in dev tools:
GET /filelogbeat-production-6.4.2-2019.02.09/_search
{
"query": {
"exists": {
"field": "message"
}
}
}
This is how I got the sample doc. I assume using the .contains is a way to only run the scripted field when the message field is present.
Even though there is data I can't seem to access the message value with scripted fields it always returns null so does the error.message field.
I'm not sure why this is returning no values.
Also, can you do try catch blocks in painless language? I can't seem to get try catches to work.
Also in the preview results editor I can add the additional fields for message error.message and @timestamp from the drop down and only timestamp gets added to the output value.
I use doc['source'].value in the scripted field box and when previewing I added message and error.message fields from the drop down of additional fields.
This is what returns, there is no error or message results but I know for sure because of my query above that data exist and I can obviously see it in my dashboard. Its also under the string type in the drop down.
[
{
"_id": "RVW50mgBvqEbiJJnH8Vp",
"@timestamp": "2019-02-05T04:24:05.000Z",
"ipAddress": [
"C:\\inetpub\\logs\\LogFiles\\W3SVC5\\u_extend192.log"
]
},