Making dynamic Schema in metricbeat?

Hi,

devguide/6.X/creating-metricsets.html recommends using the Schema packages and eventMapping() to convert Golang maps and string values to the common.MapStr with correct types of the values. It looks great.

The example shows usage of a static mapping, that is, one knows the keys in map[string]interface{} beforehand. (What does happen, btw, if a particular key is missing at runtime, would schema.Apply() fail?)

I wonder if there is a possibility to have a dynamic Schema that would convert everything present in a map[string]interface{} dynamically, without knowing the keys at the compile time?

Thanks!

Grigory Shamov, University of Manitoba / Westgrid

Hi @Grigory_Shamov1,

It is possible to report any available value without a Schema, you would need to just set the fields directly as in this example: https://www.elastic.co/guide/en/beats/devguide/current/creating-metricsets.html#_fetching.

Take into account that not using a mapping is tricky in general, as Elasticsearch will try to guess the type for every metric

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.