# 给ELK的kibana设置密码

## 1、前言

kibana是ELK中重要的一个组件，它是一个开源的数据可视化工具，主要用于分析和可视化大规模数据集。\
Kibana提供了一系列交互式的可视化组件，包括图表、表格、地图、仪表盘等，用户可以通过简单的拖拽和点击操作，将数据转化为易于理解和分析的图形化展示。Kibana还支持自定义查询和过滤器，用户可以根据自己的需求对数据进行深入挖掘和分析1。

根据前言所知，kibana是在ELK中只是会去读取elasticsearch API中的索引和一些值，所以设置密码的任务就落到了elasticsearch上，下面开始设置密码

## 2、ES设置账号密码

* 第一步：在ES的配置文件中添加以下配置

```sh
#添加如下内容
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-headers: Authorization
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
```

* 第二步：保存后，重启ES容器
* 第三步：切换到ES的程序目录，执行一下命令

```bash
./bin/elasticsearch-setup-passwords interactive
```

<mark style="color:yellow;">命令执行后</mark> ：需要设置以下六种账户的密码：\
`elastic、apm_system、kibana、logstash_system、beats_system、remote_monitoring_user`

输入y开始设置，六种密码设置完成后，需要再次**重启ES容器**

输入完成后，验证密码设置是否成功，在浏览器输入 `https://IP:9200`

这时候会让在浏览器上方输入账户名和密码，账户名就是elastic，密码就是刚刚设置的密码\
这里建议吧这些密码设置成一致的，方便配置

## 3、给Kibana设置账号密码

打开kibana的配置文件 添加以下内容  \
vim config/kibana.yml

```bash
#添加以下内容
elasticsearch.username: "elastic"
elasticsearch.password: "你在es中设置的密码"
```

保存退出后，重启kibana，再次访问kibana的地址就会发现多了输入密码的一步，这里就输入刚刚设置的es的账号密码就行了

## 4、在kibana中创建只读账号


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.zywjjj.vip/group-1/all/gei-elk-de-kibana-she-zhi-mi-ma.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
