You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
code generates: "('dc=tag1'=ANY("tags") OR 'dc=tag2'=ANY("tags"))"
Expected behavior
all tags in search returned
"('dc=tag1'=ANY("tags") OR 'dc=tag2'=ANY("tags") OR OR 'dc=tag3'=ANY("tags"))"
Screenshots
Additional context
This was a customer request from our ops dept using alerta.
I have done some debugging and testing against mongo and postgres, in debug mode I can trace the params correctly getting to the QueryParser class in queryparser.py and then hitting the query_expr infixNotation() that seems to only handle a left / right or clause. (Optional(OR).setParseAction(lambda: 'OR'), 2, opAssoc.LEFT, SearchOr), this in turn returns an sql query of:
"('dc=tag1'=ANY("tags") OR 'dc=tag2'=ANY("tags"))"
so it looks like the parser for handling multiple query params is locked at 2 even though 3 params were passed into the function.
Appreciate any feedback or guidance on what we could do here to open this up to more parameters for searching.
Thanks
Pete
The text was updated successfully, but these errors were encountered:
Interestingly, I can get up to 4 working by wrapping 2 sets of OR's in brackets via the UI. (I have moved to the tag called channel here which are in my prod system i have lots alerts for)
and this seems to continue by wrapping that 4 queries in brackets also works for fulfilling the first OR in the query, this will probably continue forever and is becoming a little unintuitive for the user.
Issue Summary
When trying to filter results via the API (or UI) using tags, we are unable to use more than 2 tags.
Environment
OS: Linux
API version: 9.0.1
Deployment: Local / K8s
For self-hosted, WSGI environment: nginx / pycharm
Database: Postgres & Mongo
Server config:
Auth enabled? Yes for Prod, No for Dev
Customer views? No
web UI version: n/a
CLI version: n/a
To Reproduce
Steps to reproduce the behavior:
create 3 alerts with unique tags. eg
alerta send -r test4 -e test4 -S test4 -t test4 -T dc=tag1 -E Production -s major
alerta send -r test3 -e test3 -S test3 -t test3 -T dc=tag2 -E Production -s major
alerta send -r test2 -e test2 -S test2 -t test2 -T dc=tag3 -E Production -s major
query api with following params
/alerts?q=tags%3A"dc%3Dtag1"+tags%3A"dc%3Dtag2"+tags%3A"dc%3Dtag3"
response will only be for tag1 + tag2.
code generates: "('dc=tag1'=ANY("tags") OR 'dc=tag2'=ANY("tags"))"
Expected behavior
all tags in search returned
"('dc=tag1'=ANY("tags") OR 'dc=tag2'=ANY("tags") OR OR 'dc=tag3'=ANY("tags"))"
Screenshots
Additional context
This was a customer request from our ops dept using alerta.
I have done some debugging and testing against mongo and postgres, in debug mode I can trace the params correctly getting to the QueryParser class in queryparser.py and then hitting the query_expr infixNotation() that seems to only handle a left / right or clause. (Optional(OR).setParseAction(lambda: 'OR'), 2, opAssoc.LEFT, SearchOr), this in turn returns an sql query of:
"('dc=tag1'=ANY("tags") OR 'dc=tag2'=ANY("tags"))"
so it looks like the parser for handling multiple query params is locked at 2 even though 3 params were passed into the function.
Appreciate any feedback or guidance on what we could do here to open this up to more parameters for searching.
Thanks
Pete
The text was updated successfully, but these errors were encountered: