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

Docker driver: Allow to provision external pipeline files to plugin #2054

Merged
merged 4 commits into from
May 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/docker-driver/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ COPY . /src/loki
WORKDIR /src/loki
RUN make clean && make BUILD_IN_CONTAINER=false cmd/docker-driver/docker-driver

FROM alpine:3.9
FROM alpine:3.11
RUN apk add --update --no-cache ca-certificates tzdata
COPY --from=build /src/loki/cmd/docker-driver/docker-driver /bin/docker-driver
WORKDIR /bin/
Expand Down
49 changes: 30 additions & 19 deletions cmd/docker-driver/config.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,31 @@
{
"description": "Loki Logging Driver",
"documentation": "https://github.com/grafana/loki",
"entrypoint": ["/bin/docker-driver"],
"network": {
"type": "host"
},
"interface": {
"types": ["docker.logdriver/1.0"],
"socket": "loki.sock"
},
"env": [
{
"name": "LOG_LEVEL",
"description": "Set log level to output for plugin logs",
"value": "info",
"settable": ["value"]
}
]
}
"description": "Loki Logging Driver",
"documentation": "https://github.com/grafana/loki",
"entrypoint": ["/bin/docker-driver"],
"network": {
"type": "host"
},
"interface": {
"types": ["docker.logdriver/1.0"],
"socket": "loki.sock"
},
"env": [
{
"name": "LOG_LEVEL",
"description": "Set log level to output for plugin logs",
"value": "info",
"settable": ["value"]
}
],
"mounts": [
{
"name": "data",
"description": "Optional external pipeline files",
"source": "",
"destination": "/data",
"type": "none",
"options": ["bind", "ro"],
"settable": ["source", "destination"]
}
]
}
31 changes: 31 additions & 0 deletions docs/clients/docker-driver/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,37 @@ Custom labels can be added using the `loki-external-labels`,
`loki-pipeline-stage-file`, `labels`, `env`, and `env-regex` options. See the
next section for all supported options.

## Configure custom pipeline stage file

You can also use custom pipeline stage files, with `loki-pipeline-stage-file` option,
provided from outside of the Loki logging driver container by running Loki with a
mounted volume. To do so, you'll need to disable the plugin, set a volume mount
options and enable the plugin again:

```bash
docker plugin disable loki:latest
docker plugin set loki:latest data.source=/etc/pipelines
docker plugin enable loki:latest
```

In the example above the directory `/etc/pipelines` will be mounted as `/data`
inside the Loki driver container and `loki-pipeline-stage-file` option can be
passed with a custom pipeline configuration, provided there's a file
`/etc/pipelines/mypipeline.yaml` on the host machine:

```bash
docker run --log-driver=loki \
--log-opt loki-url="https://<user_id>:<password>@logs-us-west1.grafana.net/loki/api/v1/push" \
--log-opt loki-pipeline-stage-file=/data/mypipeline.yaml \
grafana/grafana
```

Available options are:

- `data.source`: the source directory the volume
- `data.destination`: the path where the directory is mounted in the container,
and is `/data` by default

## Supported log-opt options

The following are all supported options that the Loki logging driver supports:
Expand Down