path_prefix not working

80 views
Skip to first unread message

Damian

unread,
Jun 13, 2023, 8:49:52 AM6/13/23
to Prometheus Users
Hello!

I want to send my alerts to alertmanager with path_prefix. It's working properly without path_prefix. But when I try add path_prefix, the page show me "404 page not found". My prometheus version is 2.12.0 and alertmanager is 0.25.0. I've tried a few options. What should I do wrong? Maybe versions are not compatible? My alerting section in prometheus.yaml:

alerting:
  alertmanagers:
  - path_prefix: "my/path/"
    static_configs:
    - targets:
      - localhost:9093

When I'm trying localhost:9093/my/path I see "404 page not found".

I also tried on my virtual machine with prometheus version 2.32.1 and alertmanager version 0.23.0 and have the same issue.

Thank you in advance for hints.

Regards,
Damian

Brian Candler

unread,
Jun 13, 2023, 9:34:27 AM6/13/23
to Prometheus Users
1. You have to configure your alertmanager to listen on /my/path
2. I believe you need the leading slash.

Here are some working configs taken straight off my system, where the alertmanager path prefix is "/alertmanager"

For alertmanager itself, run with this flag:

alertmanager ... --web.external-url=http://prometheus.mydomain.com:9093/alertmanager

(You can test this using "curl localhost:9093/alertmanager/metrics")

For prometheus:

alerting:
  alertmanagers:
  - scheme: http
    path_prefix: /alertmanager
    static_configs:
      - targets:
          - "127.0.0.1:9093"

scrape_configs:
  - job_name: alertmanager
    scrape_interval: 1m
    metrics_path: /alertmanager/metrics
    static_configs:
      - targets: ['localhost:9093']

Damian

unread,
Jun 14, 2023, 2:53:39 AM6/14/23
to Prometheus Users
Hello Brian,

Thank you very much, it is working properly now :)

Have a nice day,
Damian
Reply all
Reply to author
Forward
0 new messages