Hello,World

es慢查询log问题

Elasticsearch | 作者 miqi1992 | 发布于2018年08月10日 | 阅读数:2788

由于公司集群未配置慢查询,使用的是es5.5.2,查了一下官网,慢查询配置是索引级别的,使用的是动态模板配置,我想问一下这个应该怎么配置?最好能贴出代码,我自己写了一下,不正确,但是用_setting这种方式配置就可以
已邀请:

God_lockin

赞同来自:

slow log 的官方文档?
https://www.elastic.co/guide/e ... w-log
 
直接用
PUT: ip/yourindex/_setting
写不进去么?

miqi1992

赞同来自:

可以写进去,想在动态模板里面加的,如果使用的put方式,只针对已有的索引有效,新增的索引就没有了

God_lockin

赞同来自:

不指定index的话是可以全局生效的
 
如果想永久生效需要把相应的配置写在es的配置文件里才会做到集群重启也能生效

JackGe

赞同来自:

在template中设置search slowlog,如下

PUT _template/templateName 
{
    "order": 0,
    "template": "index*",
    "settings": {
      "index": {
        "codec": "best_compression",
        "mapping": {
          "ignore_malformed": "true"
        },
        "number_of_shards": "1",
        "search": {
          "slowlog": {
            "threshold": {
              "fetch": {
                "warn": "1s",
                "trace": "200ms",
                "debug": "500ms",
                "info": "800ms"
              },
              "query": {
                "warn": "10s",
                "trace": "500ms",
                "debug": "1s",
                "info": "5s"
              }
            }
          }
        }
      }
    },
    "mappings": {
      "type": {
        "_source": {
          "enabled": true
        },
        "properties": {
          
        }
      }
    },
    "aliases": {}
  }

要回复问题请先登录注册