Docker Logging Driver Plugin. Sends the Docker container’s logs to the specified RELP server.
These can be modified via the --log-opt KEY=VALUE
command-line argument when using docker run
.
Log option | Description | Default value | Possible values |
---|---|---|---|
relpHostname |
Set the RELP server’s hostname |
127.0.0.1 |
any IP address |
relpPort |
Set the RELP server’s port |
1601 |
any valid port |
relpTls |
Use TLS connection instead of unencrypted to RELP server |
false |
true OR false |
syslogHostname |
Hostname in syslog message |
Actual hostname |
any string |
syslogAppName |
App name in syslog message |
teragrep |
any string |
tags |
View docker info in "dkr_01@48577" structured data |
off |
off, minimal OR full |
k8sMetadata |
Enrich syslog message with dkr_01_k8s@48577 structured data containing kubernetes metadata |
false |
true OR false |
kubeletUrl |
URL used to connect to the kubernetes metadata API |
any valid URL |
|
k8sClientAuthEnabled |
Authenticate the client for Kubernetes metadata |
true |
true OR false |
k8sClientAuthCertPath |
Path for the client.crt file for kubernetes metadata, must be accessible
from the mount specified in |
|
valid path for PEM cert |
k8sClientAuthKeyPath |
Path for the client.key file for kubernetes metadata, must be accessible
from the mount specified in |
|
valid path for PEM key |
k8sServerCertValidationEnabled |
Validate the server certificate |
false |
true OR false |
k8sServerCertPath |
Path for the server certificate, must be accessible
from the mount specified in |
(empty) |
valid path for cert |
k8sMetadataRefreshInterval |
Metadata refresh interval in seconds, 0 is always. |
0 |
valid positive integer (>=0) |
k8sMetadataRefreshEnabled |
Enable data refresh more than once in the beginning |
false |
true OR false |
In git root, run:
$ chmod +x build.sh && bash build.sh
Will make the plugin and enable it. You can check if it was successful with the docker plugin ls
command.
The plugin’s logs can be accessed from the /run/docker/plugins/<id>/
folder.
To attach the log driver to a container, run the container with the --log-driver=teragrep/dkr_01:v1
parameter.
$ docker run --log-driver=teragrep/dkr_01:v1 \
--log-opt relpHostname=127.0.0.1 \
--log-opt relpPort=1234 \
--log-opt relpTls=false
If using the docker-compose
command, you can customize the docker-compose.yaml
to contain the
options
.
x-logging:
&default-logging
options:
relpHostname: "127.0.0.1"
relpPort: "1601"
driver: teragrep/dkr_01:v1
services:
test:
build:
context: .
dockerfile: Dockerfile
logging: *default-logging
To build and use the plugin in Minikube, follow the instructions below.
(Note: In the commands below, [host]$
means that the command should be run in the
host machine’s terminal, [minikube]$
means that it should be run in minikube ssh, and
[testserver-pod]$
means that it should be run in the pod’s terminal.)
-
Start your Minikube environment with
[host]$ minikube start
-
Eval the docker-env to in your host machine’s terminal
[host]$ eval $(minikube -p minikube docker-env)
-
Build the plugin
[host]$ chmod +x build.sh && bash build.sh
-
If necessary, build the test server
[host]$ cd testserver && docker build . -t testserver:latest --no-cache
-
SSH to the minikube
[host]$ minikube ssh
-
You need to add the log driver into the dockerd launch command in the
docker.service
file[minikube]$ sudo vi /lib/systemd/system/docker.service
Change the line "ExecStart=" to contain the --log-driver=teragrep/dkr_01:v1
option and any possible
log opts.
-
Reload the daemon, restart docker service and restart kubelet to save these changes.
[minikube]$ sudo systemctl daemon-reload [minikube]$ sudo service docker restart [minikube]$ sudo systemctl restart kubelet
-
You can check if the logging driver is functioning with the command below in minikube ssh terminal:
[minikube]$ docker info | grep -i "logging driver"
It should display dkr_01 instead of the default jsonfile logging driver, if the plugin has been loaded correctly.
If you built the test server, you can run it with (in your host machine terminal):
[host]$ kubectl run dkrpod --image=testserver:latest --image-pull-policy=Never --restart=Never
To print logs, you can use the pod’s terminal and curl
[host]$ kubectl exec -i -t dkrpod -- /bin/bash
and enter
[testserver-pod]$ curl localhost:9003/foobar
to generate log output in the testserver pod.
You can involve yourself with our project by opening an issue or submitting a pull request.
Contribution requirements:
-
All changes must be accompanied by a new or changed test. If you think testing is not required in your pull request, include a sufficient explanation as why you think so.
-
Security checks must pass
-
Pull requests must align with the principles and values of extreme programming.
-
Pull requests must follow the principles of Object Thinking and Elegant Objects (EO).
Read more in our Contributing Guideline.
Contributors must sign Teragrep Contributor License Agreement before a pull request is accepted to organization’s repositories.
You need to submit the CLA only once. After submitting the CLA you can contribute to all Teragrep’s repositories.