Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a command line flag to specify the log destination #997

Closed
guoshimin opened this Issue Aug 17, 2015 · 10 comments

Comments

Projects
None yet
5 participants
@guoshimin
Copy link

guoshimin commented Aug 17, 2015

Currently prometheus logs to stderr. I could use shell redirection to make it log to a file, but that doesn't play well with the official prometheus docker image: I will have to change the entry point from prometheus to shell. It's better to make it a command line flag.

@fabxc

This comment has been minimized.

Copy link
Member

fabxc commented Aug 17, 2015

Not supporting this was a conscious decision. There are just to many ways to approach this problem so the builtin solutions will inevitably blow up in complexity.

Maybe the other Docker users can chime in give advice how they are solving the problem.

@discordianfish @sdurrheimer

@discordianfish

This comment has been minimized.

Copy link
Member

discordianfish commented Aug 17, 2015

@guoshimin Why do you need to redirect it to a file? Docker keeps the logs for you right now and you can access them via docker logs my-prometheus-container.

If you need to, you can also run the docker container with: docker run -a prom/prometheus ... > log.txt 2>&1 to redirect the output.

@guoshimin

This comment has been minimized.

Copy link
Author

guoshimin commented Aug 17, 2015

I want to be able to rotate logs, so I don't want docker to keep the logs
for me

  • In theory I could logrotate /var/lib/docker/containers# ls
    /var/lib/docker/containers//-json.log, but I don't want to apply the same
    log rotation policy to all container logs.

Yes there are other ways to approach this problem. Having the ability to
specify the log destination will make my run script slightly simpler. For
now I'll just continue to use shell as the entrypoint. I like to keep
everything inside the container or in volumes.

On Mon, Aug 17, 2015 at 11:00 AM, discordianfish notifications@github.com
wrote:

@guoshimin https://github.com/guoshimin Why do you need to redirect it
to a file? Docker keeps the logs for you right now and you can access them
via docker logs my-prometheus-container.

If you need to, you can also run the docker container with: docker run -a
prom/prometheus ... > log.txt 2>&1 to redirect the output.


Reply to this email directly or view it on GitHub
#997 (comment)
.

@discordianfish

This comment has been minimized.

Copy link
Member

discordianfish commented Aug 17, 2015

If you're using a recent version of Docker, you can use logging drivers to manage the logs: https://docs.docker.com/reference/logging/overview/

@swsnider

This comment has been minimized.

Copy link
Contributor

swsnider commented Aug 17, 2015

We use cronolog for this, and it works pretty well.

@guoshimin

This comment has been minimized.

Copy link
Author

guoshimin commented Aug 18, 2015

Thanks for the suggestions.

@swsnider Do you guys run cronolog inside the same container as the main app? I'm trying to run one process per container wherever I can, what with shell not propagating signal to subprocesses.

@swsnider

This comment has been minimized.

Copy link
Contributor

swsnider commented Aug 18, 2015

sorry, just realized I was mixed up -- we run our docker containers via upstart, and we use cronolog as part of the upstart script, in combination with docker run.

@guoshimin

This comment has been minimized.

Copy link
Author

guoshimin commented Aug 18, 2015

Gotcha. Thank you all for your help. I'll close the issue.

@guoshimin guoshimin closed this Aug 18, 2015

@SpoorthyB

This comment has been minimized.

Copy link

SpoorthyB commented Sep 28, 2018

@guoshimin: I’m interested to know how you are handling this as of today as I have the same scenario as yours. Are you still using shell redirection or do you have an alternative ?

@guoshimin

This comment has been minimized.

Copy link
Author

guoshimin commented Sep 28, 2018

@SpoorthyB I no longer need to do this. I simply let docker capture the stdout/stderr and from there I also set up logstash to ship the logs to elasticsearch. If I needed to do it today I would run prometheus under supervisord: http://supervisord.org/configuration.html#program-x-section-example

@lock lock bot locked and limited conversation to collaborators Mar 27, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.