Hello,
I just added a /metrics endpoint to my app to leverage the prometheus instance of Fly. But I don’t want to expose it publicly.
For Elixir there is a library to bind conditions to a plug (e.g. authentication or whatever can be passed). What’s the best practice way here at Fly to expose a metrics endpoint without exposing it publicly? Thanks.
Hi @mathiasn
A fairly easy way is to expose metrics on a different port that is not exposed publicly in fly.toml, only in the metrics section.
The fly metrics scraper will still be able to access the port and it won’t be publicly accessible.
2 Likes
@charsleysa can you explain your solution? this is my fly.toml
[http_service]
internal_port = 3000
force_https = true
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 0
processes = ["app"]
[metrics]
port = 3000
path = "/metrics"
processes = ["app"]
[env]
PORT="3000"
HOSTNAME="0.0.0.0"
the app (nodejs) is serving the metrics using prom-client
,
Added metrics