Hello,
I try to create a template that store in Elasticsearch only the properties inside "Data" with a dynamic Template.
My output come from the MetricBeat (call by Jolokia the Endpoint metrics of Spring boot application).
My output is as follow :
{
  "@timestamp": "2017-07-17T10:09:50.248Z",
  "beat": {
    "hostname": "XXXX",
    "name": "XXXX",
    "version": "5.5.0"
  },
  "jolokia": {
    "metric": {
      "data": {
        "classes": 9203.000000,
        "classes.loaded": 9203.000000,
        "classes.unloaded": 0.000000,
        "counter.status.200.jolokia.star-star": 1.000000,
        "gauge.response.jolokia.star-star": 173.000000,
        "gc.copy.count": 108.000000,
        "gc.copy.time": 344.000000,
        "gc.marksweepcompact.count": 3.000000,
        "gc.marksweepcompact.time": 122.000000,
        "heap": 253440.000000,
        "heap.committed": 48804.000000,
        "heap.init": 16384.000000,
        "heap.used": 34625.000000,
        "instance.uptime": 2826140.000000,
        "mem": 81738.000000,
        "mem.free": 14178.000000,
        "nonheap": 0.000000,
        "nonheap.committed": 34144.000000,
        "nonheap.init": 160.000000,
        "nonheap.used": 32934.000000,
        "processors": 4.000000,
        "systemload.average": -1.000000,
        "threads": 21.000000,
        "threads.daemon": 12.000000,
        "threads.peak": 21.000000,
        "threads.totalStarted": 25.000000,
        "uptime": 2836409.000000
      }
    }
  },
  "metricset": {
    "host": "localhost:XXXX",
    "module": "jolokia",
    "name": "jmx",
    "namespace": "metric",
    "rtt": 83257
  },
  "type": "metricsets"
}
My template is :
{
	"template": "metric-springboot-*",
	"mappings": {
		"metric_data": {
			"properties": {
				"@timestamp": {
					"type": "date"
				},
				"jolokia": {
					"properties": {
						"metric": {
							"properties": {
								"data": {
									"dynamic": "true",
									"type": "object"
								}
							}
						}
					}
				}
			},
			"dynamic_templates": [
			{	
				"data_value_mapping": {
					"path_match": "jolokia.metric.data.*",
					"mapping": {
						"type": "float",
						"index": false
					}
				}
			}
			]
		}
	}
}
But I have the following error :
java.lang.IllegalArgumentException: Can't merge a non object mapping [jolokia.me
tric.data.classes] with an object mapping [jolokia.metric.data.classes]
My metricbeat configuration is :
metricbeat.modules:
- module: jolokia
  metricsets: ["jmx"]
  enabled: true
  period: 10s
  hosts: ["localhost:8081"]
  namespace: "metric"
  path: "xxxx/jolokia/read"
  jmx.mappings:
    - mbean: 'org.springframework.boot:name=metricsEndpoint,type=Endpoint'
      attributes:
        - attr: Data
          field: data
          field_type: java.Object
output.elasticsearch:
  hosts: ["localhost:9200"]
  index: "metric-springboot-smartphone"
  template.name: "metric_springboot"
  template.path: "metricbeat.template-metrics.json"
  template.versions.2x.enabled: false
  template.versions.6x.enabled: false
Thank for your help