Closed kanatohodets closed 7 years ago
Some context for the comment about format changing:
From graphite-web, handling the AJAX request from the frontend for autocomplete:
if format == 'completer':
query = query.replace('..', '*.')
if not query.endswith('*'):
query += '*'
if automatic_variants:
query_parts = query.split('.')
for i,part in enumerate(query_parts):
if ',' in part and '{' not in part:
query_parts[i] = '{%s}' % part
query = '.'.join(query_parts)
try:
matches = list( STORE.find(query, fromTime, untilTime, local=local_only) )
except:
log.exception()
raise
The STORE.find
at the end here will do a normal Find request to zipper, with the normal json or pickle format.
As a result, zipper never sees any 'completer' requests as far as I can tell. This is why we need to guess a bit about whether a query is a completer or not by looking for the *
. However, I think this is a basically reasonable thing given how virtual metrics work -- normal globs aren't supported by carbonsearch, so the only concern is about colliding with a tag which legitimately has a glob at the end.
This allows the SearchBackend to return query completions for virtual queries: e.g. virt.v1..servers-stat returns ["virt.v1.*.servers-status:"].
Why test for running a completion query using 'HasSuffix(query, "*")' rather than 'format == "completer"? The reason is that graphite-web translates format=completer from the javascript into format=json and a standard 'find' request, and it is this standard 'find' request which reaches carbonzipper.