Cherbo
Cherbo

Reputation: 67

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

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.

Upvotes: 6

Views: 12545

Answers (1)

Yoni L.
Yoni L.

Reputation: 25895

you can use the in() operator: https://learn.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

Upvotes: 8

Related Questions