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

Conversation

afcollins
Copy link
Member

Type of change

  • Bug fix

Description

Simply aligned the 'not' section for an aggregation to that of getResults.

Related Tickets & Documents

Checklist before requesting a review

  • I have performed a self-review of my code.
  • If it is a core feature, I have added thorough tests.

Testing

  • Please describe the System Under Test.
  • Please provide detailed steps to perform tests related to this code change.
  • How were the fix/results from this change verified? Please provide relevant screenshots or results.

@afcollins
Copy link
Member Author

@vishnuchalla @shashank-boyapally PTAL , I don't have merge permissions

Copy link
Member

@jtaleric jtaleric left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Contributor

@vishnuchalla vishnuchalla left a comment

Choose a reason for hiding this comment

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

imho, if we have multiple labels to be represented under not I think having them interpreted as list of dicts would make more sense from yaml configuration standpoint and will be inline with other similar structures in the configuration. For example metrics["labels"]

@@ -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

@@ -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", [])
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: Couldn't get metrics ..., exception 'str' object has no attribute 'items'
3 participants