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

Re-add full -web.external-url functionality #289

Merged
merged 1 commit into from
Mar 31, 2016
Merged

Re-add full -web.external-url functionality #289

merged 1 commit into from
Mar 31, 2016

Conversation

juliusv
Copy link
Member

@juliusv juliusv commented Mar 30, 2016

Fixes #212

@juliusv
Copy link
Member Author

juliusv commented Mar 30, 2016

@fabxc @mrwacky42

RegisterWeb(router)
api.Register(router.WithPrefix("/api"))
RegisterWeb(router.WithPrefix(amURL.Path))
api.Register(router.WithPrefix(amURL.Path + "/api"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

path.Join

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, we're usually just +-ing together pre-sanitized paths in Prometheus, including in your own https://github.com/prometheus/common/blob/master/route/route.go. Not that it matters much, but maybe we should keep it consistent?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

path.Join does not work well for URLs in general, I usually decide against using it.

https://play.golang.org/p/xGEOg3Gw7p

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

path.Join is fine in general, but can only be applied to paths, not full URLs. Otherwise it'll get rid of duplicated slashes and do all kinds of other things you might not want.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't side effects fun?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this is not an issue here though, since we're dealing with paths only. Both path.Join or + would work fine, just that I think + is what we usually use in Prometheus in this situation.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A full URL is not a path. Of course that doesn't work and it shouldn't. But this is a path (url.URL.Path) :)

Do as you wish. But it would be correct to apply here and keep things working, when sanitization somewhere up the chain changes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Na gut, path.Join for @fabxc :)

controller: 'SilencesCtrl',
reloadOnSearch: false
}).
when('/status', {
templateUrl: '/app/partials/status.html',
templateUrl: 'app/partials/status.html',
controller: 'StatusCtrl'
}).
otherwise({
redirectTo: '/alerts'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This redirect to /alerts won't work correctly when proxying to a different base URL.
(In our case /alertmanager...)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can tell, this all works fine for me. Have you tested it? E.g. I run:

./alertmanager -web.external-url=http://localhost:9093/foo/bar

Going to http://localhost:9093/foo/bar correctly redirects me to http://localhost:9093/foo/bar/#/alerts.

Note that this is an angular route name that appears in the hash part of the URL, and is thus not part of the normal path.

Or am I misunderstanding something?

@grobie
Copy link
Member

grobie commented Mar 31, 2016

👍

@juliusv juliusv merged commit d7c0b7f into master Mar 31, 2016
@juliusv juliusv deleted the ext-url branch March 31, 2016 23:46
@mrwacky42
Copy link

Doesn't this merit a 0.1.2 release? Our configuration won't work if we can't proxy.
And if we can't upgrade Alertmanager, we can't upgrade Prometheus.
See my sad panda face: 😦

@flecno
Copy link

flecno commented May 27, 2016

hey... when do you will release this fix?

@juliusv
Copy link
Member Author

juliusv commented May 27, 2016

@fabxc would probably know when a next release is planned for the Alertmanager.

@fabxc
Copy link
Contributor

fabxc commented May 27, 2016

-web.external-url is hacky implementation-wise in many ways and then there's prometheus/prometheus#1191 that suggests we need something different to generally work anyway.

I'd like some ideas or opinions on that.
Not very keen to release features breaking in a few weeks.

@flecno
Copy link

flecno commented May 27, 2016

Thanks for your fast reply... You are right.. it's a little bit hacky... Why you are using angular for this frontend? Mhm. But I need this fix to get alertmanger working behind a reverser proxy. I should build my own release for now...
After all: THANK YOU FOR YOUR BEAUTIFUL prometheus!

@fabxc
Copy link
Contributor

fabxc commented May 27, 2016

It's hacky independent of the frontend. Look at the Prometheus code for comparison...
There's a good chance we will release a version with the storage changes to resolve problems people are encountering with SQLite persistence. In that case the flag would be included again soon.

Still would prefer a counter-proposal.

@fabxc
Copy link
Contributor

fabxc commented Jun 27, 2016

FYI, @flecno @mrwacky42 there was a 0.2 release that contains these changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants