# Setting Elaticsearch and Kibana

## Install Elasticsearch

I followed the guide listed [here](https://www.elastic.co/guide/en/elasticsearch/reference/7.6/rpm.html#rpm-repo)

## Install Kibana

I followed the guide listed [here](https://www.elastic.co/guide/en/kibana/7.6/deb.html#deb-repo)

```bash
  $ sudo vi /etc/kibana/kibana.yml

    # Modify these lines
    server.port: 5601
    server.host: "0.0.0.0"
```

## Secure Elasticsearch & Kibana

For Security, [here](https://www.elastic.co/kr/blog/getting-started-with-elasticsearch-security)

```bash
  $ sudo /usr/share/elasticsearch/bin/elasticsearch-certutil cert -out /etc/elasticsearch/config/elastic-certificates.p12 -pass ""

  # If you meed "failed to initialize SSL TrustManager - access to read truststore file"
  $ chmod -R 770 /etc/elasticsearch/config
```

`/etc/elasticsearch/elasticsearch.yml` should look like this:

```bash
  xpack.security.enabled: true
  xpack.security.transport.ssl.enabled: true
  xpack.security.transport.ssl.verification_mode: certificate
  xpack.security.transport.ssl.keystore.path: /etc/elasticsearch/config/elastic-certificates.p12
  xpack.security.transport.ssl.truststore.path: /etc/elasticsearch/config/elastic-certificates.p12
```

Start elasticsearch

```bash
  $ sudo service elasticsearch start
  $ sudo /usr/share/elasticsearch/bin/elasticsearch-setup-passwords auto # It generates password for kibana
```

Open `/etc/kibana/kibana.yml`

```bash
  elasticsearch.username: "kibana"
  elasticsearch.password: "{elasticsearch-setup-passwords generated kibana password}"
```

And finally start/restart kibana

```bash
  $ sudo service kibana start
```

Browse `http://{ES_URL}:5601`

If you see Kibana login you have made it well. But when you don't clear your browser cache and try again.

### 참고

* [elasticsearch installation](https://www.elastic.co/guide/en/elasticsearch/reference/7.6/rpm.html#rpm-repo)
* [kibana installation](https://www.elastic.co/guide/en/kibana/7.6/deb.html#deb-repo)
* [elasticsearch-security](https://www.elastic.co/kr/blog/getting-started-with-elasticsearch-security)


---

# 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://molla4455.gitbook.io/dev-log/elastic/elasticsearch.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.
