How to change the default type of MetricBeat index when ingest data to ES


(Martin) #1

Hello, everyone.

I added 2 custom fields in "metricbeat.yml" like following:

fields: {xaxis: 1, yaxis: 1}

After data store in ES, those 2 fields are defined as "String" type in the mapping definition:

{
"fields": {
"path_match": "fields.*",
"match_mapping_type": "string",
"mapping": {
"type": "keyword"
}
}
}

So, may I know if there is a configuration item to let me modify the type from "String" to "Long" for custom fields?

Thanks in advance!


(ruflin) #2

There is a "hidden" setting callend append_fields that you can use for that: https://github.com/elastic/beats/blob/master/libbeat/_meta/config.reference.yml#L863

It has the same structure as the fields.yml we use inside our repository.

For your case it would be:

- name: fields.xaxis
  type: log

If you change anything here, you must overwrite your existing template and it will only apply to new indices.