Kusto: Run a query for a list of unique id numbers

Viewed 4106

I am a C programmer and new to Kusto. I am running a Kusto query which gives me the result for a direct search on a unique id number. How do I run that query for a list of id numbers. In C I would use a for loop for the range of items in the array of list but I do not know how to translate that logic in Kusto.

Query:

let startdate = ago(5d); let enddate = ago(1m);
DataBase
| where messageType != "Beacon" 
| where timestamp between (startdate..enddate)   
| where uniqueId == "26ca68"
| project uniqueId, timestamp

I wish to run the above query for a list of 25 unique Id numbers. Thank you.

1 Answers

you can use the in() operator: https://docs.microsoft.com/en-us/azure/kusto/query/inoperator

for example:

let IDs = dynamic(["abc", "def", "ghi"]); // replace/add IDs
let startdate = ago(5d);
let enddate = ago(1m);
DataBase
| where messageType != "Beacon" 
| where timestamp between (startdate..enddate)   
| where uniqueId in (IDs) // <----
| project uniqueId, timestamp
Related