Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign up/metrics does not respect --web.external-url configuration #4482
Comments
This comment has been minimized.
This comment has been minimized.
|
I have raised an issue with Helm charts too, just in case this is a configuration error. |
This comment has been minimized.
This comment has been minimized.
|
Can you share your configuration file? This setting configures the Prometheus http server, it has no effect on the scrape logic. |
This comment has been minimized.
This comment has been minimized.
Using the default configuration (https://github.com/helm/charts/blob/master/stable/prometheus/values.yaml) extended with the earlier mentioned configuration.
Point is that the http://gajus.com/prometheus/metrics endpoint exists and http://gajus.com/metrics does not. Since I have configured By the way, Prometheus does actually work as expected. I think it is just the liveness checker that is not aware of the prefix. |
This comment has been minimized.
This comment has been minimized.
|
That sounds like an issue with the Helm chart, Prometheus is working as documented. |
This comment has been minimized.
This comment has been minimized.
Which part of Prometheus is working as expected... ? If by |
This comment has been minimized.
This comment has been minimized.
|
Prometheus has no notion of baseURL, that's a Helm thing. |
This comment has been minimized.
This comment has been minimized.
Doesn't change the question. |
This comment has been minimized.
This comment has been minimized.
|
Yes, Prometheus is working as expected. You told it to scrape /metrics so that's what it tried to do. |
This comment has been minimized.
This comment has been minimized.
Which part of configuration is that? |
This comment has been minimized.
This comment has been minimized.
hoffie
commented
Aug 11, 2018
I am not familiar with helm/charts at all, but if I were to guess, this is the place where another metrics path would have to be configured: No metrics_path is configured there, which means Prometheus takes the default of /metrics. This works as long as --web.external-url is not set. But as soon as it is modified, metrics_path would have to be adjusted (or rather: set at all) as well. Relevant docs: So you are probably right that this is an issue, but Prometheus-wise there is little which can be done as it is a configuration issue. It has therefore be fixed in the configuration files, which seem to be managed by helm/charts in your case. Therefore, It might make sense to open an issue in the helm/charts repository (maybe referencing this one). |
This comment has been minimized.
This comment has been minimized.
Here we go. We are down to the core issue. I am saying that it Prometheus issue that after setting
I have already raised an issue. It is a simple change knowing the requirement. But it isn't clear having read the docs whats the reason these are two separate configurations. |
gajus
closed this
Aug 11, 2018
This comment has been minimized.
This comment has been minimized.
@brian-brazil changing the template to this should fix the display thing <a href="{{.URL | globalURL}}">{{.URL.Scheme}}://{{.URL.Host}}/{{pathPrefix}}{{.URL.Path}}</a><br>but the where is <td class="endpoint">
<a href="{{.URL | globalURL}}">{{.URL.Scheme}}://{{.URL.Host}}{{.URL.Path}}</a><br>
{{range $label, $values := .URL.Query }}
{{range $i, $value := $values}}
<span class="label label-primary">{{$label}}="{{$value}}"</span>
{{end}}
{{end}}
</td>https://github.com/prometheus/prometheus/blob/master/web/ui/templates/targets.html#L43 |
This comment has been minimized.
This comment has been minimized.
|
I got it working after setting the correct apache virtualhost <VirtualHost *:443>
ServerName servername.org
ProxyPreserveHost on
ProxyPass /prom/ http://localhost:9090/prom/
ProxyPassReverse /prom/ http://localhost:9090/prom/
<Location /prom>
AuthType Basic
AuthName "Restricted Content"
AuthUserFile /etc/apache2/.htpasswd
Require valid-user
</Location>
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/servername.org/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/servername.org/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/servername.org/chain.pem
</VirtualHost>prometheus.yml global:
scrape_interval: 10s
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets:
- 'localhost:9090'
metrics_path: '/prom/metrics/'prometheus.service (systemd) [Unit]
Description=Prometheus Server
[Service]
User=prometheus
Group=prometheus
Type=simple
ExecStart=/usr/local/bin/prometheus \
--config.file=/etc/prometheus/prometheus.yml \
--storage.tsdb.path=/var/lib/prometheus/ \
--web.console.templates=/etc/prometheus/consoles \
--web.console.libraries=/etc/prometheus/console_libraries \
--web.external-url=https://servername.org/prom/
ExecReload=/bin/kill -HUP $MAINPID
KillMode=mixed
Restart=always
[Install]
WantedBy=multi-user.targetNow I can get the prometheus explorer at |

gajus commentedAug 8, 2018
Bug Report
What did you do?
I have configured
--web.external-url=http://gajus.com/prometheus/.What did you expect to see?
All Prometheus service endpoints to be prefixed with a path that is part of the
--web.external-url.What did you see instead? Under which circumstances?
The host is respected, but the path is not respected, i.e. Prometheus attempts to look for http://gajus.com/metrics instead of http://gajus.com/prometheus/metrics.
Environment
https://github.com/helm/charts/tree/master/stable/prometheus +