How to use binary operators in LOKI ? and based on that need to show the result?

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 could I achieve this? I am looking for an expression something like the 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)

Hi @roopchandcse,

Welcome to the :grafana: community support forums !!

Well, I am not an expert when it comes to the K8s world. But I will try to help. I found some resources which might be helpful to get some basic idea as how to setup for K8s canary deployment/testing.

1- Loki Canary | Grafana Loki documentation

2- Loki’s Path to GA: Loki-Canary Early Detection for Missing Logs | Grafana Labs

3- Loki-Canary | Grafana Labs

I hope this helps and maybe someone else from the community able to give more insights to your post :slight_smile:

1 Like