Skip to content

Commit

Permalink
Docker driver: Allow to provision external pipeline files to plugin (#…
Browse files Browse the repository at this point in the history
…2054)

* Use latest Alpine version

* Allow to provision external pipeline files to plugin

* Add custom pipeline documentation

* Untabify on reviewer request

Co-authored-by: Mike Futerko <mike@maytech.net>
  • Loading branch information
bkmit and mfuterko authored May 8, 2020
1 parent fcb4c76 commit f5b9cff
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 20 deletions.
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

0 comments on commit f5b9cff

Please sign in to comment.