Allow configuring CORS origin.
Fixes: PROD-35204
Change-Id: Ib717ca16eb8a6e58da663a47f5bc65e7c5bdb14c
diff --git a/metadata/service/server/container.yml b/metadata/service/server/container.yml
index 222e703..29de13d 100644
--- a/metadata/service/server/container.yml
+++ b/metadata/service/server/container.yml
@@ -10,10 +10,12 @@
prometheus_scrape_interval: "15s"
prometheus_scrape_timeout: "15s"
prometheus_storage_retention: "360h"
+ prometheus_cors_origin: ".*"
prometheus:
server:
enabled: true
is_container: true
+ cors_origin: ${_param:prometheus_cors_origin}
use_grains:
target: true
recording: true
diff --git a/metadata/service/server/standalone.yml b/metadata/service/server/standalone.yml
index 40dbc7f..921001c 100644
--- a/metadata/service/server/standalone.yml
+++ b/metadata/service/server/standalone.yml
@@ -9,10 +9,12 @@
prometheus_scrape_interval: "15s"
prometheus_storage_retention: "4320h"
prometheus_server_bind_port: 9090
+ prometheus_cors_origin: ".*"
prometheus:
server:
enabled: true
is_container: false
+ cors_origin: ${_param:prometheus_cors_origin}
use_grains:
target: false
recording: false
diff --git a/prometheus/files/server/default b/prometheus/files/server/default
index ee921da..f07ed8d 100644
--- a/prometheus/files/server/default
+++ b/prometheus/files/server/default
@@ -3,3 +3,4 @@
PROMETHEUS_DATA_DIR={{ server.dir.data }}
PROMETHEUS_BIND_ADDRESS={{ server.bind.address }}:{{ server.bind.port }}
PROMETHEUS_STORAGE_LOCAL_RETENTION={{ server.storage.local.retention }}
+PROMETHEUS_CORS_ORIGIN_REGEX="{{ server.get("cors_origin", ".*") }}"
diff --git a/prometheus/files/server/service b/prometheus/files/server/service
index c1bc00e..4fd04fc 100644
--- a/prometheus/files/server/service
+++ b/prometheus/files/server/service
@@ -10,6 +10,7 @@
Restart=on-failure
ExecStart=/usr/bin/prometheus \
--web.listen-address=${PROMETHEUS_BIND_ADDRESS} \
+ --web.cors.origin="${PROMETHEUS_CORS_ORIGIN_REGEX}" \
--config.file=${PROMETHEUS_CONFIG_DIR}/prometheus.yml \
--storage.tsdb.path=${PROMETHEUS_DATA_DIR} \
--storage.tsdb.retention=${PROMETHEUS_STORAGE_LOCAL_RETENTION}