HI all,
My setup has only a filebeat sending the logs to elasticsearch, I'm trying to use multiple templates with different indexes.
When filebeat starts, the indexes are created, but only with default fields (beat.name, beat.version, and stuffs like that), I'm not sure if the filebeat are sending data using my templates, but when I've purposely typed something wrong on my json, the prospector won't be able to start, so I guess my template is being read.
Here my filebeat.yml
filebeat.prospectors:
- type: log
json.keys_under_root: true
json.message_key: event
paths:
- /var/log/*.log
- type: log
paths:
- /hostfs/var/lib/docker/containers/*/*.log
document_type: docker
json.message_key: log
output.elasticsearch:
hosts: ["localhost:9200"]
index: 'default'
indices:
- index: "backend"
when.contains:
message: "backend"
- index: "frontend"
when.contains:
message: "frontend"
setup.template.name: "default"
setup.template.pattern: "default-*"
setup.template.name: "default"
setup.template.name: "backend"
setup.template.pattern: "backend-*"
setup.template.name: "frontend"
setup.template.pattern: "frontend-*"
setup.template.overwrite: true
here my backend.json
{
"mappings": {
"_default_": {
"_all": {
"norms": false
},
"_meta": {
"version": "5.2.1"
},
"dynamic_templates": [{
"strings_as_keyword": {
"mapping": {
"ignore_above": 1024,
"type": "keyword"
},
"match_mapping_type": "string"
}
}],
"properties": {
"@timestamp": {
"type": "date"
},
"beat": {
"properties": {
"hostname": {
"ignore_above": 1024,
"type": "keyword"
},
"name": {
"ignore_above": 1024,
"type": "keyword"
},
"version": {
"ignore_above": 1024,
"type": "keyword"
},
"input_type": {
"ignore_above": 1024,
"type": "keyword"
},
"message": {
"norms": false,
"type": "text"
},
"instance_id": {
"ignore_above": 1024,
"type": "keyword"
},
"machine_type": {
"ignore_above": 1024,
"type": "keyword"
},
"project_id": {
"ignore_above": 1024,
"type": "keyword"
},
"provider": {
"ignore_above": 1024,
"type": "keyword"
},
"region": {
"ignore_above": 1024,
"type": "keyword"
},
"host": {
"ignore_above": 1024,
"type": "keyword"
},
"level": {
"ignore_above": 1024,
"type": "keyword"
},
"type": {
"ignore_above": 1024,
"type": "keyword"
},
"msg": {
"ignore_above": 1024,
"type": "keyword"
},
"app": {
"ignore_above": 1024,
"type": "keyword"
},
"environment": {
"ignore_above": 1024,
"type": "keyword"
},
"caller": {
"ignore_above": 1024,
"type": "keyword"
},
"error": {
"ignore_above": 1024,
"type": "keyword"
},
"request_uri": {
"ignore_above": 1024,
"type": "keyword"
},
"stack": {
"ignore_above": 1024,
"type": "keyword"
},
"offset": {
"type": "long"
},
"source": {
"ignore_above": 1024,
"type": "keyword"
},
"tags": {
"ignore_above": 1024,
"type": "keyword"
},
"order": 0,
"settings": {
"index.mapping.total_fields.limit": 10000,
"index.refresh_interval": "5s"
},
"template": "backend-*"
}
}
}
}
}