Hi,
I'm attempting to take a JSON-based log, and use Filebeat to stick it directly into Elasticsearch. I'm trying - at this point - not to include Logstash yet, AND also attempting to get a better understanding of what Filebeat is capable of.
Whilst I can currently get the log loaded into Elasticsearch, I can't seem to get my timestamp field to be recognised as a date. I'm aware that Filebeat will add a @timestamp
property that reflects when it read the log item. I don't mind that, but I also want my own timestamp property to be usable for time series analysis.
Some sample log items. I'm looking to use the eventTime
property as my timestamp field.
{"eventType":"search","searchTerm":"sauce","user":175362,"eventTime":"2018-08-21T15:42:29+1000"}
{"eventType":"search","searchTerm":"goats milk","user":138297,"eventTime":"2018-08-21T15:42:29+1000"}
{"eventType":"search","searchTerm":"potatoes","user":140003,"eventTime":"2018-08-21T15:42:29+1000"}
This is what I've done, and none of them have succeeded in having the eventTime
field registered as a date
type.
Partial of the filebeat.yml
file
output.elasticsearch:
hosts: ['elasticsearch:9200']
index: "search-metrics-filebeat-%{[beat.version]}-%{+yyyy.MM.dd}"
setup.template.name: "search-metrics-filebeat"
setup.template.pattern: "search-metrics-filebeat-*"
setup.template.fields: "/usr/share/filebeat/events-fields.yml"
setup.template.overwrite: true
for the events-field.yml
file, it's contents were extracted the mapping from my index, I then used a JSON -> YAML converter (I've got NO idea if this is the right thing to do or not...), and then I made the following modifications:
- set
date_detection: true
- set
dynamic_date_formats: ["YYYY-MM-DDTHH:mm:ssZZ"]
- (and finally when I decided to try the brute force approach) I added an
eventTimeField
underdynamic_templates
that matched on the property name ofeventTime
doc:
_meta:
version: 6.3.2
date_detection: true
dynamic_date_formats: ["YYYY-MM-DDTHH:mm:ssZZ"]
dynamic_templates:
- eventTimeField:
match_mapping_type: string
match: "eventTime"
mapping:
type: "date"
- fields:
mapping:
type: keyword
match_mapping_type: string
path_match: fields.*
I also tried, in the properties
section, at the same level as the apache2
and docker
entries, adding a date
property like that:
date:
type: "date"
format: "YYYY-MM-DDTHH:mm:ssZZ||yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
As you might guess, I'm basically taking bits and pieces from where-ever and trying to figure out if it works or not...
Any chance of some help please?
Thank you