Skip to content

Commit

Permalink
Adds tenant-id for docker driver. (#1414)
Browse files Browse the repository at this point in the history
Signed-off-by: Cyril Tovena <[email protected]>
  • Loading branch information
cyriltovena authored and owen-d committed Dec 13, 2019
1 parent 4fea713 commit b1e232c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
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

0 comments on commit b1e232c

Please sign in to comment.