Forum Discussion
abhijitchaudhari
Mar 29, 2019Copper Contributor
Use time range value in kusto query to calculate % uptime
Is there a way to access time range selected from azure portal in log/app analytics query to help calculate the % uptime ? I am able to calculate the the downtime in minutes using our custom lo...
abhijitchaudhari
Mar 30, 2019Copper Contributor
CliveWatson Not exactly. What I am trying to do is to find the time range selected from portal and use it inside the log analytics query.
CliveWatson
Microsoft
Apr 01, 2019abhijitchaudhari I don't think you can get the last Time Range that was set in the portal. All you can do is re-create it in your query with TimeGenerated filters.
If you don't specify a time range in a query, then the one selected in the current portal window is used by default.
Are you trying to check to see what default was used. to display it in some way?
You could check the start / end data and workout the interval from that?
Event | summarize min_time = min(TimeGenerated), max_time = max(TimeGenerated) | extend my_duration = max_time - min_time // days / hrs/ min / seconds // do other things... | project "All done " , my_duration
- bfd_jamesJun 26, 2019Copper Contributor
CliveWatson - This is the workaround that I ended up doing as well, but I really hate it from a code cleanliness perspective, as it seems like hacky to basically min/max a dataset of thousands/millions of rows just to get a begin end.
In my scenario, I had a Kusto query that had been written against an Application Insights workspace, that included a moving average/series gap filling function for some analysis we were working on internally for request information (trying to flatten out 1-off spikes in request duration skewing graphs). While the query worked in the analytics portal, once pinned to the dashboard, the graph showed no information.
I opened a ticket with Azure Support, but as I opened the ticket, I found/realized that the reason the widget wasn't showing information is that internally the query was failing (found on the network tab of the browser) due to a difference in windowing/dates from the portal vs those that had been defined in the query.
I've since modified the query to utilize min/max on the timestamp information, but it'd definitely be nice to have some way of accessing this information via query, similar to how log analytics has the injectable query/parameter information - ${LikeThis}, or just as a function @query_windowBegin().
Anyways - I didn't see a request for the feature yet, but not sure if I was using the write search terms. Are you aware of any open/outstanding feature requests?
Thanks!
- abhijitchaudhariApr 04, 2019Copper Contributor
But if I do not get any call for first n minutes and last m minutes , I will not able able calculate the % correctly
more details here: https://stackoverflow.com/questions/55379172/find-the-start-and-end-time-or-time-span-of-the-kusto-query-is-running-on-azur
- CliveWatsonApr 04, 2019
Microsoft
abhijitchaudhari Just a thought, but if this is something that is running 24hrs, could you use the startofday operator to get a % up time for a 24hr period - i.e I was up for 10% of the 24hr day.
You may consider submitting a user Voice request: https://feedback.azure.com/forums/267889-log-analytics for your feature to retrieve the portal time span.