Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Add stats to track knn request counts #89

Merged

Conversation

jmazanec15
Copy link
Member

Issue #, if available:
#88

Description of changes:
PR adds stats to track the number of requests and errors for KNN query and index operations.

For query operations, bookkeeping is added in the queryIndex function in KNNIndex. For index operations, it is added in the KNNVectorFieldMapper parse function.

Unit tests have been added to make sure that the counting functionality works properly.

Documentation has been updated as well.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@jmazanec15 jmazanec15 requested a review from vamshin April 10, 2020 21:20
Comment on lines 276 to 278
} catch (Exception ex) {
KNNCounter.GRAPH_INDEX_ERRORS.increment();
throw ex;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These Exceptions will only include the parsing errors(customer error) which we could ignore. Graphs are indexed part of the KNN80DocValuesConsumer. We may want to keep track of failures for graph creation there

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh okay that makes sense. Will update.

Comment on lines +88 to +90
} catch (Exception ex) {
KNNCounter.GRAPH_QUERY_ERRORS.increment();
throw new RuntimeException("Unable to query the index: " + ex);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a thought, why not we just rely on load_exception_count metric from cache stats. This seem to track number of exceptions while loading graph which will be invoked during queries?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using load_exception_count would only count exceptions for loading the graph into memory, not the actual query of the graph. Adding the metric here allows us to check if the library query of the graph fails. In your opinion, should this metric track the number of query errors where a query is a call to the ES search API for knn, or for a query where a query is a call to the library function?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense. It should track the number of query errors.

throw new IllegalStateException("KNN plugin is disabled. To enable " +
"update knn.plugin.enabled setting to true");
}
KNNCounter.GRAPH_INDEX_REQUESTS.increment();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might add a little confusion for bulk requests, which could index multiple vectors but still part of same request. If the intention is to count the number of graph requests , probably we could count at KNN80DocValuesConsumer.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the intention of this metric is to count the total number of requests to index graphs. Will move to KNN80DocValuesConsumer

@jmazanec15 jmazanec15 changed the title added stats to track knn request counts Add stats to track knn request counts Apr 16, 2020
#### graph_query_requests
The number of graph queries that have been made.

#### graph_query_errors
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about we add metrics for counting KNNQueries?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. Will add

Copy link
Member

@vamshin vamshin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for adding the metrics.

@jmazanec15 jmazanec15 merged commit 3cbcc9f into opendistro-for-elasticsearch:master Apr 23, 2020
@jmazanec15 jmazanec15 deleted the knn-counters branch April 23, 2020 20:55
jmazanec15 added a commit to jmazanec15/k-NN that referenced this pull request Jul 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants