Do not redirect when creating custom metric from metrics dashboard
Problem to solve
The API to create a custom metric redirects to the prometheus integration settings page on success. However the API is called from two places: the prometheus integration settings page and the metrics dashboard page. When called from the metrics dashboard page, we do not want to redirect the user to the prometheus integration settings page since this will require the user to navigate all the way back to the metrics dashboard to see the query result.
Intended users
Further details
Proposal
If we want the redirect to happen when a custom metric is created on the prometheus integration settings page, and no redirect should happen on the metrics dashboard page, we can add support for a json format response in the API and call the json format API from the custom metrics page.
- Custom metric creation on the prometheus integration settings page will continue to use the html format and the response will be a redirect in case of success. In case of failure it renders the
new
template. (unchanged from current behavior) - The custom metric creation API call from the metrics dashboard page can use json format. On success it will simply return
{ status: 'success', message: 'Metric was successfully added.' }
. On failure, we can try returning an array of errors, or just a failure message.
Permissions and Security
Documentation
Testing
What does success look like, and how can we measure that?
When a custom metric is successfully created from the metrics dashboard page, the user is not redirected and stays on the metrics dashboard page.
When a custom metric is successfully created from the prometheus integration settings page, the user is redirected back to the prometheus integration settings page.