starsliao/TenSunS

docker运行的时候,非hosts模式exporter未正确检测配置文件

tm2018 opened this issue · 3 comments

tm2018 commented

version: '3'
services:
redis-exporter:
image: oliver006/redis_exporter
container_name: redis-exporter
restart: always
command:
- "-redis.password-file=/redis_passwd.json"
volumes:
- ./redis_passwd.json:/redis_passwd.json
ports:
- "9121:9121"

cat redis_passwd.json

{
"redis://xxxxxxxxxxx.dcs.huaweicloud.com:6379":"",
"redis://aaaaaaaa.cn-south-1.dcs.myhuaweicloud.com:6379":"q1azw2sx"
}
docker-compose.yml文件如上,不想使用 network_mode: "host"这种网络模式,启动发现已经从redis_passwd.json读取了配置,但报错如下,exporter检测的是localhost:6379而非我配置的其他主机
2a8650662073 Go: go1.20.6 GOOS: linux GOARCH: amd64"
redis-exporter | time="2023-08-02T10:22:57Z" level=info msg="Loaded 2 entries from /redis_passwd.json"
redis-exporter | time="2023-08-02T10:22:57Z" level=info msg="Providing metrics at :9121/metrics"
redis-exporter | time="2023-08-02T10:22:59Z" level=error msg="Couldn't connect to redis instance (redis://localhost:6379)"
redis-exporter | time="2023-08-02T10:22:59Z" level=error msg="Couldn't connect to redis instance (redis://localhost:6379)"
redis-exporter | time="2023-08-02T10:23:01Z" level=error msg="Couldn't connect to redis instance (redis://localhost:6379)"

你进容器看看/redis_passwd.json的内容 感觉配置没有挂载成功

tm2018 commented

容器无法进入:

docker exec -it redis-exporter bash

OCI runtime exec failed: exec failed: unable to start container process: exec: "bash": executable file not found in $PATH: unknown

docker exec -it redis-exporter sh

OCI runtime exec failed: exec failed: unable to start container process: exec: "sh": executable file not found in $PATH: unknown

另外配置应该是读入成功了,我在redis_passwd.json增加或者减少配置,启动Loaded xxx entries from /redis_passwd.json数量都会明显变化

cat redis_passwd.json

{
"redis://xxxxxxxxxxx.dcs.huaweicloud.com:6379":"",
"redis://aaaaaaaa.cn-south-1.dcs.myhuaweicloud.com:6379":"q1azw2sx"
}

tm2018 commented

抱歉,我去redis_exporter官方github下面提。