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 ...
随机推荐
- KRPano JS 场景编辑器源码
KRPano JS编辑器,可以运行在Node环境中. 源码地址:https://github.com/xxweimei/krpano-editor-js 或者下载zip包:http://pan.bai ...
- 文心一言 VS 讯飞星火 VS chatgpt (93)-- 算法导论9.2 1题
一.用go语言,证明:在 RANDOMIZED-SELECT 中,对长度为0的数组,不会进行递归调用. 文心一言: 在 Go 语言中,我们可以通过实现一个函数来检查数组的长度,如果长度为0,则不进行递 ...
- 【规范】SpringBoot接口返回结果及异常统一处理,这样封装才优雅
前言 缘由 博友的需求就是我最大的动力 博友一说话,本狗笑哈哈.博友要我写啥,我就写啥. 特来一篇关于SpringBoot接口返回结果及异常统一处理,虽说封不封装都能用,但咱后端也得给前端小姐姐留个好 ...
- salesforce零基础学习(一百三十二)Flow新功能: Custom Error
本篇参考: https://help.salesforce.com/s/articleView?id=sf.flow_ref_elements_custom_error.htm&type=5 ...
- 拟合优度R2较低怎么办
拟合优度R2较低怎么办 (1)回归分为解释型回归和预测型回归. 预测型回归一般才会更看重2. 解释型回归更多的关注模型整体显著性以及自变量的统计显著性和经济意义显著 性即可. (2)可以对模型进行调整 ...
- 在 kubernetes 环境中实现 gRPC 负载均衡
前言 前段时间写过一篇 gRPC 的入门文章,在最后还留了一个坑没有填: 也就是 gRPC 的负载均衡问题,因为当时的业务请求量不算大,再加上公司没有对 Istio 这类服务网格比较熟悉的大牛,所以我 ...
- Unity - UIWidgets 7. Redux接入(二) 把Redux划分为不同数据模块
参考QF.UIWidgets 参考Unity官方示例 - ConnectAppCN 前面说过,当时没想明白一个问题,在reducer中每次返回一个new State(), 会造成极大浪费,没想到用什么 ...
- ASP.NET CORE MVC的一些说明
1.ASP.NET CORE MVC 是微软公司的Web应用开发框架,结合了MVC架构的高效.简洁等优秀思想并融合了.NET的灵活性. 2.ASP.NET诞生于2002年,当时微软想保持桌面应用程序的 ...
- 阿里云上的rds 的隔离级别read committed 而不是repeatable-read设置原因
阿里云上的rds 的隔离级别 是read committed ,而不是原生mysql的"可重复读(repeatable-read)",他们是基于什么原因这样设置的? show va ...
- 深入理解maven构建生命周期和各种plugin插件(转)
https://blog.csdn.net/zhaojianting/article/details/80321488 本博文不会长篇大论的讨论生命周期的概念,而是从各种plugin的实际功能和应用出 ...