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

AI-generated summary

Users are discussing the correct REGEX format for the DISCOURSE_PROMETHEUS_TRUSTED_IP_ALLOWLIST_REGEX in the app.yml file. andy212 asked for confirmation on the format and provided an example, which sam said “looks more or less right” but suggested escaping . and adding ^ and $. However, andy212 reported that the suggested format did not work, and dschaper pointed out that the $ character is being escaped during translation from the container config to the container environment.

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)

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

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…

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\$"