简体   繁体   English

如何在 LOKI 中使用二元运算符? 格拉法纳

[英]How to use binary operators in LOKI ? Grafana

I'm creating a panel to show the error count in logs for canary instances.我正在创建一个面板来显示金丝雀实例的日志中的错误计数。 First, I need to find whether the instance is canary or not.首先,我需要确定实例是否是金丝雀。 So, if the instance is canary then I have to show the error log count for that instance.因此,如果实例是金丝雀,那么我必须显示该实例的错误日志计数。

To filter the canary instance - I have stack label so if the stack contains one instance then it should be a canary instance.要过滤金丝雀实例 - 我有堆栈 label 所以如果堆栈包含一个实例,那么它应该是一个金丝雀实例。

The expression should check the instance count of each and every stack, if a stack has one instance then it needs to search for the keyword in the log.该表达式应该检查每个堆栈的实例计数,如果一个堆栈有一个实例,那么它需要在日志中搜索关键字。

How do achieve this?如何做到这一点? I am looking for an expression something like below.我正在寻找类似下面的表达式。

sum(count_over_time({component="stack-blue.*" ,cloud=~"${cloud}" ,environment=~"${environment}" ,location=~"${location}" } |= "Unable to record" [$__interval]))
and
(count(count by(hostname)(count_over_time({component="stack-blue.*",cloud=~"${cloud}" ,environment=~"${environment}" ,location=~"${location}"  } [$__interval]))) == 1)

You can combine two separate queries A and B with a Math expression $A && $B.您可以将两个单独的查询 A 和 B 与数学表达式 $A && $B 结合起来。

Note that you can decide whether a query or expression is displayed in the panel by clicking on the eye symbol.请注意,您可以通过单击眼睛符号来决定是否在面板中显示查询或表达式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM