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
Alerting: handle folder names with / safely #42947
Comments
|
@gillesdemey @peterholmberg can you have a look at possibly fixing this in the UI? This is high priority as CRUD operations for alerting rules are broken for anyone using a namespace with a |
|
I've had a look at this and it looks like we are properly encoding the I'm not quite sure if there is anything we can do on the front-end without involving a change on the backend to resolve this one unless we transform the At first glance it looks like we are a transparent proxy towards Cortex (https://cortexmetrics.io/docs/api/#get-rule-group) – perhaps the bug also occurs there? |
|
@gillesdemey I agree grafana is properly encoding the |
|
Thanks for investigating @chaudyg – I've dug a bit deeper and can indeed confirm that the encoded We will look in to disallowing the We also believe that there is a valid concern when it comes to the Cortex API interface – creating a
{"name":"foo/bar","rules":[{"record":"testing123","labels":{},"expr":"1"}]}This will in turn create a group named |
|
After some help from @pstibrany it seems like the issue is not in Cortex but perhaps in a proxy or gateway that sits in front of the Cortex setup, creating group names and deleting them via the HTTP API works fine when sent to a local Cortex setup. |
|
Perhaps the decoding is happening somewhere in the https://github.com/grafana/backend-enterprise project, @JohnnyQQQQ investigated it and it may be decoded in the reverse proxy. |
|
We talked about this in the weekly. The consensus is that unescaping an URL is expected behavior. We also agree that a user should be able to use whatever they want as a name. The main problem we have here is that we will always need to provide the This is also a problem for users running Grafana behind a proxy, as most proxies will unescape the URL before forwarding the request as mentioned in the comments above. As the plain text name is used as the unique identifier, we don't have any way around it. I think we have a few options here:
|
|
Since we don't have a UID to work with and sluggifying requires a migration, the only reasonable proposal left is to pass the name of the group you wish to delete either via the body (but some server implementations might ignore Those should not be automatically decoded by proxies. Either proposal would require a change in the Cortex API since it only allows deleting groupnames via the name in the path and proxies could always decode it like @JohnnyQQQQ mentioned. |
|
This was discussed further with the engineering team – consensus is not to try and fix this in the current API of Cortex / Loki / Grafana and to make sure we configure all proxies properly instead. We are instead spending our effort on an API redesign where this issue will be resolved. |
|
By adding validation, we can deal with the slashes in alert rules names, namespaces and groups but not in folders. |
What happened:
As originally reported in #40979 and followed up by https://github.com/grafana/hosted-grafana/issues/1667 hosted grafana alerting handles URLs in a way that breaks when attempting to use a namespace (folder) with
/in it. We should consider ways to handle namespaces structured like this more safely while still allowing users to have namespaces that contain/Possible approaches include:
The text was updated successfully, but these errors were encountered: