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

Corrects aggregation query not clause #30

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions fmatch/matcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,7 @@ def get_agg_metric_query(
metric_queries = []
not_queries = [
~Q("match", **{not_item_key: not_item_value})
for not_item in metrics.get("not", [])
Copy link
Contributor

@vishnuchalla vishnuchalla Jan 24, 2025

Choose a reason for hiding this comment

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

I think the previous logic was meant to take a list of dicts under not as shown below

[{'labels.container.keyword': 'kube-rbac-proxy'}, {'labels.namespace.keyword': 'xyz'}]

and then generate a query as below

[Bool(must_not=[Match(labels__container__keyword='kube-rbac-proxy')]), Bool(must_not=[Match(labels__namespace__keyword='xyz')])]

So the yaml structure should be

      not:
        - labels.container.keyword: kube-rbac-proxy
        - labels.namespace.keyword: xyz

for not_item_key, not_item_value in not_item.items()
for not_item_key, not_item_value in metrics.get("not", {}).items()
Copy link
Contributor

@vishnuchalla vishnuchalla Jan 24, 2025

Choose a reason for hiding this comment

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

But if we look at the new logic, it is changing the interpretation to a single dict with multiple key value pairs

{'labels.container.keyword': 'kube-rbac-proxy', 'labels.namespace.keyword': 'xyz'}

and the generated query would be same

[Bool(must_not=[Match(labels__container__keyword='kube-rbac-proxy')]), Bool(must_not=[Match(labels__namespace__keyword='xyz')])]

But the yaml structure for not would change to

      not:
        labels.container.keyword: kube-rbac-proxy
        labels.namespace.keyword: xyz

]
metric_queries = [
Q("match", **{metric_key: metric_value})
Expand Down
Loading