利用elk搞了一个日志平台,随着日志越来越多,使用的人反应kibana上查询比较慢。kibana虽然有日志,但记录的信息不全,无法分析到底是什么样的查询比较慢。因此考虑在kibana和elk之间加一个nginx。主要作用有两个:
1、记录kibana的每个请求日志
2、kibana通过nginx连到es,可以实现负载均衡的请求es。
集成方法比较简单,在任意一台机器上安装nginx,nginx里配置es相关信息,kibana配置文件中的elasticsearch.url改成nginx相应的ip和监听端口即可。
nginx配置文件的主要内容如下:
upstream elasticsearch {
server 10.10.10.1:9200;
server 10.10.10.2:9200;
server 10.10.10.3:9200;
keepalive 10;
}
server {
listen 8888;
server_name hostname;
location / {
proxy_pass http://elasticsearch;
access_log_bypass_if ($request = 'HEAD / HTTP/1.1');
access_log_bypass_if ($request = 'GET /_nodes?filter_path=nodes.*.version%2Cnodes.*.http.publish_address%2Cnodes.*.ip HTTP/1.1');
access_log_bypass_if ($request = 'GET /_nodes/_local?filter_path=nodes.*.settings.tribe HTTP/1.1');
access_log_bypass_if ($request_body = '{\"docs\":[{\"_index\":\".kibana\",\"_type\":\"config\",\"_id\":\"5.5.1\"}]}');
access_log_bypass_if ($request = 'GET /_cluster/health/.kibana?timeout=5s HTTP/1.1');
access_log_bypass_if ($request = 'POST /.kibana/config/_search HTTP/1.1');
access_log_bypass_if ($request = 'GET /_cluster/settings?include_defaults=true&filter_path=**.script.engine.*.inline HTTP/1.1');
access_log_bypass_if ($request = 'GET /_aliases HTTP/1.1');
access_log_bypass_if ($request = 'GET /_mapping HTTP/1.1');
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
upstream定义了es有哪些节点。另外,nginx加了日志过滤模块ngx_log_if,用来过滤kibana和es之间的心跳请求日志,这个模块可以在github上下载
1、记录kibana的每个请求日志
2、kibana通过nginx连到es,可以实现负载均衡的请求es。
集成方法比较简单,在任意一台机器上安装nginx,nginx里配置es相关信息,kibana配置文件中的elasticsearch.url改成nginx相应的ip和监听端口即可。
nginx配置文件的主要内容如下:
upstream elasticsearch {
server 10.10.10.1:9200;
server 10.10.10.2:9200;
server 10.10.10.3:9200;
keepalive 10;
}
server {
listen 8888;
server_name hostname;
location / {
proxy_pass http://elasticsearch;
access_log_bypass_if ($request = 'HEAD / HTTP/1.1');
access_log_bypass_if ($request = 'GET /_nodes?filter_path=nodes.*.version%2Cnodes.*.http.publish_address%2Cnodes.*.ip HTTP/1.1');
access_log_bypass_if ($request = 'GET /_nodes/_local?filter_path=nodes.*.settings.tribe HTTP/1.1');
access_log_bypass_if ($request_body = '{\"docs\":[{\"_index\":\".kibana\",\"_type\":\"config\",\"_id\":\"5.5.1\"}]}');
access_log_bypass_if ($request = 'GET /_cluster/health/.kibana?timeout=5s HTTP/1.1');
access_log_bypass_if ($request = 'POST /.kibana/config/_search HTTP/1.1');
access_log_bypass_if ($request = 'GET /_cluster/settings?include_defaults=true&filter_path=**.script.engine.*.inline HTTP/1.1');
access_log_bypass_if ($request = 'GET /_aliases HTTP/1.1');
access_log_bypass_if ($request = 'GET /_mapping HTTP/1.1');
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
upstream定义了es有哪些节点。另外,nginx加了日志过滤模块ngx_log_if,用来过滤kibana和es之间的心跳请求日志,这个模块可以在github上下载
[尊重社区原创,转载请保留或注明出处]
本文地址:http://searchkit.cn/article/286
本文地址:http://searchkit.cn/article/286
1 个评论
给一下github地址,谢谢