-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Stack Monitoring] Use server.publicBaseUrl in Alert links #131154
[Stack Monitoring] Use server.publicBaseUrl in Alert links #131154
Conversation
Pinging @elastic/infra-monitoring-ui (Team:Infra Monitoring UI) |
@@ -344,6 +344,9 @@ export class BaseRule { | |||
if (ccs) { | |||
globalState.push(`ccs:${ccs}`); | |||
} | |||
return `${Globals.app.url}/app/monitoring#/${link}?_g=(${globalState.toString()})`; | |||
|
|||
const baseUrl = Globals.app.url || '(server.publicBaseUrl)'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know how we should react if the setting isn't configured, the default is simply 'undefined'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could use the serverInfo as a fallback, or make it a relative path URL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We expose the kibana base path itself as an action context variable within alerting, and leave it "set" to undefined
if the config is not set. It renders as the empty string. Customers can "optionally" add it via a section block like, so it won't render anything if it's undefined
:
Note you can one-line this multi-line template.
{{#kibanaBaseUrl}}
[head to Kibana]({{kibanaBaseUrl}})
{{/kibanaBaseUrl}}
|
||
const baseUrl = Globals.app.url || '(server.publicBaseUrl)'; | ||
|
||
return `${baseUrl}/app/monitoring#/${link}?_g=(${globalState.toString()})`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the input may be coming from the user (cloud sets the kibanaBaseUrl and it's not overridable by customers), would be best to use something like a relative URL "joiner" (not sure what the current flavor would be). Reason is, the customer may or may not be adding an trailing /
to the URL, and you don't want to generate ...//app/...
(though that might well work in some envs)
I believe I've cheated and used path.join()
for this as well, but ... using a url
or URL
or whatever is correct these days would be better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, if that's the case, shouldn't need a special join!
@elasticmachine merge upstream |
💚 Build SucceededMetrics [docs]
History
To update your PR or re-run it, just comment with: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the changes LGTM 👍
the overall way the state is serialized doesn't look as good, but it's beyond the scope of this PR 😬
…31154) * [Stack Monitoring] Use server.publicBaseUrl in Alert links (elastic#127126) * Use empty string as fallback value Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Fixes #127126
Rather than reading from core.Http. getServerInfo which gives info about the internal host, we use the config setting server.publicBaseUrl which should be set to the public facing URL users reach Kibana on when generating the links in alerts.