Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alertmanager PathPrefix not used by prometheus #2287

Closed
groob opened this Issue Dec 16, 2016 · 6 comments

Comments

Projects
None yet
3 participants
@groob
Copy link

groob commented Dec 16, 2016

What did you do?

Used alertmanager config below in my prometheus.yml file

alerting:
  alertmanagers:
  - scheme: http
    path_prefix: "/alertmanager"
    static_configs:
    - targets:
        - "alertmanager.default.svc.cluster.local"

What did you expect to see?

A successful alert sent to the alertmanager.

What did you see instead? Under which circumstances?

time="2016-12-16T02:32:37Z" level=error msg="Error sending alerts: bad response status 404 Not Found" alertmanager="http://alertmanager.default.svc.cluster.local:80/api/v1/alerts" count=2 source="notifier.go:335"
  • Prometheus version:
prometheus, version 1.4.1 (branch: master, revision: 2a89e8733f240d3cd57a6520b52c36ac4744ce12)
  build user:       root@e685d23d8809
  build date:       20161128-09:59:22
  go version:       go1.7.3* 

I'm able to send alerts using curl successfully

curl -H "Content-Type: application/json" -d '[{"labels":{"alertname":"TestAlert1"}}]' alertmanager.default.svc.cluster.local/alertmanager/api/v1/alerts

If I remove the -web.externalurl flag from alertmanager, prometheus also succesfuly sends alerts.

@groob

This comment has been minimized.

Copy link
Author

groob commented Dec 16, 2016

I tried debugging this myself. The path_prefix appears to load correctly. And alertmanagerFromGroup
https://github.com/prometheus/prometheus/blob/master/notifier/notifier.go#L477
also seems to correctly add the prefix from the config.

But I couldn't find out where Sync() is called from https://github.com/prometheus/prometheus/blob/master/notifier/notifier.go#L442

@brancz

This comment has been minimized.

Copy link
Member

brancz commented Dec 16, 2016

Sync() is part of the Syncer interface and called here. @fabxc is probably the one who will find the problem most quickly as he implemented the feature and is most familiar with the discovery implementation as well. I'll try to find it as well.

@groob

This comment has been minimized.

Copy link
Author

groob commented Dec 16, 2016

Wow, sorry. this actually turned out to be user error.

My yaml looked like

alerting:
  alertmanagers:
  - path_prefix: "/alertmanager"
  - scheme: http
    static_configs:
    - targets:
        - "alertmanager.default.svc.cluster.local"

Then I fixed it, but didn't reload the config, and spent a good 2 hours debugging this.

On the plus side, I now understand how a good part of the notifier and config loading code works.

@groob groob closed this Dec 16, 2016

@nelsonfassis

This comment has been minimized.

Copy link

nelsonfassis commented Feb 26, 2018

And how does it look now @groob ? I'm having the same issue as you.

` ```
alerting:
alertmanagers:
- scheme: http
path_prefix: "/alertmanager"
static_configs:
- targets:
- alertmanager-0.alertmanager:9093
- alertmanager-1.alertmanager:9093

`
@nelsonfassis

This comment has been minimized.

Copy link

nelsonfassis commented Feb 27, 2018

Found the issue to be with path_prefix syntax.
It should be like:

  • path_prefix: "alertmanager/"
    Changed the "/" to the end and it works for me now.
@lock

This comment has been minimized.

Copy link

lock bot commented Mar 22, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Mar 22, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.