ES开启慢查询日志
默认情况,慢日志是不开启的。要开启它,需要定义具体动作(query,fetch 还是 index),你期望的事件记录等级( WARN、INFO、DEBUG、TRACE 等),以及时间阈值。
es有几种搜索模式,比如 query_then_fetch , 表示先从各个节点query到id,然后整合,再去各个节点拿具体数据
这是一个索引级别的设置,也就是说可以独立应用给单个或所有索引,这个配置是永久的,配置后即使集群重启也会保留
PUT /_all/_settings
{
"index.search.slowlog.threshold.query.warn":"5s",
"index.search.slowlog.threshold.query.info":"2s",
"index.search.slowlog.threshold.query.debug":"1s",
"index.search.slowlog.threshold.query.trace":"400ms",
"index.search.slowlog.threshold.fetch.warn":"1s",
"index.search.slowlog.threshold.fetch.info":"800ms",
"index.search.slowlog.threshold.fetch.debug":"500ms",
"index.search.slowlog.threshold.fetch.trace":"200ms",
"index.indexing.slowlog.threshold.index.warn":"5s",
"index.indexing.slowlog.threshold.index.info":"2s",
"index.indexing.slowlog.threshold.index.debug":"1s",
"index.indexing.slowlog.threshold.index.trace":"400ms"
}
查询慢于 5 秒输出一个 WARN 日志
索引慢于 2 秒输出一个 INFO 日志
获取慢于 1 秒输出一个 DEBUG 日志
参考资料:https://www.elastic.co/guide/cn/elasticsearch/guide/current/logging.html
两种开启方式:
一、通过修改elasticsearch.yml来启用慢查询:
vim elasticsearch.yml
###Search Slow Log :查询慢日志配置,日志记录在以“_index_isearch_slowlog.log” 结尾的文件中
#注:配置不一定都需要,自己选择需要那种级别(warn、info、debug、trace)日志,关闭的话配置成-1 就可以了,注释掉重启也可以
index.search.slowlog.threshold.query.warn: 10s #超过10秒的query产生1个warn日志
index.search.slowlog.threshold.query.info: 5s #超过5秒的query产生1个info日志
index.search.slowlog.threshold.query.debug: 2s #超过2秒的query产生1个debug日志
index.search.slowlog.threshold.query.trace: 500ms #超过500毫秒的query产生1个trace日志
index.search.slowlog.threshold.fetch.warn: 1s ##fetch阶段的配置
index.search.slowlog.threshold.fetch.info: 800ms
index.search.slowlog.threshold.fetch.debug: 500ms
index.search.slowlog.threshold.fetch.trace: 200ms
###Index Slow log:索引慢日志配置 ,日志记录在以“_index_indexing_slowlog.log” 结尾的文件中
#注:上边四个配置不一定都需要,自己选择需要那种级别(warn、info、debug、trace)日志关闭的话配置成-1就可以了
index.indexing.slowlog.threshold.index.warn: 10s ##索引数据超过10秒产生一个warn日志
index.indexing.slowlog.threshold.index.info: 5s ##索引数据超过5秒产生一个info日志
index.indexing.slowlog.threshold.index.debug: 2s ##索引数据超过2秒产生一个ddebug日志
index.indexing.slowlog.threshold.index.trace: 500ms ##索引数据超过500毫秒产生一个trace日志
二、通过API动态的修改配置:
这是一个索引级别的设置,也就是说可以独立应用给单个索引:这个配置是永久的,配置后即使集群重启也会保留。如果关闭日志记录的话将选项修改成 -1 即可(例如: "index.search.slowlog.threshold.query.warn" : -1
PUT /my_index/_settings
{
"index.search.slowlog.threshold.query.warn" : "10s",
"index.search.slowlog.threshold.fetch.debug": "500ms",
"index.indexing.slowlog.threshold.index.info": "5s"
}
查询慢于 10 秒输出一个 WARN 日志。
获取慢于 500 毫秒输出一个 DEBUG 日志。
索引慢于 5 秒输出一个 INFO 日志。
这是一个集群级别的设置:一旦阈值设置过了(可以在 elasticsearch.yml 文件里定义这些阈值。没有阈值设置的索引会自动继承在静态配置文件里配置的参数),你可以和其他日志器一样切换日志记录等级。这个API简单试了下,没效果。并没有改变日志记录级别。而且我没找到集群级别的设置慢查询阈值的API。有知道的发个链接(QQ:1250134974)
PUT /_cluster/settings
{
"transient" : {
"logger.index.search.slowlog" : "DEBUG",
"logger.index.indexing.slowlog" : "WARN"
}
}
设置搜索慢日志为 DEBUG 级别。
设置索引慢日志为 WARN 级别。
ES开启慢查询日志的更多相关文章
- MySQL:动态开启慢查询日志(Slow Query Log)
前言 在开发中,高效能的程序 也包括 高效能的查询,所以优化SQL也是程序员必要技能之一.要优化就必须要有慢日志记录才可以知道哪些查询慢,然后反向去修改 慢日志设置方式 写入文件 写入数据库 实践操作 ...
- MySQL 开启慢查询日志
1.1 简介 开启慢查询日志,可以让MySQL记录下查询超过指定时间的语句,通过定位分析性能的瓶颈,才能更好的优化数据库系统的性能. 1.2 登录数据库查看 [root@localhost lib]# ...
- mysql数据库优化之开启慢查询日志
进入mysql数据库,使用 show variables like 'slow_query_log'; 查看是否开启了慢查询日志 value值为OFF,则慢查询日志没有开启,在开启慢查询日志之前,我们 ...
- php-fpm开启慢查询日志
php-fpm.conf /usr/local/php/etc/php-fpm.conf 开启慢查询日志 ; The log file for slow requests ; Default Valu ...
- MySQL跟踪SQL执行之开启慢查询日志
查询慢查询相关参数 show variables like '%quer%'; slow_query_log(是否记录慢查询) slow_query_log_file(慢日志文件路径) ...
- MySQL开启慢查询日志时报Errcode: 13 的解决方法
开启慢查询日志时会出现(Errcode: 13 - Permission denied)文件找不到的错误,但文件明明是存在的并且有读写的权限. mysql> set global slow_qu ...
- mysql配置调优-开启慢查询日志-slow_query_log
工作中,会遇到需要查看mysql的top 20 慢sql,逐个进行优化,加上必要的索引这种需求,这时就需要开启数据库的慢查询日志的功能 1.查询当前慢查询日志的状态 # 默认为关闭状态 mysql - ...
- mysql中开启慢查询日志
开启慢查询日志,需要在配置文件my.ini中配置. long_query_time = 1 #设置慢查询时间,配置是下划线log-slow-queries = d:\mysql5\logs\mysql ...
- MySQL 开启慢查询日志与普通日志
一.开启满查询日志 1.查看慢查询日志 SHOW VARIABLES LIKE '%slow%'; 2.开启慢查询日志 set GLOBAL slow_query_log =on; 3.设置慢查询日志 ...
随机推荐
- ML-线性 SVM 推导
Max Margin svm 即Suport Vector Machine, 中文意为:支持向量机. 对于二分类问题, 在样本空间中(即便是多维向量, 在空间中可表示为一个点). svm的核心思想就是 ...
- postgresql9.5编译安装体验
实验环境: centos7.6 pgsql9.5 源码编译安装 实验目的: 体验源码编译安装pgsql 01.download https://ftp.postgresql.org/pub/sourc ...
- 记录SQLAlchemy的基本使用
代码 # -*- coding: utf-8 -*- from sqlalchemy import Column, String, create_engine from sqlalchemy.orm ...
- Nginx Location指令URI匹配规则详解
server { listen 80; server_name ss.test *.ss.test; root "D:/Project/PHP/admin-h5/dist/"; s ...
- python测试开发django-67.templates模板变量取值
前言 django 的模板里面变量取值是通过句点语法来取值,就是一个点(.)符号.取值的对象也可以是字符串,int类型,list列表,字典键值对,也可以是一个类的实例对象. views视图 比如我在 ...
- git在windows及linux(源码编译)环境下安装
git在windows下安装 下载地址:https://git-scm.com/ 默认安装即可 验证 git --version git在linux下安装 下载地址:https://mirrors.e ...
- wordpress调用指定分类除外的置顶文章
我们有时需要根据实际需要进行一些设置,比如wordpress调用指定分类除外的置顶文章,如何实现呢?随ytkah一起来看看吧,用如下代码插入到需要调取的位置 <div class="r ...
- Hbase 分页设计
hbase 数据获取方式 直接根据 rowkey 查找,速度最快 scan,指定 startrowkey.endrowkey 和 limit获取数据,在 rowkey 设计良好的情况下,效率也不错 全 ...
- 谷歌浏览器打开不了Axure生成的html文件
1.首先要进行翻墙.https://www.google.com 搜索Axure chrome软件 2. 3.安装axure插件即可. 4.管理扩展程序,允许访问文件网址.
- 使用VSCode开发Flutter
前言 为什么使用VSCode? flutter官方推荐的编辑器有IDEA/Android Studio和VSCode, 之前开发Flutter用的IDEA, 不过IDEA始终比较重,于是换用VSCod ...