Hi,
i get confuse how to set a new value for msg value from message field. i want set if message value == { "msg" : "ICMP flood" }, msg value will show only ICMP flood
i have try this but getting error
Hi,
i get confuse how to set a new value for msg value from message field. i want set if message value == { "msg" : "ICMP flood" }, msg value will show only ICMP flood
i have try this but getting error
Hi 0ksigi,
Welcome to the community! For future, can you share the script snippet as code
. It makes it easier to validate and try out than sharing via screenshot.
Looking at your script I immediately see 3 issues:
{
, instead of brackets (
. You should have something like this as per the syntax guide:if (condition) {
// actionable code
}
I immediately see is you have an open string in your first emit statement. You should have emit('ICMP flood')
.
The emit
function cannot not accept null values. I would suggest emitting either an empty string, aka ''
, or another alternative value.
Taking all into consideration, I think you need to try something like this:
if (doc['message'].value == {'msg': 'ICMP flood'}) {
emit('ICMP flood')
} else {
emit('')
}
Can you try the above and see what you get?
hi Carly, thank you for replying my question.
i have try your suggestion you have suggest to me, but it still get error.
before i continue my if else condition, i am trying to extract message field using
emit (doc["message"].value)
but getting match_only_text fields do not support sorting and aggregations error.
So this new error is due to a sort or aggregation being applied to a text field. If you use the keyword field message.keyword
instead of just message
you should eliminate that error.
i am sorry, i am still confuse how to use
message keyword. i have try on my running field but get another error like
No field found for [message.keyword] in mapping
Interesting, looks like message.keyword
isn't available on your index mapping. From the index pattern name it looks like you're using Filebeat. Can you share the index mapping and filebeat config?
I did find another related thread, albeit old, that suggests reindexing which could be worth a try.
and this is my filebeat config
filebeat.inputs:
type: log
id: my-filestream-id
enabled: true
paths:
output.elasticsearch:
hosts: ["localhost:9200"]
this is my index mapping
{
"mappings": {
"_doc": {
"_meta": {
"beat": "filebeat",
"version": "7.17.8"
},
"dynamic_templates": [
{
"labels": {
"path_match": "labels.*",
"match_mapping_type": "string",
"mapping": {
"type": "keyword"
}
}
},
{
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
© 2020. All Rights Reserved - Elasticsearch
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant logo are trademarks of the Apache Software Foundation in the United States and/or other countries.