Closed mrjones-plip closed 5 hours ago
tl;dr - i propose we force scrapes of express metrics to be over TLS. I've added a PR to this extent.
Soooo - this is tricky. On a local docker helper instance I had both port 10091
running with http
and port 10454
running https
. By default express metrics runs a regex and drops the https
(or http
) used in cht-instances.yml
- check out the regex
line:
- job_name: cht-express-metrics
metrics_path: /api/v1/express-metrics
file_sd_configs:
- files:
- '/etc/prometheus/cht-instances.yml'
relabel_configs:
- source_labels: [__address__]
regex: "(?:https?:\\/\\/|)(?:www\\.|)(.*?)(?:\\/|)$"
target_label: instance
replacement: "$1"
- source_labels: [instance]
target_label: __address__
So what happens in this default scenario is
cht-instances.yml
as https://192-168-68-26.local-ip.medicmobile.org:10454
https
and makes this URL: http://192-168-68-26.local-ip.medicmobile.org:10454/api/v1/express-metrics
server returned HTTP status 497
- translation - bruh - i can't speak http
to an https
serverThe fix is one of these then:
scheme: "https"
- which forces ALL requests to go to https
- OR `http://192-168-68-26.local-ip.medicmobile.org:10091
in the cht-instances.yml
file - but then in dev I had to comment out the redirect we have on the http
port add and add the server.conf
include and then it could get both the JSON monitoring endpoint AND the express metrics. but this is so not real world that it's uselessby going with option 1 (scheme: "https"
) we're breaking it in dev environment for not docker helper, but it will work in docker helper, which seems common enough.
i'll see where I get with the PR!
cc @jkuester - but I'm tapping Kenn for the PR review!
A production instance recently had port
80
accidentally stop working. As it turns out, API Express metrics always defaults to80
and then gets redirected to port443
where the metrics actually are served. Without the redirect, the metrics fail.Related:
Checking production watchdog instance that Medic runs, I see all requests are hitting port
80
first: