Skip to content

Commit

Permalink
feat(fluentd-plugin-datadog-loki): support custom http headers (#14299)
Browse files Browse the repository at this point in the history
Co-authored-by: Trevor Whitney <trevorjwhitney@gmail.com>
  • Loading branch information
AndrewChubatiuk and trevorwhitney authored Sep 30, 2024
1 parent 720c303 commit e59035e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions clients/cmd/fluentd/lib/fluent/plugin/out_loki.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ class LogPostError < StandardError; end
desc 'TLS: disable server certificate verification'
config_param :insecure_tls, :bool, default: false

desc 'Custom HTTP headers'
config_param :custom_headers, :hash, default: {}

desc 'Loki tenant id'
config_param :tenant, :string, default: nil

Expand Down Expand Up @@ -232,6 +235,9 @@ def loki_http_request(body, tenant)
req = Net::HTTP::Post.new(
@uri.request_uri
)
@custom_headers.each do |key, value|
req.add_field(key, value)
end
req.add_field('Content-Type', 'application/json')
req.add_field('Authorization', "Bearer #{@auth_token_bearer}") unless @auth_token_bearer.nil?
req.add_field('X-Scope-OrgID', tenant) if tenant
Expand Down

0 comments on commit e59035e

Please sign in to comment.