Skip to content
Closed
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
5 changes: 5 additions & 0 deletions loki/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,11 @@ func (c *Client) send(ctx context.Context, tenantID string, buf []byte) (int, er
req.Header.Set("X-Scope-OrgID", tenantID)
}

// Authorization header to send if you are using a gateway like https://github.com/observatorium/api for example
if c.cfg.Authorization != "" {
req.Header.Set("Authorization", c.cfg.Authorization)
}

resp, err := c.client.Do(req)
if err != nil {
return -1, err
Expand Down
3 changes: 3 additions & 0 deletions loki/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ type Config struct {
// single tenant mode)
TenantID string `yaml:"tenant_id"`

// The authorization header to send to Loki gateway
Authorization string `yaml:"authorization_header"`

// Use Loki JSON api as opposed to the snappy protobuf.
EncodeJson bool `yaml:"encode_json"`
}
Expand Down
4 changes: 4 additions & 0 deletions loki/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ url: http://localhost:3100/loki/api/v1/push

var clientCustomConfig = `
url: http://localhost:3100/loki/api/v1/push
tenant_id: tenant-id
authorization_header: Bearer XXX
backoff_config:
max_retries: 20
min_period: 5s
Expand Down Expand Up @@ -60,6 +62,8 @@ func Test_Config(t *testing.T) {
URL: urlutil.URLValue{
URL: u,
},
TenantID: "tenant-id",
Authorization: "Bearer XXX",
BackoffConfig: backoff.BackoffConfig{
MaxBackoff: 1 * time.Minute,
MaxRetries: 20,
Expand Down