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

How to support mulit options with label values of stream-fields #109

Closed
worker24h opened this issue Nov 20, 2024 · 14 comments
Closed

How to support mulit options with label values of stream-fields #109

worker24h opened this issue Nov 20, 2024 · 14 comments
Assignees
Labels
bug Something isn't working question Further information is requested

Comments

@worker24h
Copy link
Contributor

worker24h commented Nov 20, 2024

image

When I selected ALL, the result of query is nothing, as follows:
image

So I capture the package of http:

{
  "from": xxx
  "to": xxx
   "queries":  {
     ...
     "expr": "{pod=~\"(neolix-cockpit-server-5888c774f-fqrgv OR neolix-cockpit-server-5888c774f-smclh)\",container_name=\"neolix-cockpit-server\",namespace=\"vehicle-platform\"} MarsSendServiceImpl",
     ...
    }
}

The LogQL is : {pod=~"${pod}",container_name="${container}",namespace="${namespace}"} ${query}

The value of variable pod is generated by grafana auto, But, I think the victorialogs does not support it, which it is (AAA OR BBB)

so, how to fix it? Everyone, thanks

@hagen1778 @dmitryk-dk

@hagen1778
Copy link
Contributor

Hey @worker24h !
Have you tried set All value to *?
See my example for host variable below:
image

And then on query time:
image

And here's how it works for All:
image

@hagen1778 hagen1778 added the question Further information is requested label Nov 21, 2024
@worker24h
Copy link
Contributor Author

Yes, your case is done, but my case is stream field. When I setted * , it response failed.
image

The fields of stream, as follows
image

@hagen1778

@hagen1778
Copy link
Contributor

Try changing * to .* in All options settings for variable

@worker24h
Copy link
Contributor Author

worker24h commented Nov 21, 2024

Try changing * to .* in All options settings for variable

Perfect, .* for 'ALL' is good. But, if selected two items of pod, the result of query is nothing.

image

The grafana will generate pod=~"(AAA OR BB)",So I think, it will be need fixed.

@hagen1778
Copy link
Contributor

For stream selector regular expression for selecting multiple items should be A|B, instead of A OR B.
@Loori-R is it possible to parse variable differently if we deal with stream matcher?

@Loori-R
Copy link
Contributor

Loori-R commented Nov 21, 2024

For stream selector regular expression for selecting multiple items should be A|B, instead of A OR B. @Loori-R is it possible to parse variable differently if we deal with stream matcher?

Yes, of course, I'll see what I can do.

@Loori-R Loori-R self-assigned this Nov 21, 2024
@Loori-R Loori-R added the bug Something isn't working label Nov 21, 2024
@worker24h
Copy link
Contributor Author

worker24h commented Nov 26, 2024

For stream selector regular expression for selecting multiple items should be A|B, instead of A OR B. @Loori-R is it possible to parse variable differently if we deal with stream matcher?

Yes, of course, I'll see what I can do.

Hi, I fixed the bug, Do you cloud code reivew ? PR: #122

@hagen1778 @Loori-R Thanks

@dmitryk-dk dmitryk-dk mentioned this issue Dec 4, 2024
@dmitryk-dk
Copy link
Contributor

Hi @worker24h ! The issue was fixed in the new plugin release. Close this issue as resolved. Feel free to reopen the issue if you find any problems.

@hagen1778 hagen1778 reopened this Dec 6, 2024
@hagen1778
Copy link
Contributor

hagen1778 commented Dec 6, 2024

The filter is still not working correctly - try selecting multiple namespaces at playground.

@worker24h
Copy link
Contributor Author

The filter is still not working correctly - try selecting multiple namespaces at https://grafana.sandbox.victoriametrics.com/d/be5zidev72m80f/k8s-logs-demo?orgId=1&var-ds=fdmacvu8gcwlce&var-namespace=All&var-pod=All&var-container=All&var-filter=%2A&var-limit=100

I can't sign in without username and password. Do you support a capture screen, I will try to fix it. Thanks @hagen1778

@dmitryk-dk
Copy link
Contributor

Hi @worker24h ! You just fixed one possible problem, but in the filters, there can be another OR
Screenshot 2024-12-06 at 13 23 45
Screenshot 2024-12-06 at 13 23 58

@Loori-R
Copy link
Contributor

Loori-R commented Dec 6, 2024

@worker24h, Your code works for the case {field_name=~"foo|bar"}, but it doesn’t handle queries like field_name:~"foo|bar".

It’s also necessary to add support for the in() function, for example: field_name:in(foo,bar).

There might be other cases where variables need to be inserted without using OR. @hagen1778 or @dmitryk-dk , maybe you have some insights.

We might need a solution more complex than regular expressions. I plan to take a closer look at this issue today.

@worker24h
Copy link
Contributor Author

@worker24h, Your code works for the case {field_name=~"foo|bar"}, but it doesn’t handle queries like field_name:~"foo|bar".

It’s also necessary to add support for the in() function, for example: field_name:in(foo,bar).

There might be other cases where variables need to be inserted without using OR. @hagen1778 or @dmitryk-dk , maybe you have some insights.

We might need a solution more complex than regular expressions. I plan to take a closer look at this issue today.

OK. I consider that if I can unify all logical ORs into using the keyword OR, while the keyword | is only used to express pipeline.

So,it need to modify backend code, But this syntax is simple and unified for users, and Loki only has keyword OR.

@hagen1778 @dmitryk-dk @Loori-R

@dmitryk-dk
Copy link
Contributor

Hi! The issue was fixed in the new release. Please check it. If you find any problems feel free to reopen the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants