[试图弄清Kibana的ELASTICSEARCH_HOSTS语法,但我收到以下任何一个:
kib01 | FATAL Error: [config validation of [elasticsearch].hosts]: types that failed validation:
kib01 | - [config validation of [elasticsearch].hosts.0]: expected URI with scheme [http|https].
kib01 | - [config validation of [elasticsearch].hosts.1]: could not parse array value from json input
来自Kibana本身或:
ERROR: The Compose file './docker-compose.yml' is invalid because:
services.kibana.environment.ELASTICSEARCH_HOSTS contains ["http://es01:9200", "http://es02:9200", "http://es03:9200", "http://es04:9200"], which is an invalid type, it should be a string, number, or a null
来自Docker compose。
我最新的迭代是:
environment:
ELASTICSEARCH_HOSTS=["http://es01:9200", "http://es02:9200", "http://es03:9200", "http://es04:9200"]
我也尝试过:
environment:
- ELASTICSEARCH_HOSTS: '["http://es01:9200", "http://es02:9200", "http://es03:9200", "http://es04:9200"]'
我尝试将其转换为列表:
environment:
ELASTICSEARCH_HOSTS:
- "<host1>"
- "<host2>"
我曾尝试在上述变体中的各个位置以及列表中的各种组合中删除引号。
我还尝试了同时使用official documentation和:
的=
组合
带有ELASTICSEARCH_HOST = http://es01:9200, http://es02:9200...
全部都被拒绝。有谁知道神奇的语法使它起作用?
有一些注意事项可以解决您的问题:
# A native yaml approach to define key-value objects
environment:
KEY1: VAL11
KEY2: VAL2
# OR
# Some special way for compose yaml parser
# that can split key and value from a "KEY1=VAL1" string
environment:
- KEY1=VAL1
- KEY2=VAL2
环境变量的值必须是字符串(上面的示例),数字或null(空值)。请注意,如果您编写[foo, bar]
yaml解析器,则将其视为列表。
在this论坛问题中,有一个示例如何将多个Elasticsearch主机作为环境变量(ELASTICSEARCH_HOSTS
)传递。
因此,这必须是docker-compose和Kibana都能理解的有效示例:
environment:
ELASTICSEARCH_HOSTS: "['http://es01:9200','http://es02:9200','http://es03:9200','http://es04:9200']"
# OR
environment:
- ELASTICSEARCH_HOSTS=['http://es01:9200','http://es02:9200','http://es03:9200','http://es04:9200']