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

Adds tenant-id for docker driver. #1414

Merged
merged 1 commit into from
Dec 13, 2019
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
1 change: 1 addition & 0 deletions cmd/docker-driver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ To specify additional logging driver options, you can use the --log-opt NAME=VAL
| `loki-max-backoff` | No | `10s` | The maximum amount of time to wait before retrying a batch. Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
| `loki-retries` | No | `10` | The maximum amount of retries for a log batch.
| `loki-pipeline-stage-file` | No | | The location of a pipeline stage configuration file ([example](./pipeline-example.yaml)). Pipeline stages allows to parse log lines to extract more labels. [see documentation](../../docs/logentry/processing-log-lines.md)
| `loki-tenant-id` | No | | Set the tenant id (http header`X-Scope-OrgID`) when sending logs to Loki. It can be overrides by a pipeline stage.
| `loki-tls-ca-file` | No | | Set the path to a custom certificate authority.
| `loki-tls-cert-file` | No | | Set the path to a client certificate file.
| `loki-tls-key-file` | No | | Set the path to a client key.
Expand Down
8 changes: 8 additions & 0 deletions cmd/docker-driver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const (
cfgMaxBackoffKey = "loki-max-backoff"
cfgMaxRetriesKey = "loki-retries"
cfgPipelineStagesKey = "loki-pipeline-stage-file"
cfgTenantIDKey = "loki-tenant-id"

swarmServiceLabelKey = "com.docker.swarm.service.name"
swarmStackLabelKey = "com.docker.stack.namespace"
Expand Down Expand Up @@ -98,6 +99,7 @@ func validateDriverOpt(loggerInfo logger.Info) error {
case cfgMaxBackoffKey:
case cfgMaxRetriesKey:
case cfgPipelineStagesKey:
case cfgTenantIDKey:
case "labels":
case "env":
case "env-regex":
Expand Down Expand Up @@ -189,6 +191,12 @@ func parseConfig(logCtx logger.Info) (*config, error) {
clientConfig.Client.ProxyURL.URL = proxyURL
}

// parse tenant id
tenantID, ok := logCtx.Config[cfgTenantIDKey]
if ok && tenantID != "" {
clientConfig.TenantID = tenantID
}

// parse external labels
extlbs, ok := logCtx.Config[cfgExternalLabelsKey]
if !ok {
Expand Down