ElasticSearch之Slow Log
ElasticSearch的慢日志,相关的参数及配置方法。
在log4j2.properties中配置慢日志的输出文件名。
Search Slow Log
相关参数
index.search.slowlog.threshold.query.warnindex.search.slowlog.threshold.query.infoindex.search.slowlog.threshold.query.debugindex.search.slowlog.threshold.query.traceindex.search.slowlog.threshold.fetch.warnindex.search.slowlog.threshold.fetch.infoindex.search.slowlog.threshold.fetch.debugindex.search.slowlog.threshold.fetch.trace
上述参数的默认值均为-1,即关闭日志的输出。
参数值为时长,单位如下:
s,即秒,样例:10s。ms,即毫秒,样例:10ms。
修改各参数的时长,命令样例,如下:
curl -X PUT "https://localhost:9200/testindex_001/_settings?pretty" -H 'Content-Type: application/json' -d'
{
"index.search.slowlog.threshold.query.warn": "10s",
"index.search.slowlog.threshold.query.info": "5s",
"index.search.slowlog.threshold.query.debug": "2s",
"index.search.slowlog.threshold.query.trace": "500ms",
"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"
}
' --cacert $ES_HOME/config/certs/http_ca.crt -u "elastic:ohCxPH=QBE+s5=*lo7F9"
执行结果的样例,如下:
{
"acknowledged" : true
}
查看上述参数的当前值,命令样例,如下:
curl -X GET "https://localhost:9200/testindex_001/_settings?pretty" --cacert $ES_HOME/config/certs/http_ca.crt -u "elastic:ohCxPH=QBE+s5=*lo7F9"
执行结果的样例,如下:
{
"testindex_001" : {
"settings" : {
"index" : {
"routing" : {
"allocation" : {
"include" : {
"_tier_preference" : "data_content"
}
}
},
"search" : {
"slowlog" : {
"threshold" : {
"fetch" : {
"warn" : "1s",
"trace" : "200ms",
"debug" : "500ms",
"info" : "800ms"
},
"query" : {
"warn" : "10s",
"trace" : "500ms",
"debug" : "2s",
"info" : "5s"
}
}
}
},
"number_of_shards" : "1",
"provided_name" : "testindex_001",
"merge" : {
"scheduler" : {
"max_thread_count" : "2"
}
},
"creation_date" : "1701354456991",
"number_of_replicas" : "1",
"uuid" : "7iGJRFfxRd2jD3qP-KDRmQ",
"version" : {
"created" : "8500003"
}
}
}
}
}
Index Slow log
相关参数
index.indexing.slowlog.threshold.index.warn
index.indexing.slowlog.threshold.index.info
index.indexing.slowlog.threshold.index.debug
index.indexing.slowlog.threshold.index.trace
上述参数的默认值均为-1,即关闭日志的输出。
参数值为时长,单位如下:
s,即秒,样例:10s。ms,即毫秒,样例:10ms。
index.indexing.slowlog.source,指定在日志中记录数据中_source时的长度,默认值为1000。
false或者0,记录日志时跳过_source字段。true,记录日志时完整记录_source字段。- 非零值,记录日志时截取
_source字段的部分。
index.indexing.slowlog.reformat,输出日志时,对_source做格式化操作,默认值为true。
true,对_source做格式化操作。false,不对_source做格式化操作。
修改各参数的时长,命令样例,如下:
curl -X PUT "https://localhost:9200/testindex_001/_settings?pretty" -H 'Content-Type: application/json' -d'
{
"index.indexing.slowlog.threshold.index.warn": "10s",
"index.indexing.slowlog.threshold.index.info": "5s",
"index.indexing.slowlog.threshold.index.debug": "2s",
"index.indexing.slowlog.threshold.index.trace": "500ms",
"index.indexing.slowlog.source": "1000"
}
' --cacert $ES_HOME/config/certs/http_ca.crt -u "elastic:ohCxPH=QBE+s5=*lo7F9"
执行结果的样例,如下:
{
"acknowledged" : true
}
查看上述参数的当前值,命令样例,如下:
curl -X GET "https://localhost:9200/testindex_001/_settings?pretty" --cacert $ES_HOME/config/certs/http_ca.crt -u "elastic:ohCxPH=QBE+s5=*lo7F9"
执行结果的样例,如下:
{
"testindex_001" : {
"settings" : {
"index" : {
"routing" : {
"allocation" : {
"include" : {
"_tier_preference" : "data_content"
}
}
},
"indexing" : {
"slowlog" : {
"threshold" : {
"index" : {
"warn" : "10s",
"trace" : "500ms",
"debug" : "2s",
"info" : "5s"
}
},
"source" : "1000"
}
},
"number_of_shards" : "1",
"provided_name" : "testindex_001",
"merge" : {
"scheduler" : {
"max_thread_count" : "2"
}
},
"creation_date" : "1701354456991",
"number_of_replicas" : "1",
"uuid" : "7iGJRFfxRd2jD3qP-KDRmQ",
"version" : {
"created" : "8500003"
}
}
}
}
}
控制日志级别
从前述配置方法可以发现,当前慢日志没有提供参数用于控制日志级别。
但可以通过关闭低级别的日志,从而模拟对日志级别的控制。
比如当前只希望记录INFO级别以上的日志,则可以执行如下日志,关闭debug和trace。
curl -X PUT "https://localhost:9200/testindex_001/_settings?pretty" -H 'Content-Type: application/json' -d'
{
"index.indexing.slowlog.threshold.index.debug": "-1",
"index.indexing.slowlog.threshold.index.trace": "-1"
}
' --cacert $ES_HOME/config/certs/http_ca.crt -u "elastic:ohCxPH=QBE+s5=*lo7F9"
相关资料
ElasticSearch之Slow Log的更多相关文章
- jdbc autoReconnect=true 参数设置导致 slow log 爆表。
1.过程 同事按照文档上配置了下面的jdbc url: jdbc:mysql://ip:port/db?autoReconnect=true&useUnicode=true&chara ...
- redis专题--slow log详解
SLOWLOG subcommand [argument] 什么是 SLOWLOG Slow log 是 Redis 用来记录查询执行时间的日志系统. 查询执行时间指的是不包括像客户端响应(talki ...
- mysql slow log分析工具的比较
mysql 中的 slow log 是用来记录执行时间较长(超过 long_query_time 秒)的 sql 的一种日志工具. 启用 slow log 在 my.cnf 中设置 [mysqld] ...
- mysql之 slow log 慢查询日志
一. 相关参数: • slow_query_log ◦ 是否开启慢查询日志 • slow_query_log_file ◦ 慢查询日志文件名, 在 my.cnf 我们已经定义为slow.log,默认是 ...
- Mysq性能分析 —— Genral log(普通日志)与 Slow log(慢速日式)
对Mysql进行深入的分析对于发现mysql性能瓶颈和寻找优化策略是十分必要的. 我们可以从不同的粒度上对Mysql进行分析:可以整体分析服务器,或者检查单个查询或批查询.通过分析,我们得到的如下信息 ...
- 【PHP】善用php-fpm的慢执行日志slow log,分析php性能问题
(转)善用php-fpm的慢执行日志slow log,分析php性能问题 众所周知,mysql有slow query log,根据慢查询日志,我们可以知道那些sql语句有性能问题.作为mysql的好 ...
- Genral log(普通日志)与 Slow log(慢速日式)
General log: Geleral log记录了服务器接收到的每一个查询或是命令,无论这些查询或是命令是否正确甚至是否包含语法错误,general log 都会将其记录下来 ,记录的格式为 {T ...
- 正确安全清空在线慢查询日志slow log的流程 (转)
1, see the slow log status; mysql> show variables like '%slow%'; +---------------------+--------- ...
- MySQL Slow Log慢日志分析【转】
如果你的MySQL出现了性能问题,第一个需要“诊断”的就是slow log(慢日志)了. slow log文件很小,使用more less等命令就足够了.如果slow log很大怎么办?这里介绍MyS ...
- MySQL-慢日志slow log
文件结构 1.目录结构 drwxrwxr-x mysql mysql Mar bin drwxrwxr-x mysql mysql Dec : binlogdir -rw-r--r-- mysql m ...
随机推荐
- python基础:集合(set)字典(direction)介绍
三.字典(dict) 1.字典的创建赋值创建字典In [2]: d = {1,True,"hello"} In [3]: type(d)Out[3]: set #字典由key和va ...
- 「codeforces - 1674F」Madoka and Laziness
link. 如果做过 codeforces - 1144G 那这题最多 *2200. 序列中的最大值必然为其中一个拐点,不妨设 \(a_p = a_\max\),先讨论另一个拐点 \(i\) 在 \( ...
- 在deepin上使用Fleet开发SpringBoot 3.0.0项目
前言 Fleet被称为是由 JetBrains 打造的下一代 IDE,目前出于公测状态,可以免费下载使用. SpringBoot 3.0.0最小支持是JDK 17,这或许是对于JDK8的断舍离迈出的重 ...
- 43道Python经典案例题(有答案)
1.有四个数字:1.2.3.4,能组成多少个互不相同且无重复数字的三位数?各是多少? for x in range(0,5): for y in range(0,5): for z in range( ...
- CSS 还原拉斯维加斯球数字动画
我的小册 <CSS 技术揭秘与实战通关>上线了,想了解更多有趣.进阶.系统化的 CSS 内容,可以猛击 - LINK. 最近大家刷抖音,是否有刷到拉斯维加斯的新地标 「Sphere」: 场 ...
- 2023 SHCTF-校外赛道 Crypto—Wp
WEEK1 立正 wl hgrfhg 4gNUx4NgQgEUb4NC64NHxZLg636V6CDBiDNUHw8HkapH :jdoi vl vlkw ~xrb wd nrrT Y: 凯撒解密,偏 ...
- JVM核心知识体系(转)
1.问题 1.如何理解类文件结构布局? 2.如何应用类加载器的工作原理进行将应用辗转腾挪? 3.热部署与热替换有何区别,如何隔离类冲突? 4.JVM如何管理内存,有何内存淘汰机制? 5.JVM执行引擎 ...
- OceanBase金融SQL、亿万级别据量优化案例(Row_number 开窗 + 分页SQL)
最近优化了不少SQL,简单的SQL顺手搞了不好意思发出来了忽悠人,复杂很考验逻辑思维的,但是又不想分享出来(自己收藏的案例),怕被人抄袭思路. 今天遇到一条很有意思的SQL案例: 性能SQL(金融行 ...
- 「保姆级」网络爬虫教程(二):教你下载文库中的PDF文档!
如何点赞再看,养成习惯.微信公众号搜索「Job Yan」关注这个爱发技术干货的 Coder.本文 GitHub https://github.com/JobYan/PythonPearls 已收录,还 ...
- 【Android】学习day05|简单登陆页面的实现|监听代码
实现效果如下图所示 实现代码[部分] MainActivity.java 1 package com.example.app02; 2 3 import androidx.appcompat.app. ...