ricoberger / script_exporter

Prometheus exporter to execute scripts and collect metrics from the output or the exit status.
MIT License
354 stars 82 forks source link

Error encountered when executing script with Docker - 6: docker: command not found #117

Closed ginsul closed 7 months ago

ginsul commented 9 months ago

Hi,

Seems like there are problem when running docker?

ts=2024-02-15T11:18:16.300Z caller=scripts.go:108 level=debug msg="Script 'docker' execution succeed" cmd=./examples/docker.sh stdout="0\nnumber_of_files 0\n" stderr="./examples/docker.sh: line 6: docker: command not found\n" env=

Running with :

docker run --rm -it --name script_exporter -p 9469:9469 -v $(pwd):/examples -v /var/run/docker.sock:/var/run/docker.sock ricoberger/script_exporter:main -config.file /examples/config.yaml -log.level=debug

Thank you

ricoberger commented 9 months ago

Hi @ginsul, the /examples/docker.sh example requires Docker and was used to test, if the output of a Docker container can be used with the exporter.

This example will not work with our Docker image, since it doesn't contain Docker.

If you want to use it, you have to build your own Docker image where Docker is installed inside the image, to have a Docker in Docker setup. I'm not completely sure if this will work, since I never tested it.

ricoberger commented 7 months ago

Hi @ginsul, since there is no activity for some time, I will close the issue for now. If this is still a problem please let me know and we can reopen the issue.