What's the correct REGEX for the allowlist in app.yml?

What is the correct format of _REGEX in the app.yml file?

Is this correct?

  DISCOURSE_PROMETHEUS_TRUSTED_IP_ALLOWLIST_REGEX: "(35.247.25.222|34.83.69.98|35.192.150.184)"

I’m will be attempting to list all IP’s used by grafana.com for scraping (https://grafana.com/api/hosted-grafana/source-ips.txt)

1 Like

Looks more or less right. You may want to escape .s though and add ^ and $

1 Like

I probably should have added that it doesn’t work…

I have tried adding my machine’s IP address and it cannot access the metrics without logging into Discourse.

I take your point about the escaping the dot. In this case the regex will only be supplied with IP addresses, so escaping the dot doesn’t change the result but does make it harder to read. Also, grafana.com use up to 100 IP’s to pull data so this line might become too long…

1 Like

Seems that $ is being escaped in the translation from containers/<container>.conf to the container environment.

Container config:

  ## Allowed IPs for Prometheus metrics
  DISCOURSE_PROMETHEUS_TRUSTED_IP_ALLOWLIST_REGEX: "^10.20.20.5$"

Container environment.

declare -x DISCOURSE_PROMETHEUS_TRUSTED_IP_ALLOWLIST_REGEX="^10.20.20.5\$"
2 Likes