I am writing a Beat that generates the following event and sends to ES. I have included a sample event below. The data does not make it into ES - there is an error occurring:
WARN Can not index event (status=400): {"type":"mapper_parsing_exception",
"reason":"failed to parse [weather]",
"caused_by":{"type":"illegal_argument_exception",
"reason":"unknown property [cod]"}}
I didn't define a mapping because I assumed it would dynamically add any unknown properties. Any help would be much appreciated!
Happy to hear you are building the Weatherbeat. Looking forward to have another community Beat!
You need to tell Elasticsearch in advance what type each field is, especially for special types. If you don't define the mappings, then Elasticsearch will try to guess the types based on the first data pushed. For example, if you have a float field, but the first value that it's pushed to Elasticsearch is integer, then Elasticsearch will consider it as integer. When you push a float value, Elasticsearch will throw an exception as it expects to be integer, and not float. To avoid these problems, it's better to define the type of each field beforehand. Starting with 5.0, you just need to define the type of each field under etc/fields.yml, and then run make update in your Beat. This will generate the index template for you, that it's loaded automatically when the Beat starts.
NOTE: Please make sure to delete the current index from Elasticsearch with the old values before generating the new index template, and starting the Beat.
@monica Thanks for the reply! I did use Beat generator, but underestimated the importance of fields.yml. I was trying to define all the fields but could not find any docs on how to properly use that file. Instead, I added a placeholder in fields.yml and removed any actual fields:
- key: weatherbeat
title: weatherbeat
description:
fields:
- name: test
type: text
That seemed to cause the dynamic template to work, which is actually what I was trying to do. The weatherbeat I wrote is just for practice. I am trying to write a beat to talk to a Hadoop cluster and gather JMX metrics, which come back in many different formats, so trying to define a template would be very tedious. The dynamic part is working now though, so thanks!
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.