Skip to content

Commit e9f1005

Browse files
authored
feat(cortex-nginx): optional override push endpoint (#522)
* feat(cortex-nginx): provide optional override push endpoint Signed-off-by: locmai <[email protected]> * chore: update README.md and CHANGELOG.md Signed-off-by: locmai <[email protected]> * fix: make it DRY and elegant Signed-off-by: locmai <[email protected]> --------- Signed-off-by: locmai <[email protected]>
1 parent d98478c commit e9f1005

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## master / unreleased
44

55
* [DEPENDENCY] Update quay.io/cortexproject/cortex Docker tag to v1.19.0 #521
6+
* [ENHANCEMENT] Add `nginx.config.override_push_endpoint` field to override push endpoint in the nginx configuration #522
67

78
## 2.5.0 / 2025-01-17
89

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,7 @@ Kubernetes: `^1.19.0-0`
440440
| nginx.&ZeroWidthSpace;config.&ZeroWidthSpace;dnsTTL | string | `"15s"` | Including the valid parameter to the `resolver` directive to re-resolve names every `dnsTTL` seconds/minutes |
441441
| nginx.&ZeroWidthSpace;config.&ZeroWidthSpace;httpSnippet | string | `""` | arbitrary snippet to inject in the http { } section of the nginx config |
442442
| nginx.&ZeroWidthSpace;config.&ZeroWidthSpace;mainSnippet | string | `""` | arbitrary snippet to inject in the top section of the nginx config |
443+
| nginx.&ZeroWidthSpace;config.&ZeroWidthSpace;override_push_endpoint | string | `""` | |
443444
| nginx.&ZeroWidthSpace;config.&ZeroWidthSpace;serverSnippet | string | `""` | arbitrary snippet to inject in the server { } section of the nginx config |
444445
| nginx.&ZeroWidthSpace;config.&ZeroWidthSpace;setHeaders | object | `{}` | |
445446
| nginx.&ZeroWidthSpace;config.&ZeroWidthSpace;upstream_protocol | string | `"http"` | protocol for the communication with the upstream |

templates/nginx/nginx-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,16 @@ data:
8787
location = /all_user_stats {
8888
proxy_pass {{ .Values.nginx.config.upstream_protocol }}://{{ template "cortex.fullname" . }}-distributor.{{ $rootDomain }}$request_uri;
8989
}
90-
90+
{{- $push_endpoint := .Values.nginx.config.override_push_endpoint | default (printf "%s://%s-distributor.%s" .Values.nginx.config.upstream_protocol (include "cortex.fullname" .) $rootDomain) }}
91+
# Push API endpoints
9192
location = /api/prom/push {
92-
proxy_pass {{ .Values.nginx.config.upstream_protocol }}://{{ template "cortex.fullname" . }}-distributor.{{ $rootDomain }}$request_uri;
93+
proxy_pass {{ $push_endpoint }}$request_uri;
9394
}
9495
9596
## New Remote write API. Ref: https://cortexmetrics.io/docs/api/#remote-write
9697
location = /api/v1/push {
97-
proxy_pass {{ .Values.nginx.config.upstream_protocol }}://{{ template "cortex.fullname" . }}-distributor.{{ $rootDomain }}$request_uri;
98+
proxy_pass {{ $push_endpoint }}$request_uri;
9899
}
99-
100100
{{- end }}
101101
102102
{{- if .Values.alertmanager.enabled }}

values.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,6 +1239,10 @@ nginx:
12391239
dnsTTL: "15s"
12401240
# -- Enables all access logs from nginx, otherwise ignores 2XX and 3XX status codes
12411241
verboseLogging: true
1242+
1243+
## -- Optional: Override the URL for push endpoints (/api/prom/push and /api/v1/push)
1244+
## If not specified, the default URL will be used, corresponding to the distributor service URL
1245+
override_push_endpoint: ""
12421246
image:
12431247
repository: nginx
12441248
tag: 1.23

0 commit comments

Comments
 (0)