使用kibana的开发工具console做一些elasticsearch的基本查询和设置
针对于刚搭建的ELK环境,要做一些基本的设置。如:索引模板的建立。
如果非集群模式的ELK环境,在监听新的日志文件时,没有创建索引模板,则会根据系统默认的模板规则进行创建。但是系统默认的配置是按照集群方式处理的,会创建多个副本文件等。不是最优的方案,所以需要针对性的优化,而kibana后台提供了一个方便的可视化操作界面,很好用,如下
简单的模板配置
PUT /_template/filebeat-*
{
"index_patterns" : "filebeat*", //索引名称
"order" : 0, //层级深度,向上兼容
"settings" : {
"number_of_shards" : 5, //碎片
"number_of_replicas": 0 //副本
}
}
查询索引模板
GET _template/filebeat*
删除索引模板
DELETE _template/filebeat-6.4.2
查询5分钟之内的数据
POST /filebeat*/_search
{
"query": {
"bool": {
"must": [
{
"range": {
"@timestamp": {
"gte": "now-5m/m",
"lte": "now/m",
"format": "epoch_millis"
}
}
}
],
"filter": [
{
"multi_match": {
"type": "best_fields",
"query": "exception or error",
"lenient": true
}
}
]
}
}
}
查看索引列表
http://xxx.xx.xxx.xx:9200/_cat/indices?v
查看具体索引
http://xx.xx.xx.xx:9200/test-4-2018.11.15
附 logstash的grok语法链接
https://github.com/logstash-plugins/logstash-patterns-core/blob/master/patterns/grok-patterns
原创文章,转载请标明本文链接: 使用kibana的开发工具console做一些elasticsearch的基本查询和设置