I have Metricbeat, Kibana and Elasticsearch running in different Docker containers in the same network.
Metricbeat is sending information successfully to Elasticsearch. However, I have a problem when I want to load the sample dashboards to the Kibana index. If I execute the command: ./metricbeat setup --dashboards
in Metricbeat container, I get the following error:
Exiting: error connecting to Kibana: fail to get the Kibana version: HTTP GET request to https://kibana:5601/api/status fails: fail to execute the HTTP GET request: Get "https://kibana:5601/api/status": http: server gave HTTP response to HTTPS client (status=0). Response:
My configuration is the following:
- Docker Compose:
services:
#...
kibana:
image: docker.elastic.co/kibana/kibana:${ELK_STACK_VERSION}
container_name: kibana
volumes:
- certs:/usr/share/kibana/config/certs
- kibana_data:/usr/share/kibana/data
env_file:
- .kibana.env
ports:
- ${KIBANA_PORT}:5601
networks:
- elastic
metricbeat:
image: docker.elastic.co/beats/metricbeat:${ELK_STACK_VERSION}
user: root
container_name: metricbeat
volumes:
- certs:/usr/share/metricbeat/config/certs
- metricbeat_data:/usr/share/metricbeat/data
- ./metricbeat/config/metricbeat.yml:/usr/share/metricbeat/metricbeat.yml
- /proc:/hostfs/proc
- /sys/fs/cgroup:/hostfs/sys/fs/cgroup
- /:/hostfs
env_file:
- .metricbeat.env
networks:
- elastic
- .metricbeat.env
# Metricbeat
METRICBEAT_USERNAME=
METRICBEAT_PASSWORD=
# Elasticsearch
ELASTICSEARCH_URL=https://elasticsearch:9200
# Kibana
KIBANA_URL=kibana:5601
KIBANA_USERNAME=
KIBANA_PASSWORD=
- .kibana.env
# Kibana
SERVERNAME=kibana
# Elasticsearch
ELASTICSEARCH_URL=https://elasticsearch:9200
ELASTICSEARCH_HOSTS=https://elasticsearch:9200
ELASTICSEARCH_USERNAME=
ELASTICSEARCH_PASSWORD=
ELASTICSEARCH_SSL_CERTIFICATEAUTHORITIES=config/certs/ca/ca.crt
- metricbeat.yml
#============================== Kibana =====================================
# Starting with Beats version 6.0.0, the dashboards are loaded via the Kibana API.
# This requires a Kibana endpoint configuration.
setup.kibana:
# Kibana Host
# Scheme and port can be left out and will be set to the default (http and 5601)
# In case you specify and additional path, the scheme is required: http://localhost:5601/path
# IPv6 addresses should always be defined as: https://[2001:db8::1]:5601
host: "${KIBANA_URL}"
# Optional protocol and basic auth credentials.
protocol: "https"
username: "${KIBANA_USERNAME}"
password: "${KIBANA_PASSWORD}"
# Kibana Space ID
# ID of the Kibana Space into which the dashboards should be loaded. By default,
# the Default Space will be used.
#space.id:
# Use SSL settings for HTTPS.
ssl.enabled: true
# List of root certificates for HTTPS server verifications
ssl.certificate_authorities: ["/usr/share/metricbeat/config/certs/ca/ca.crt"]
I believe there is a problem with HTTPS configuration, there is an HTTP request to Kibana API to extract the current version when the client expects to be HTTPS.
The problematic function is here: https://github.com/elastic/beats/blob/main/metricbeat/module/kibana/kibana.go#L99https://github.com/elastic/beats/blob/main/metricbeat/module/kibana/kibana.go#L99
Moreover, I have found that if I change the protocol to HTTP in Metricbeat configuration, I don't get this error but I get a 400 Bad Request
in Kibana logs. Surprisingly, the dashboards get loaded in Kibana anyway. Could it be a security issue?