I have an logstash instance with ElasticSearch Index. I trying to run some queries against to this index via command line, because I would like to monitor some log items in this index, because I use logstash as a central logging server.
But I am totall missed in query language, and I cannot find a correct part of documentation for solve my problem.
I trying to search some specific log messages. My mapping seems as following:
{
"syslog": {
"properties": {
"@fields": {
"dynamic": "true",
"properties": {
"received_at": {
"type": "date",
"format": "dateOptionalTime"
},
"received_from": {
"type": "string"
},
"syslog_facility": {
"type": "string"
},
"syslog_facility_code": {
"type": "long"
},
"syslog_pri": {
"type": "string"
},
"syslog_program": {
"type": "string"
},
"syslog_severity": {
"type": "string"
},
"syslog_severity_code": {
"type": "long"
}
}
},
"@message": {
"type": "string"
},
"@source": {
"type": "string"
},
"@source_host": {
"type": "string"
},
"@source_path": {
"type": "string"
},
"@tags": {
"type": "string"
},
"@timestamp": {
"type": "date",
"format": "dateOptionalTime"
},
"@type": {
"type": "string"
}
}
}
}
The query what I want to run is something like: @source.host:myhost AND syslog_program:exim4
I do this query against my ES server:
curl -ks http://localhost:9200/syslog-2012.10.27/syslog/_search?q=syslog_program:exim4%20AND%20@source_host:myhost
What I want is ordering result by received_at and limiting to last 2-3 items.