none
Using Let not working for my Query RRS feed

  • Question

  • let start = ago(5h);
    union (traces
    | where timestamp >= start and timestamp < ago(0d)), (requests
    | where timestamp >= start and timestamp < ago(0d)), (pageViews
    | where timestamp >= start and timestamp < ago(0d)), (dependencies
    | where timestamp >= start and timestamp < ago(0d)), (customEvents
    | where timestamp >= start and timestamp < ago(0d)), (availabilityResults
    | where timestamp >= start and timestamp < ago(0d)), (exceptions
    | where timestamp >= start and timestamp < ago(0d))
    | where ((itemType == 'trace' or (itemType == 'request' or (itemType == 'pageView' or (itemType == 'customEvent' or (itemType == 'exception' or (itemType == 'dependency' or itemType == 'availabilityResult')))))) and (timestamp >= start and timestamp <= ago(0d)))
    | top 101 by timestamp desc

    Dear, I am using the query above, but it does not seem to use the variable start properly.

    Anybody any idea what I am doing wrong?

    Kind regards,

    Rogier

    Wednesday, April 3, 2019 9:45 AM

All replies

  • Hi Rogier, 

    If the intent is to fetch the top 101 rows of the data set (which is union of traces, requests , pageViews, dependencies , customEvents , availabilityResults, exceptions ) between now and last 5 hrs with a where condition on itemType (as you have above)  the query you have should work.

    To simply you can view the results with below query, which should return the entire data set you are looking for

    let start = ago(5h); 
    union traces, requests , pageViews, dependencies , customEvents , availabilityResults, exceptions
    | where itemType == 'trace' or itemType == 'request' or itemType == 'pageView' or itemType == 'customEvent' or itemType == 'exception' or itemType == 'dependency' or itemType == 'availabilityResult' and timestamp >= start and timestamp <= ago(0d)

    Further you can add your top results as below 

    let start = ago(5h); 
    union traces, requests , pageViews, dependencies , customEvents , availabilityResults, exceptions
    | where itemType == 'trace' or itemType == 'request' or itemType == 'pageView' or itemType == 'customEvent' or itemType == 'exception' or itemType == 'dependency' or itemType == 'availabilityResult' and timestamp >= start and timestamp <= ago(0d)
    
    | top
    101
    by timestamp desc

    Hope above information helps, please revert back if you have further queries. 

     
    Wednesday, April 3, 2019 6:47 PM
    Owner