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
Graphite: Fix autocomplete when tags are not available #31680
Graphite: Fix autocomplete when tags are not available #31680
Conversation
@@ -13,6 +14,7 @@ const graphiteVersions = [ | |||
{ label: '1.0.x', value: '1.0' }, | |||
{ label: '1.1.x', value: '1.1' }, | |||
]; | |||
const DEFAULT_GRAPHITE_VERSION = graphiteVersions[2]; |
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.
Nitpick: probably makes sense to have last(graphiteVersions)
so that when new version is added it's automatically the latest version
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've extracted the list to graphite_versions.ts
to use the default (now last from the list) in datasource.ts
and ConfigEditor.tsx
In some configurations graphite-web fail to return the list of tags. It shouldn't however prevent displaying list of metrics (which is concatenated with tags).
The version of Graphite is preselected in the dropdown but was not saved in jsonData initially.
b578683
to
355f844
Compare
It should also resolve #24287 |
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.
One small additional comment but otherwise this look nice, good work.
* Return empty list of tags when tags are not available In some configurations graphite-web fail to return the list of tags. It shouldn't however prevent displaying list of metrics (which is concatenated with tags). * Populate jsonData with default version of Graphite The version of Graphite is preselected in the dropdown but was not saved in jsonData initially. * Fix a typo * Show a popup with an error message * Always use the latest Graphite value as the default one when creating a datasource * Move autocomplete error handling to GraphiteQueryCtrl * Test error handing in Graphite autocomplete * Test default Graphite version fallback * Rename graphite_versions.ts to versions.ts * Remove redundant import * Code formatting, minor renaming * Remove redundant error info
What this PR does / why we need it:
This is to fix #17429. Long story short the query builder's autocomplete input makes 2 requests to graphite-web: one to get a list of metrics and one to get a list of tags and merges both lists together:
The problem is when one of the requests fails, nothing is returned in the suggests list.
The request to get the list of tags may fail in two scenarios:
To mitigate this problem the errors for tags request are caught to return an empty list and the error is displayed in the console.
This may however happen unintentionally in some edge cases. When creating a new Graphite data source the version input is initially populated:
But this value is not being saved if it's not changed explicitly. In Explore section the query component falls back to
1.1
when the version is not defined, but this fall back was changed in7.4.0
(from 0.9 to 1.1) meaning that all data sources created before 7.4.0 (intentionally created for 0.9 with the default value in the input) are now treated as 1.1 and make an attempt to get tags, hence breaking autocomplete.To avoid similar problems in future the initial version is saved when a new data source is created.
We could also automatically detect the version of Graphite by calling
/version
endpoint (https://github.com/graphite-project/graphite-web/blob/master/webapp/graphite/version/views.py)Which issue(s) this PR fixes:
Fixes #17429.