使用docker compose将Elasticsearch请求/查询记录到docker实例的标准输出
我正在尝试使用dockerhub上的普通docker容器在本地运行Elasticsearch(出于开发目的) 当我在本地运行实例时,我希望看到所有查询都转储到stdout/console,这样我就可以很容易地看到我的弹性SDK客户端创建/编写/执行了哪些查询 我在这个地方看到一些评论,建议可以通过定制各种设置来实现,比如:使用docker compose将Elasticsearch请求/查询记录到docker实例的标准输出,docker,elasticsearch,logging,docker-compose,Docker,elasticsearch,Logging,Docker Compose,我正在尝试使用dockerhub上的普通docker容器在本地运行Elasticsearch(出于开发目的) 当我在本地运行实例时,我希望看到所有查询都转储到stdout/console,这样我就可以很容易地看到我的弹性SDK客户端创建/编写/执行了哪些查询 我在这个地方看到一些评论,建议可以通过定制各种设置来实现,比如: index.search.slowlog.threshold.query.debug: 0s index.search.slowlog.threshold.fetch.deb
index.search.slowlog.threshold.query.debug: 0s
index.search.slowlog.threshold.fetch.debug: 0s
index.indexing.slowlog.threshold.index.debug: 0s
但我不知道如何通过docker compose做到这一点
我尝试了以下操作,但ES在启动时崩溃:
version: '3.5'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.2.0
container_name: my-elasticsearch
networks:
- my-network
ports:
- "9200:9200"
- "9300:9300"
environment:
- discovery.type=single-node
- index.indexing.slowlog.threshold.index.deb=0s
- index.search.slowlog.threshold.fetch.debug=0s
- index.search.slowlog.threshold.query.debug=0s
有办法吗?对于低于5.X的Elasticsearch版本(这些是索引特定的设置,不推荐使用ES版本5.X)
Elasticsearch.yml
Docker-compose.yml内容
编辑:根据OPs评论
elasticsearch.yml
文件创建具有本地主机配置文件中提到的相同设置和配置的elasticsearch docker*nix
,因此无需更改卷中:
部分之后的卷部分,但在此之前它是本地主机文件系统,因此需要相应地更改它Elasticsearch.yml
中使用这些设置会引发以下错误:elasticsearch.yml
中提到它们,只需点击下面的API就可以了。
放置http://{{hostname}}:{{es port}}/{{index name}}/\u设置
{
"index.indexing.slowlog.threshold.index.warn": "0s",
"index.indexing.slowlog.threshold.index.info": "0s",
"index.indexing.slowlog.threshold.index.debug": "0s",
"index.indexing.slowlog.threshold.index.trace": "0s",
"index.indexing.slowlog.level": "info",
"index.indexing.slowlog.source": "1000"
}
谢谢你的回复。所以,让我弄清楚这一点,首先我需要1)创建一个
elasticsearch.yml
文件,并将其放置在本地主机的某个位置。2) 将docker compose.yml
文件更改为上述格式。3) 更改卷
部分,以便ES使用我的本地主机文件(在容器实例之外)作为配置。旁注:我在windows电脑上,所以我想音量必须不同。哦,对不起。。我忘了还要问。。。你能给我发一个我应该创建的elasticsearch.yml
文件的快速示例吗?这实际上是一个包含这三个设置的空文件?@Pure.Krome,请给我一些时间,我会提供this@Pure.Krome,正如我承诺的那样,我提供了我的答案:),很抱歉耽搁了,但工作很忙,最后在周末抽出时间来处理,但涉及到复制问题,调试etcSo我必须使用API打开设置,而不是使用一些环境变量或启动设置?@Pure.Krome,是的,根据docker compose中的弹性版本,您需要打开这些设置,好消息是这些设置是动态的,因此您可以立即验证。非常感谢您接受答案:D,希望你也已经投了赞成票:p
version: '2.2'
services:
#Elasticsearch Docker Images: https://www.docker.elastic.co/
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.6.0
container_name: elasticsearch
environment:
- xpack.security.enabled=false
- discovery.type=single-node
ulimits:
memlock:
soft: -1
hard: -1
nofile:
soft: 65536
hard: 65536
cap_add:
- IPC_LOCK
volumes:
- ./elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
ports:
- 9200:9200
- 9300:9300
volumes:
elasticsearch-data:
driver: local
{
"index.indexing.slowlog.threshold.index.warn": "0s",
"index.indexing.slowlog.threshold.index.info": "0s",
"index.indexing.slowlog.threshold.index.debug": "0s",
"index.indexing.slowlog.threshold.index.trace": "0s",
"index.indexing.slowlog.level": "info",
"index.indexing.slowlog.source": "1000"
}