Forum Discussion

TheGreenGorilla's avatar
TheGreenGorilla
Copper Contributor
Oct 21, 2019
Solved

Is it possible to "pipe" the output of one query to another?

Hi, Firstly excuse me if this is a silly question, I am new to Kusto and query languages in general. Is it possible to "pipe" the results of one query and use it to query on with another? What are...
  • CliveWatson's avatar
    CliveWatson
    Oct 23, 2019

    TheGreenGorilla 

     

    More like this?

    let AddMember = (
    AuditLogs
    | where TimeGenerated > ago(2h)
    | where OperationName == "Add member to group" and TargetResources contains "Our Group"
    | project TimeGenerated, OperationName, UserName=TargetResources[0].userPrincipalName, GroupName=TargetResources[0].modifiedProperties[1].newValue, ResourceId
    );
    SigninLogs
    | where TimeGenerated > ago(2h)
    | where AppDisplayName == "Our App"
    | where Status.errorCode == "0"
    | where UserPrincipalName in (AddMember)
    | project TimeGenerated, OperationName, UserName=UserPrincipalName, AppDisplayName, ResourceId

     

     

    Or see my working example (using demo data), please click

     

    Go to Log Analytics and Run Query

     

    Get all computers that startswith a name of "Contoso" from the Heartbeat table and then only show Events for those?  You can use !in for the reverse i.e. "not in"

     

    let computerList = (
    Heartbeat
    | where TimeGenerated > ago(24d)
    | where Computer startswith "Contoso"
    | distinct Computer
    | project Computer
    );
    Event
    | where TimeGenerated > ago(24d)
    | where Computer in (computerList)

     

Resources