-
Notifications
You must be signed in to change notification settings - Fork 39.3k
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
Create a logging cookbook #1236
Comments
Perhaps @satnam6502 could take a look |
Will do. I've looked a little into fluentd and once I have understood enough about what is going on I can write something. I assume we want to talk about two kinds of logging: (a) for the Kubernetes system itself and (b) for the user code in Docker containers. Right? Or should we just focus on (b)? |
@satnam6502 This issue is about (b). We also want a solution for (a). |
Right. I was thinking of producing a super-simple degenerate example i.e. On Fri, Sep 12, 2014 at 12:38 PM, bgrant0607 notifications@github.com
|
Monitoring is already taken care of by heapster. On Fri, Sep 12, 2014 at 12:41 PM, Satnam Singh notifications@github.com
|
I've done some initial work on this, and I'm looking at adding fluentd. Satnam, if you wanted to integrate heapster into cite kubernetes, I think Brendan
|
This issue is about logging. Do we want to broaden it to including monitoring as well? heapster doesn't address application monitoring at all. It's only resource monitoring. I'm not saying it's not useful, but it's only a small part of the story. |
Let's focus on logging for now. |
Ok, I think what you'll want to do is adapt a container to run fluent, and mount in /var/lib/docker/containers into that container, then you should be able to use fluent to monitor the logs there. Let's sync up on monday based on the experimentation I've done so far. |
Yesterday I performed an experiment where I wrote a simple Go that program that served some static HTML and also logged interactions (using the Go log package to stderr). I put that in a Docker image which I ran on an ubuntu wheezy GCE VM. I configured fluentd on this VM to collect logs from the log file that corresponds to the container with the Go program. Here are the relevant lines from the fluentd config file /etc/td-agent/td-agent.conf and of course b155666e56904127fa7d1f1ee4dcef873754211c1e3dd4eaf76142c156190cdb is the full container ID. |
Does docker have flags for log permissions? I don't see them - probably Worst case, why not run fluentd as root? On Wed, Sep 17, 2014 at 9:32 AM, Satnam Singh notifications@github.com
|
Yes, I thought about running fluentd as root (easily done in the config file). Another option could be to change the setup to log messages to syslog which could then be collected without needing root permssion on fluentd (I think). |
I think we want a syslog answer, too, but I think stdout/stderr is more On Wed, Sep 17, 2014 at 10:44 AM, Satnam Singh notifications@github.com
|
From http://stackoverflow.com/questions/25312710/how-to-monitor-docker-containers-log-from-non-root-user I note "Downside of this approach is that if the syslog daemon on the host is restarted, the container will lose it's socket since the daemon recreates the socket at restart". |
I think we should run fluentd as root, just like how we run cadvisor. |
Or a) petition docker for a uid/gid/mode flag to control logs access and On Wed, Sep 17, 2014 at 10:57 AM, Dawn Chen notifications@github.com
|
Amazingly using path wildcards in the fluentd config:
collects from a wee container I made with a Go program that serves static HTML and logs interactions. I'll now try multiple containers to make sure that works. |
Premature excitement: the wildcard only matches against one file. |
We can do gross things like HUP fluentd, but we should also investigate On Wed, Sep 17, 2014 at 11:48 AM, Satnam Singh notifications@github.com
|
Is there scope for contributing to fluentd to add the functionality we require? Then we could solve the problem for ourselves as well as others in the wider world who will no doubt face similar issues? |
There's certainly scope - whether it is practical is another question, and cf. everything we do with docker :) On Wed, Sep 17, 2014 at 8:48 PM, Satnam Singh notifications@github.com
|
I think there is scope, but I'd rather not block on upstreaming a patch, Its possible that this is architectural, each config describes a single log On Wed, Sep 17, 2014 at 8:48 PM, Satnam Singh notifications@github.com
|
I just saw: https://github.com/tagomoris/fluent-plugin-forest Which appears to do the things we need. Take a look at this thread: https://groups.google.com/forum/#!topic/fluentd/LhMLwOttC4A Where someone is basically discussing exactly our use case. --brendan On Wed, Sep 17, 2014 at 8:53 PM, Tim Hockin notifications@github.com
|
I think the default in_tail plugin does what we need (tail_ex merged in some time ago). As I said to Satnam in email, by default it only checks for new files every 60s (this can be reduced by specifying i.e. 'refresh_interval 5' in the I spent some time playing around with this (using the config above) and it works for me. As configured, all logs will go to a single tag, but if you specify '*' in the 'tag' name it will expand to the path (with some substitutions) if that's what you want. I used 'tag docker.container.all.*' and was just manually writing to some files using "echo", like: which turns into the tag 'docker.container.all.var.lib.docker.containers.c2.4-json.log' I have 4 files in 2 directories and it is definitely watching all of them simultaneously (I can write updates to all the files and see them pop out the output end) |
Excellent, thanks. I must have got something wrong in my experiments -- Satnam On Fri, Sep 19, 2014 at 12:46 PM, Todd Derr notifications@github.com
|
Indeed, it was a permission problem. Since then I have been running fluentd as root which fixes the problem.
|
So when I run fluentd in a container and I export the Docker log files into the container:
I can't seem to get the fluentd (td-agent) inside the container to recognize the mapped log files using the config:
I also can't get the contained fluentd to listen for JSON messages on port 8888 -- but this works fine for the fluentd running directly on the GCE instance. Any ideas about what I might do doing wrong? It looks pretty much identical to what works on the GCE instance itself. Thank you kindly. |
I would manually start the fluentd container and run a shell inside the Brendan
|
This - when it doesn't work, start at the inside and work your way out. If On Fri, Sep 19, 2014 at 6:54 PM, Brendan Burns notifications@github.com
|
Yes, I did that. I notice that within the container things work fine i.e. I will bludgeon the problem to death this weekend (because is my wife is Cheers, Satnam On 19 September 2014 18:54, Brendan Burns notifications@github.com wrote:
Satnam Singh |
docker inspect the target container (the 'pause' one associated with yours) On Fri, Sep 19, 2014 at 9:13 PM, Satnam Singh notifications@github.com
|
I've now got a fluentd running in a Docker container and it can observe logging message from a different container. Thank you! Next step: prepare a Dockerfile for this fluentd config and adjust the minion/node creation process to instantiate such a node. Initially just log to a file and then later adjust to target ELK etc. |
Do you really need a dockerfile, or just a pod config? On Mon, Sep 22, 2014 at 1:28 PM, Satnam Singh notifications@github.com
|
Thanks. I'll take a look at this in detail when I have emerged from the Cheers, Satnam On Wed, Sep 17, 2014 at 8:59 PM, Brendan Burns notifications@github.com
|
I think the README.md file I wrote the Elasticsearch/Kibana directory contrib/logging/flutend-eslasticsearch acts as kind of Cookbook. Issue closed or do we need more work? |
We need to have a cookbook that describes how to set up open source logging and monitoring in Kubernetes.
This should both describe the state of tools, as well as how to integrate with OSS logging solutions like fluentd or logstash.
The text was updated successfully, but these errors were encountered: