https://github.com/fabric8io/fluent-plugin-kubernetes
https://github.com/fabric8io/fluent-plugin-kubernetes
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/fabric8io/fluent-plugin-kubernetes
- Owner: fabric8io
- License: apache-2.0
- Created: 2015-03-06T23:13:43.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2017-04-07T04:39:38.000Z (over 8 years ago)
- Last Synced: 2025-06-09T03:58:26.270Z (4 months ago)
- Language: Ruby
- Size: 203 KB
- Stars: 16
- Watchers: 44
- Forks: 10
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# fluent-plugin-kubernetes, a plugin for [Fluentd](http://fluentd.org)
[](https://circleci.com/gh/fabric8io/fluent-plugin-kubernetes)
[](https://codeclimate.com/github/fabric8io/fluent-plugin-kubernetes)
[](https://codeclimate.com/github/fabric8io/fluent-plugin-kubernetes)## Installation
gem install fluent-plugin-kubernetes
## Configuration
```type tail
path /var/lib/docker/containers/*/*-json.log
pos_file fluentd-docker.pos
time_format %Y-%m-%dT%H:%M:%S
tag docker.*
format json
read_from_head truetype kubernetes
container_id ${tag_parts[5]}
tag docker.${name}type stdout
```
Docker logs in JSON format. Log files are normally in
`/var/lib/docker/containers/*/*-json.log`, depending on what your Docker
data directory is.Assuming following inputs are coming from a log file:
0bbc558cca13c5a92cc59f33626db0aaa2afea24742d2fbe549e3a30faf7ab09-json.log:
```
{
"log": "Something happened\n",
"stream": "stdout",
"time": "2015-03-07T20:04:17.604503223Z"
}
```Then output becomes as belows
```
{
"log": "Something happened\n",
"stream": "stdout",
"time": "2015-03-07T20:04:17.604503223Z"
"container_id": "0bbc558cca13c5a92cc59f33626db0aaa2afea24742d2fbe549e3a30faf7ab09",
"container_name": "k8s_CONTAINER.2f44475a_POD.NAMESPACE.api_ae0aeb72-c44f-11e4-a274-54ee7527188d_d442134f",
"pod": "POD",
"pod_namespace": "NAMESPACE",
"pod_container": "CONTAINER"
}
```## JSON logging
Logging requires context to be really useful. Context can either be derived
from log lines from known formats, but this is error prone & requires
processing power. The logging application is the best place to add
context.If you use JSON for your application logs you can add context to your logs
as you go. This plugin will parse your log lines & if it sees that they are
JSON it will merge it in to the top level record so your contextual logging
will be nicely searchable.Something like this:
```
{
"log": "{\"context\":\"something\"}",
"stream": "stdout",
"time": "2015-03-07T20:04:17.604503223Z"
}
```Then output becomes as belows
```
{
"context": "something",
"stream": "stdout",
"time": "2015-03-07T20:04:17.604503223Z"
"container_id": "0bbc558cca13c5a92cc59f33626db0aaa2afea24742d2fbe549e3a30faf7ab09",
"container_name": "k8s_CONTAINER.2f44475a_POD.NAMESPACE.api_ae0aeb72-c44f-11e4-a274-54ee7527188d_d442134f",
"pod": "POD",
"pod_namespace": "NAMESPACE",
"pod_container": "CONTAINER"
}
```## Contributing
1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request## Copyright
Copyright (c) 2015 jimmidyson