3

ELK给Kibana加上登录权限控制

 1 year ago
source link: https://blog.51cto.com/u_15867943/5996105
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

ELK给Kibana加上登录权限控制

精选 原创

0. 背景

我们在使用ELK进行日志记录的时候,通过网址在Kibana中查看我们的应用程序(eg: Java Web)记录的日志,

但是默认是任何客户端都可以访问Kibana的, 这样就会造成很不安全,我们应该设置相应的用户名和密码,

只有通过登录用户名和密码才能通过Kibana查看我们的日志。

1. 在elasticsearch 2.x的版本是怎么做的

一般博文会建议进入elasticsearch的根目录,执行如下命令: bin/plugin install shield

但是,当你用的是5.x的时候,你会发现根本就没有plugin这条命令,进入es的根目录,发现只有

elasticsearch-plugin这条命令,这是怎么回事呢?

于是笔者上了官网一探究竟(任何时候查找技术,官网永远是最好最权威的选择)

官网给出的解释如下:

ELK给Kibana加上登录权限控制_Elastic

2. X-Pack是什么?

以下是官网给出的解释:

(X-Pack is an Elastic Stack extension that bundles security, alerting, monitoring, reporting, and graph capabilities into one easy-to-install package.

Prior to Elasticsearch 5.0.0, you had to install separate Shield, Watcher, and Marvel plugins to get the features that are bundled together in X-Pack.

With X-Pack, you no longer have to worry about whether or not you have the right version of each plugin,

just install the X-Pack for the Elasticsearch version you’re running)

X-Pack是Elastic技术栈的扩展,它集安全,提醒,监控,报表以及图标功能于一体。

在Elasticsearch 5.0之前,你必须单独安装Shield插件,还要配套Watcher, Marvel等插件,现在X-Pack把它们都整合到一块儿了。

3. 安装X-Pack

3.1  为elasticsearch安装X-Pack插件

进入 elasticsearch根目录

执行: bin/elasticsearch-plugin install x-pack

ELK给Kibana加上登录权限控制_根目录_02

3.2  配置elasticsearch.yml

进入config目录

修改配置文件,在末尾加上如下行:

action.auto_create_index: .security,.monitoring*,.watches,.triggered_watches,.watcher-history*

这是为elasticsearch增加自动创建索引功能

3.3  后台启动elasticsearch

[root@hadoop1 elasticsearch]# su es

[es@hadoop1 elasticsearch]$ bin/elasticsearch -d

ELK给Kibana加上登录权限控制_根目录_03

3.4  为Kibana安装X-Pack插件

进入Kibana根目录

执行命令:bin/kibana-plugin install x-pack

ELK给Kibana加上登录权限控制_根目录_04

3.5 启动Kibana: bin/kibana 

3.6  为Logstash节点安装X-Pack插件

进入Logstash根目录

执行命令:bin/logstash-plugin install x-pack

3.7  用配置文件启动Logstash

bin/logstash -f config/log4j_multi_input.conf 

3.8  验证

浏览器打开路径:

​http://localhost:5601/​​

你看回到登录对话框如下:

ELK给Kibana加上登录权限控制_elasticsearch_05

默认用户名和密码是:elastic/changeme

  • 2
  • 2收藏
  • 评论
  • 分享
  • 举报

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK