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 ...
随机推荐
- To_Heart—题解——好多好多!
1.CF1860D link && submission 发现自己并不会处理纯纯的 dp 甚至自己根本不会dp! 定义 dp_{i,j,k} 状态表示前 i 个字符有 j 个 0, 0 ...
- .NET应用如何防止被反编译
前言 前段时间分享了两篇关于.NET反编译相关的文章,然后文章留言区就有小伙伴提问:如何防止被反编译?因此本篇文章我们就来讲讲.NET应用如何防止被反编译..NET反编译相关的文章可以看如下文章: 4 ...
- docker入门加实战——docker安装并配置阿里云加速
docker入门加实战--docker安装并配置阿里云加速 为什么要学习docker 在开发和部署项目的过程中,经常会遇到如下问题: 软件安装包名字复杂,不知道去哪里找 安装软件和部署项目步骤复杂,容 ...
- SpringBoot + 自定义注解 + AOP 高级玩法打造通用开关
前言 最近在工作中迁移代码的时候发现了以前自己写的一个通用开关实现,发现挺不错,特地拿出来分享给大家. 为了有良好的演示效果,我特地重新建了一个项目,把核心代码提炼出来加上了更多注释说明,希望xdm喜 ...
- 如何为你的WSL2更换最新的6.5.7kernel
1.如果你像我一样,喜欢折腾你的 WSL2 ,这里是安装内核 6.X 的方法. 2.这是一个坏主意,可能会导致系统不稳定.数据损坏和其他问题.也可能会没事的,但不要怪我. Arch linux的wsl ...
- js数据结构--数组
<!DOCTYPE html> <html> <head> <title></title> </head> <body&g ...
- OI 模板合集
update on 2023.10: 这篇博客的原本意义是 方便直接复制 / 快速复习,但部分原有代码存在本质错误,完全没有起到这个作用,故重构. 由于折叠代码块在某些 markdown 编辑器中不支 ...
- vue3.0父级组件调用子组件方法
vue3.0父级组件调用子组件方法 场景:在页面开发过程中,我经常涉及到不同组件之间的元素和方法的调用.就此记录在vue3.0项目,也是我开发的开源项目中的实现方式. 父级组件调用子级 1.应用场景 ...
- 题解 ARC104F
前言 在这里首先感谢一下题解区的 FZzzz,本人的题解思路主要是基于他并给出了自己的理解. 如非特殊说明,本题解中的数学符号原则上与题目中一致. 题目分析 需要转化的喵喵题. 我们需要把原问题转化成 ...
- KMeans算法全面解析与应用案例
本文深入探讨了KMeans聚类算法的核心原理.实际应用.优缺点以及在文本聚类中的特殊用途,为您在聚类分析和自然语言处理方面提供有价值的见解和指导. 关注TechLead,分享AI全维度知识.作者拥有1 ...