Skip to content
96 changes: 96 additions & 0 deletions production/helm/loki/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,9 @@ http {
{{- end }}

location = / {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- . | nindent 6 }}
{{- end }}
return 200 'OK';
auth_basic off;
}
Expand Down Expand Up @@ -888,120 +891,207 @@ http {

{{- if .Values.loki.ui.gateway.enabled }}
location ^~ /ui {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- . | nindent 6 }}
{{- end }}
proxy_pass {{ $distributorUrl }}$request_uri;
}
{{- end }}

# Distributor
location = /api/prom/push {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- . | nindent 6 }}
{{- end }}
proxy_pass {{ $distributorUrl }}$request_uri;
}
location = /loki/api/v1/push {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- . | nindent 6 }}
{{- end }}
proxy_pass {{ $distributorUrl }}$request_uri;
}
location = /distributor/ring {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- . | nindent 6 }}
{{- end }}
proxy_pass {{ $distributorUrl }}$request_uri;
}
location = /otlp/v1/logs {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- . | nindent 6 }}
{{- end }}
proxy_pass {{ $distributorUrl }}$request_uri;
}

# Ingester
location = /flush {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- . | nindent 6 }}
{{- end }}
proxy_pass {{ $ingesterUrl }}$request_uri;
}
location ^~ /ingester/ {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- . | nindent 6 }}
{{- end }}
proxy_pass {{ $ingesterUrl }}$request_uri;
}
location = /ingester {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- . | nindent 6 }}
{{- end }}
internal; # to suppress 301
}

# Ring
location = /ring {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- . | nindent 6 }}
{{- end }}
proxy_pass {{ $ingesterUrl }}$request_uri;
}

# MemberListKV
location = /memberlist {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- . | nindent 6 }}
{{- end }}
proxy_pass {{ $ingesterUrl }}$request_uri;
}

# Ruler
location = /ruler/ring {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- . | nindent 6 }}
{{- end }}
proxy_pass {{ $rulerUrl }}$request_uri;
}
location = /api/prom/rules {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- . | nindent 6 }}
{{- end }}
proxy_pass {{ $rulerUrl }}$request_uri;
}
location ^~ /api/prom/rules/ {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- . | nindent 6 }}
{{- end }}
proxy_pass {{ $rulerUrl }}$request_uri;
}
location = /loki/api/v1/rules {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- . | nindent 6 }}
{{- end }}
proxy_pass {{ $rulerUrl }}$request_uri;
}
location ^~ /loki/api/v1/rules/ {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- . | nindent 6 }}
{{- end }}
proxy_pass {{ $rulerUrl }}$request_uri;
}
location = /prometheus/api/v1/alerts {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- . | nindent 6 }}
{{- end }}
proxy_pass {{ $rulerUrl }}$request_uri;
}
location = /prometheus/api/v1/rules {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- . | nindent 6 }}
{{- end }}
proxy_pass {{ $rulerUrl }}$request_uri;
}

# Compactor
location = /compactor/ring {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- . | nindent 6 }}
{{- end }}
proxy_pass {{ $compactorUrl }}$request_uri;
}
location = /loki/api/v1/delete {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- . | nindent 6 }}
{{- end }}
proxy_pass {{ $compactorUrl }}$request_uri;
}
location = /loki/api/v1/cache/generation_numbers {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- . | nindent 6 }}
{{- end }}
proxy_pass {{ $compactorUrl }}$request_uri;
}

# IndexGateway
location = /indexgateway/ring {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- . | nindent 6 }}
{{- end }}
proxy_pass {{ $indexGatewayUrl }}$request_uri;
}

# QueryScheduler
location = /scheduler/ring {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- . | nindent 6 }}
{{- end }}
proxy_pass {{ $schedulerUrl }}$request_uri;
}

# Config
location = /config {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- . | nindent 6 }}
{{- end }}
proxy_pass {{ $ingesterUrl }}$request_uri;
}

{{- if and .Values.enterprise.enabled .Values.enterprise.adminApi.enabled }}
# Admin API
location ^~ /admin/api/ {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- . | nindent 6 }}
{{- end }}
proxy_pass {{ $backendUrl }}$request_uri;
}
location = /admin/api {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- . | nindent 6 }}
{{- end }}
internal; # to suppress 301
}
{{- end }}


# QueryFrontend, Querier
location = /api/prom/tail {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- . | nindent 6 }}
{{- end }}
proxy_pass {{ $queryFrontendUrl }}$request_uri;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
location = /loki/api/v1/tail {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- . | nindent 6 }}
{{- end }}
proxy_pass {{ $queryFrontendUrl }}$request_uri;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
location ^~ /api/prom/ {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- . | nindent 6 }}
{{- end }}
proxy_pass {{ $queryFrontendUrl }}$request_uri;
}
location = /api/prom {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- . | nindent 6 }}
{{- end }}
internal; # to suppress 301
}
# if the X-Query-Tags header is empty, set a noop= without a value as empty values are not logged
Expand All @@ -1010,11 +1100,17 @@ http {
set $query_tags "noop=";
}
location ^~ /loki/api/v1/ {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- . | nindent 6 }}
{{- end }}
# pass custom headers set by Grafana as X-Query-Tags which are logged as key/value pairs in metrics.go log messages
proxy_set_header X-Query-Tags "${query_tags},user=${http_x_grafana_user},dashboard_id=${http_x_dashboard_uid},dashboard_title=${http_x_dashboard_title},panel_id=${http_x_panel_id},panel_title=${http_x_panel_title},source_rule_uid=${http_x_rule_uid},rule_name=${http_x_rule_name},rule_folder=${http_x_rule_folder},rule_version=${http_x_rule_version},rule_source=${http_x_rule_source},rule_type=${http_x_rule_type}";
proxy_pass {{ $queryFrontendUrl }}$request_uri;
}
location = /loki/api/v1 {
{{- with .Values.gateway.nginxConfig.locationSnippet }}
{{- . | nindent 6 }}
{{- end }}
internal; # to suppress 301
}

Expand Down
2 changes: 2 additions & 0 deletions production/helm/loki/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1177,6 +1177,8 @@ gateway:
# -- Allows appending custom configuration to the http block, passed through the `tpl` function to allow templating
httpSnippet: >-
{{ if .Values.loki.tenants }}proxy_set_header X-Scope-OrgID $remote_user;{{ end }}
# -- Allows appending custom configuration inside every location block, useful for authentication or setting headers that are not inherited from the server block.
locationSnippet: ""
# -- Allows customizing the `client_max_body_size` directive
clientMaxBodySize: 4M
# -- Whether ssl should be appended to the listen directive of the server block or not.
Expand Down
Loading