配置 Docker 中的 Kibana
Docker 镜像提供了几种方法来配置 Kibana。传统的方法是给出一个 配置 Kibana 中描述的配置文件 kibana.yml ,也可以使用环境变量来定义设置项。
绑定配置
一种配置 Docker 中 Kibana 的方法是通过绑定配置文件 kibana.yml 。使用 docker-compose 工具,向下面这样绑定:
services:
kibana:
image: docker.elastic.co/kibana/kibana:6.0.0
volumes:
- ./kibana.yml:/usr/share/kibana/config/kibana.yml
环境变量设置
在 Docker 中,Kibana 可以通过环境变量的方法设置。环境变量如下:
Table 1. Docker 环境变量
Environment Variable
Kibana Setting
ELASTICSEARCH_CUSTOMHEADERS
elasticsearch.customHeaders
ELASTICSEARCH_PASSWORD
elasticsearch.password
ELASTICSEARCH_PINGTIMEOUT
elasticsearch.pingTimeout
ELASTICSEARCH_PRESERVEHOST
elasticsearch.preserveHost
ELASTICSEARCH_REQUESTHEADERSWHITELIST
elasticsearch.requestHeadersWhitelist
ELASTICSEARCH_REQUESTTIMEOUT
elasticsearch.requestTimeout
ELASTICSEARCH_SHARDTIMEOUT
elasticsearch.shardTimeout
ELASTICSEARCH_SSL_CA
elasticsearch.ssl.ca
ELASTICSEARCH_SSL_CERT
elasticsearch.ssl.cert
ELASTICSEARCH_SSL_KEY
elasticsearch.ssl.key
ELASTICSEARCH_SSL_VERIFY
elasticsearch.ssl.verify
ELASTICSEARCH_STARTUPTIMEOUT
elasticsearch.startupTimeout
ELASTICSEARCH_URL
elasticsearch.url
ELASTICSEARCH_USERNAME
elasticsearch.username
KIBANA_DEFAULTAPPID
kibana.defaultAppId
KIBANA_INDEX
kibana.index
LOGGING_DEST
logging.dest
LOGGING_QUIET
logging.quiet
LOGGING_SILENT
logging.silent
LOGGING_VERBOSE
logging.verbose
OPS_INTERVAL
ops.interval
PID_FILE
pid.file
SERVER_BASEPATH
server.basePath
SERVER_HOST
server.host
SERVER_MAXPAYLOADBYTES
server.maxPayloadBytes
SERVER_NAME
server.name
SERVER_PORT
server.port
SERVER_SSL_CERT
server.ssl.cert
SERVER_SSL_KEY
server.ssl.key
XPACK_MONITORING_ELASTICSEARCH_URL
xpack.monitoring.elasticsearch.url
XPACK_MONITORING_ELASTICSEARCH_USERNAME
xpack.monitoring.elasticsearch.username
XPACK_MONITORING_ELASTICSEARCH_PASSWORD
xpack.monitoring.elasticsearch.password
XPACK_MONITORING_ENABLED
xpack.monitoring.enabled
XPACK_MONITORING_MAX_BUCKET_SIZE
xpack.monitoring.max_bucket_size
XPACK_MONITORING_MIN_INTERVAL_SECONDS
xpack.monitoring.min_interval_seconds
XPACK_MONITORING_NODE_RESOLVER
xpack.monitoring.node_resolver
XPACK_MONITORING_REPORT_STATS
xpack.monitoring.report_stats
XPACK_MONITORING_KIBANA_COLLECTION_ENABLED
xpack.monitoring.kibana.collection.enabled
XPACK_MONITORING_KIBANA_COLLECTION_INTERVAL
xpack.monitoring.kibana.collection.interval
XPACK_MONITORING_UI_CONTAINER_ELASTICSEARCH_ENABLED
xpack.monitoring.ui.container.elasticsearch.enabled
XPACK_SECURITY_ENABLED
xpack.security.enabled
XPACK_SECURITY_COOKIENAME
xpack.security.cookieName
XPACK_SECURITY_ENCRYPTIONKEY
xpack.security.encryptionKey
XPACK_SECURITY_SECURECOOKIES
xpack.security.secureCookies
XPACK_SECURITY_SESSIONTIMEOUT
xpack.security.sessionTimeout
这些变量可以像下面这样,用 docker-compose 设置:
services:
kibana:
image: docker.elastic.co/kibana/kibana:6.0.0
environment:
SERVER_NAME: kibana.example.org
ELASTICSEARCH_URL: http://elasticsearch.example.org
优先使用环境变量,然后是配置文件 kibana.yml 中的配置项。
Docker 默认值
使用 Docker 时,下面的配置项有不同的默认值 :
server.host
"0"
elasticsearch.url
elasticsearch.username
elastic
elasticsearch.password
changeme
xpack.monitoring.ui.container.elasticsearch.enabled
true
这些配置项的默认值在 kibana.yml 中设置。可以通过 自定义 kibana.yml 或者 环境变量覆盖这些默认值。