elastic/elasticsearch-metrics-reporter-java

Specifying not_analyzed for additional fields

Opened this issue · 1 comments

The default type for string additional fields is analyzed. Is there a way to register the type for the additional fields?

For instance, we register additional fields to track the host:

   def customFields = [
           "host": InetAddress.getLocalHost().getHostName()
   ]
   def reporter = ElasticsearchReporter.forRegistry(registry)
           .hosts(hosts)
           .additionalFields(customFields)
           .build()

Our host names have a naming convention which separates the number of the instance:

  • api-01
  • api-02
  • etc..

This causes a split in the analyzed fields (api, 01, 02) when trying to visualize the data in kibana.

I've created my own template via curl but it would be nice to specify the type along with the mapping or supply a custom template to be used in ElasticsearchReporter.checkForIndexTemplate

curl -XPUT localhost:9200/_template/metrics_template -d '
{
  "order": 0,
  "template": "metrics*",
  "settings": {},
  "mappings": {
    "_default_": {
      "properties": {
        "name": {
          "index": "not_analyzed",
          "type": "string"
        },
        "host": {
          "index": "not_analyzed",
          "type": "string"
        }
      },
      "_all": {"enabled": false}
    }
  },
  "aliases": {}
}
'