How do I enable monitoring and logging for my containers on Bluemix? How do I enable monitoring and logging for my containers on Bluemix? docker docker

How do I enable monitoring and logging for my containers on Bluemix?


Both of the default containers provided as part of the service have ssh enabled. When launching these containers from the bluemix UI, there are input fields on the bottom right to expose a port (expose port 22 for ssh) and to paste in your ssh public key. Make sure what you paste in starts with ssh-rsa and ends with either == or your email address. You'll also need to assign a public IP address.

If you're providing your own container, here's a link I found with a dockerfile for enabling SSH, or there are some containers in dockerhub with ssh enabled.

https://docs.docker.com/examples/running_ssh_service/

Once you have ssh enabled, follow the documentation at the link pasted in the other answer: https://www.ng.bluemix.net/docs/manageapps/index-gentopic5.html to enable logging.If using one of the container images provided with the bluemix service, you can skip steps 2 and 3 under "Configuring Log Collection" as this will be done for you.

The last step to enable logging which needs to be added to the instructions is to configure the logging component you installed in Step 1 to be run by supervisor, which is installed by default in the bluemix provided containers.

You do this by:

vi /etc/supervisor/conf.d/mt-logstash-forwarder.conf

and paste in the following:

[program:mt-logstash-forwarder]command=/opt/mt-logstash-forwarder/bin/run-container-lsf.shstdout_logfile=/var/log/mt-logstash-forwarder.logstderr_logfile=/var/log/mt-logstash-forwarder.logautorestart=true

Then either restart the container, or start the mt-logstash-forwarder in a running container by running:

supervisorctl rereadsupervisorctl update

If you are providing your own container, you'll need to make sure supervisord is installed in the container and you'll need to run steps 1 and 2 in the instructions (you can't skip step 2 like you can with the bluemix provided containers), but the steps to create the /etc/supervisor/conf.d/mt-logstash-forwarder.conf are the same.

Finally, as the instructions state in the NOTE under step 3, only syslog is monitored, but you can follow those instructions to create additional conf files that allow collection of any log files you wish.


Thanks for the feedback.
In case others can't find the doc, here is the link to the documentation on how to Setup Monitoring and Logging for Containers.https://www.ng.bluemix.net/docs/manageapps/index-gentopic5.html

Then documentation is in Beta. I have opened a feedback request to improve the topic. You can also go to the above page and click the feedback button on the middle right side of the page. The documentation does assume some knowledge of using containers.

You can try to ssh or attach into docker container.$ sudo docker psUse the returned Container ID and Names. IE if ID was 795b4a1e17b9 and Names was MyContainerName

$ sudo docker attach 795b4a1e17b9 #by ID

or

$ sudo docker attach MyContainerName #by Name$ root@795b4a1e17b9:/# 

You can try to use bash:

$ sudo docker exec -it MyContainerName bash

To exit bash without leaving bash running a process

$ exit