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

Autocomplete of InfluxDB measurements does not escape search string properly #11503

Closed
altery opened this issue Apr 5, 2018 · 0 comments
Closed
Labels
area/datasource datasource/InfluxDB prio/low It's a good idea, but not scheduled for any release type/bug
Milestone

Comments

@altery
Copy link

altery commented Apr 5, 2018

Symtom

Autocomplete of InfluxDB measurement does not work if measurement contains a slash (/) and user enters a slash in the input field. This has been reproduced with Grafana 5.0.4.

Expected behavior

The user may enter the series name and should get autocomplete even if the series name contains a slash.

Analysis

Grafana uses SHOW MEASUREMENTS WITH MEASUREMENT to implement autocomplete. WITH MEASUREMENT takes a regular expression as argument. The user input is taken as argument but not escaped properly.

Example

If the user enters the following input in the measurement box:

mvc.GET /

Grafana issues the following query

http://grafana:3000/api/datasources/proxy/8/query?db=test&q=SHOW%20MEASUREMENTS%20WITH%20MEASUREMENT%20%3D~%20%2Fmvc.GET%20%2F%2F%20LIMIT%20100&epoch=ms

Influx DB returns HTTP status 400, because it interprets the slash as the end-sign of the regular expression. Also note, that the dot character (.) is not escaped as well.

The correct request would be:

http://grafana:3000/api/datasources/proxy/8/query?db=test&q=SHOW%20MEASUREMENTS%20WITH%20MEASUREMENT%20%3D~%20%2Fmvc%5C.GET%20%5C%2F%2F%20LIMIT%20100&epoch=ms

Workaround

It is possible for the user to manually escape those characters. Unfortunately, if the users enter a backslash character (), the query fails again, because the backslash escapes the actual regular expression separator:

http://grafana:3000/api/datasources/proxy/8/query?db=test&q=SHOW%20MEASUREMENTS%20WITH%20MEASUREMENT%20%3D~%20%2Fmvc.GET%20%5C%2F%20LIMIT%20100&epoch=ms

The autocomplete box closes in this case, which is very unexpected. Only if the user enters another character, the query is valid again and the autocomplete reappears.

@bergquist bergquist added type/bug datasource/InfluxDB prio/low It's a good idea, but not scheduled for any release labels Apr 11, 2018
@torkelo torkelo added this to the 6.0-beta1 milestone Jan 10, 2019
@torkelo torkelo closed this as completed Jan 16, 2019
bergquist added a commit to pbakulev/grafana that referenced this issue Jan 28, 2019
* master: (250 commits)
  Firing off an action instead of listening to location changes
  Changes after PR Comments
  Made ExplorerToolbar connected and refactored away responsabilities from Explore
  Removed some split complexity
  Fixed some more styling
  Fixed close split look and feel
  Fixed position of Closesplit
  Fixed small issue with TimePicker dropdown position
  Simplified some styles and dom elements
  Fixed some more with the sidemenu open and smaller screens
  Fixed so heading looks good with closed sidemenu
  Restructure of component and styling
  Refactored out ExploreToolbar from Explore
  Fixed reinitialise of Explore
  changelog: add notes about closing grafana#13929
  changelog: add notes about closing grafana#14558
  changelog: add notes about closing grafana#14484
  changelog: add notes about closing grafana#13765
  changelog: add notes about closing grafana#11503
  changelog: add notes about closing grafana#4075
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/datasource datasource/InfluxDB prio/low It's a good idea, but not scheduled for any release type/bug
Projects
None yet
Development

No branches or pull requests

4 participants