Kibana: Install Kibana using Docker - 8.x

 Docker images for Kibana are available from the Elastic Docker registry. The base image is ubuntu:20.04 . A list of all published Docker images and tags is available at www.docker.elastic.co . The source code is in GitHub .

These images contain free and subscription features. Start a 30-day trial to try out all features.

If you haven't installed your own Elasticsearch, you can refer to the previous article " Elasticsearch: Verifying the Elasticsearch Docker image and installing Elasticsearch ".

Run Kibana on Docker for development

1) Start an Elasticsearch container for development or testing:

Note : If you have already installed Elasticsearch, you can ignore this step below.

  • Create a new Docker network for Elasticsearch and Kibana:
docker network create elastic
  • Pull the Elasticsearch Docker image:
docker pull docker.elastic.co/elasticsearch/elasticsearch:8.8.0
  • Optional: Verify the Elasticsearch Docker image signature:
wget https://artifacts.elastic.co/cosign.pub
cosign verify --key cosign.pub docker.elastic.co/kibana/kibana:8.8.0

See Elasticsearch for details on this step  : Verify the Elasticsearch Docker image and install Elasticsearch

  • Start Elasticsearch in Docker:
docker run --name es-node01 --net elastic -p 9200:9200 -p 9300:9300 -t docker.elastic.co/elasticsearch/elasticsearch:8.8.0

When starting Elasticsearch for the first time, the following security configurations are automatically made:

  • Generate certificates and keys for the transport and HTTP layers.
  • Transport Layer Security (TLS) configuration settings are written to elasticsearch.yml.
  • Generate a password for the elastic user.
  • Generate a registration token for Kibana.

NOTE : You may need to scroll back a bit in the terminal to view passwords and registration tokens.

2) Copy the generated password and registration token and save them in a safe place. These values ​​are only displayed when you start Elasticsearch for the first time. You'll use these to register Kibana with your Elasticsearch cluster and log in.

3) In a new terminal session, start Kibana and connect it to your Elasticsearch container:

docker pull docker.elastic.co/kibana/kibana:8.8.0
docker run --name kib-01 --net elastic -p 5601:5601 docker.elastic.co/kibana/kibana:8.8.0
  • Pull the Kibana Docker image:
docker pull docker.elastic.co/kibana/kibana:8.8.0

  • Optional: Verify the Kibana Docker image signature:
wget https://artifacts.elastic.co/cosign.pub
cosign verify --key cosign.pub docker.elastic.co/kibana/kibana:8.8.0

See Elasticsearch for details on this step  : Verify the Elasticsearch Docker image and install Elasticsearch

  • Start Kibana in Docker:
docker run --name kib-01 --net elastic -p 5601:5601 docker.elastic.co/kibana/kibana:8.8.0

When you start Kibana, a unique link is output to your terminal.

Generate password and registration token

If you need to reset the password of the elastic user or other built-in users, run the elasticsearch-reset-password tool. The tool is located in the Elasticsearch bin directory of the Docker container.

For example, to reset the elastic user's password:

docker exec -it es-node01 /usr/share/elasticsearch/bin/elasticsearch-reset-password -u elastic

If you need to generate a new enrollment token for Kibana or Elasticsearch nodes, run the elasticsearch-create-enrollment-token tool. The tool is located in the Elasticsearch bin directory of the Docker container.

For example, to generate a new registration token for Kibana:

docker exec -it es-node01 /usr/share/elasticsearch/bin/elasticsearch-create-enrollment-token -s kibana

Remove Docker container

To delete a container and its network, run: 

docker network rm elastic
docker rm es-node01
docker rm kib-01

Configure Kibana on Docker

The Docker image provides various ways to configure Kibana. The traditional approach is to provide a kibana.yml file, as described in Configuring Kibana , but it is also possible to use environment variables to define settings.

bind mount configuration

One way to configure Kibana on Docker is to provide kibana.yml via bind mount. With docker-compose, bind mounts can be specified like this:

version: '2'
services:
  kibana:
    image: docker.elastic.co/kibana/kibana:8.8.0
    volumes:
      - ./kibana.yml:/usr/share/kibana/config/kibana.yml

Keep the Kibana keystore

By default, Kibana automatically generates a keystore file for security setup on startup. To preserve your security settings , use the kibana-keystore utility to bind-mount the keystore's parent directory to the container. For example:

docker run -it --rm -v full_path_to/config:/usr/share/kibana/config -v full_path_to/data:/usr/share/kibana/data docker.elastic.co/kibana/kibana:8.8.0 bin/kibana-keystore create
docker run -it --rm -v full_path_to/config:/usr/share/kibana/config -v full_path_to/data:/usr/share/kibana/data docker.elastic.co/kibana/kibana:8.8.0 bin/kibana-keystore add test_keystore_setting

Environment variable configuration

Under Docker, Kibana can be configured through environment variables. When the container starts, the worker process checks the environment for variables that can be mapped to Kibana command-line arguments.

For compatibility with container orchestration systems, these environment variables are all capitalized, with underscores as word separators. The helper converts these names into valid Kibana setting names.

Note : You can see all the information you include in environment variables, including sensitive information, through the ps command.

Some example translations are shown here:

Table 1. Example Docker environment variables
 environment variable Kibana settings
SERVER_NAME server.name
SERVER_BASEPATH server.basePath
ELASTICSEARCH_HOSTS elasticsearch.hosts

In general, any of the settings listed in Configuring Kibana can be configured using this technique.

Providing array options can be tricky. The following example shows the syntax to provide an array for ELASTICSEARCH_HOSTS.

These variables can be set with docker-compose like this:

version: '2'
services:
  kibana:
    image: docker.elastic.co/kibana/kibana:8.8.0
    environment:
      SERVER_NAME: kibana.example.org
      ELASTICSEARCH_HOSTS: '["http://es01:9200","http://es02:9200","http://es03:9200"]'

Since environment variables are translated into CLI arguments, they take precedence over settings configured in kibana.yml.

Docker defaults

The following settings have different defaults when using Docker images:

server.host "0.0.0.0"
server.shutdownTimeout "5s"
elasticsearch.hosts http://elasticsearch:9200
monitoring.ui.container.elasticsearch.enabled true

These settings are defined in the default kibana.yml. They can be overridden with a custom kibana.yml or via environment variables.

Important : If you replace kibana.yml with a custom version, be sure to copy the default values ​​to the custom file if you want to keep them. Otherwise, they will be "masked" by the new file.

Guess you like

Origin blog.csdn.net/UbuntuTouch/article/details/130921373