Grafana OpenSearch/ElasticSearch Alerting

I have OpenSearch configured as a datasource in my Grafana. I have data which consists of logtime, status and targetApi. I want to trigger an alert whenever a status 400 is observed and I want to include the corresponding targetApi in the labels and annotation(basically in the alert notification). I have tried many methods, but to no success. If anyone ha worked on this or something similar please do teach me your findings, learnings and challenges.

Nvm, figured it out. Just used the average and/or count metric with Group by terms with my targetApi and then by the time and it returned data which was usable for alerting purposes.