0

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.

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)
Roopchand
  • 33
  • 5
  • You could use the first query as input for a variable (the part before "and") and reference this variable in the second part. This is not exactly what you've asked for but it might be a useful workaround. – Sascha Doerdelmann Aug 24 '22 at 07:44

1 Answers1

0

You can combine two separate queries A and B with a Math expression $A && $B.

Note that you can decide whether a query or expression is displayed in the panel by clicking on the eye symbol.

  • But how could A experssion knows which stacks are canary... Let's assume, I have 10 stacks as stack-blue-1, stack-blue-2 up to stack-blue-10... stack-blue-1 & stack-blue-5 have 1 instance and the remaining all have more than one so here blue1 and blue5 are the canary ones. So, I want to inform A expression to display only these stacks stats... right? – Roopchand Aug 25 '22 at 11:58
  • So you are not asking for something like "and", you are asking for control structures like if-then-else? I currently don't know how to achieve this. – Sascha Doerdelmann Aug 25 '22 at 14:06