Skip to content

Instantly share code, notes, and snippets.

@cinhtau
Last active November 13, 2018 16:07
Show Gist options
  • Save cinhtau/544d6bbea91b4eaf3120dfbb046f214b to your computer and use it in GitHub Desktop.
Save cinhtau/544d6bbea91b4eaf3120dfbb046f214b to your computer and use it in GitHub Desktop.
2018-11-13 Elasticsearch Meet-up Stuttgart Demo 2 - Payments Statistics

Filebeat Checks

./filebeat test config
./filebeat test output

Start filebeat

With reload and debug

./filebeat -e -c filebeat.yml -d "publish"

Start with less noise

./filebeat -c filebeat.yml
GET payments-*/_search
{
"size": 0,
"query": {
"bool": {
"must": [
{
"match_all": {}
}
],
"filter": {
"range": {
"@timestamp": {
"gte": "now-4h"
}
}
}
}
},
"aggs": {
"states": {
"terms": {
"field": "address.state"
},
"aggs": {
"payments": {
"sum": {
"field": "amount"
}
},
"payments_bucket_sort": {
"bucket_sort": {
"sort": [
{
"payments": {
"order": "desc"
}
}
],
"size": 5
}
}
}
}
}
}
GET payments-*/_search
{
"size": 0,
"query": {
"bool": {
"must": [
{
"match_all": {}
}
],
"filter": {
"range": {
"@timestamp": {
"gte": "now-4h"
}
}
}
}
},
"aggs": {
"states": {
"terms": {
"field": "address.state",
"size": 5
},
"aggs": {
"cities": {
"terms": {
"field": "address.city"
},
"aggs": {
"payments": {
"sum": {
"field": "amount"
}
},
"payments_bucket_sort": {
"bucket_sort": {
"sort": [
{
"payments": {
"order": "desc"
}
}
],
"size": 3
}
}
}
}
}
}
}
}
PUT _template/statistics
{
"index_patterns": [
"statistics-*"
],
"settings": {
"number_of_shards": 1
},
"mappings": {
"doc": {
"dynamic": true,
"properties": {
"logtime": {
"type": "date",
"format": "epoch_millis"
},
"counter": {
"type": "integer"
},
"class": {
"type": "keyword"
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment