feat(logger/loki): Support for tenants when running Loki in multi-tenant mode (#477)

This commit is contained in:
iLLeniumStudios
2024-01-15 02:10:08 +01:00
committed by GitHub
parent 2ad3503985
commit 5dfd14d69d

View File

@@ -131,6 +131,7 @@ if service == 'loki' then
local lokiUser = GetConvar('loki:user', '') local lokiUser = GetConvar('loki:user', '')
local lokiPassword = GetConvar('loki:password', GetConvar('loki:key', '')) local lokiPassword = GetConvar('loki:password', GetConvar('loki:key', ''))
local lokiEndpoint = GetConvar('loki:endpoint', '') local lokiEndpoint = GetConvar('loki:endpoint', '')
local lokiTenant = GetConvar('loki:tenant', '')
local startingPattern = '^http[s]?://' local startingPattern = '^http[s]?://'
local headers = { local headers = {
['Content-Type'] = 'application/json' ['Content-Type'] = 'application/json'
@@ -140,6 +141,10 @@ if service == 'loki' then
headers['Authorization'] = getAuthorizationHeader(lokiUser, lokiPassword) headers['Authorization'] = getAuthorizationHeader(lokiUser, lokiPassword)
end end
if lokiTenant ~= '' then
headers['X-Scope-OrgID'] = lokiTenant
end
if not lokiEndpoint:find(startingPattern) then if not lokiEndpoint:find(startingPattern) then
lokiEndpoint = 'https://' .. lokiEndpoint lokiEndpoint = 'https://' .. lokiEndpoint
end end