question

ChristophHinterleitner-5350 avatar image
0 Votes"
ChristophHinterleitner-5350 asked SwathiDhanwada-MSFT commented

Calling series_rate_fl() breaks IDE in Azure Log Analytics blade

Concerned function/document:
https://docs.microsoft.com/en-us/azure/data-explorer/kusto/functions-library/series-rate-fl

I am using the function in a Azure Log Analytics blade and after calling it, the IDE breaks.
ReferenceError: UnknownIdentifierResolveResult is not defined

After using this in code, none of the IDE functions work, it turns into a basic text editor.

azure-monitor
· 6
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@ChristophHinterleitner-5350 Welcome to Microsoft Q & A Community Forum. Can you please provide the kusto query you are executing so that we can test it and provide you appropriate resolution?

0 Votes 0 ·

Sure, here is my query (in 3 parts because of characters limit):

 let StartTime = ago(12h);
 let series_metric_fl=(metrics_tbl: (*), timestamp_col: string, name_col: string, labels_col: string, value_col: string, metric_name: string, labels_selector: string='', lookback: timespan=timespan(10m), offset: timespan=timespan(0)) {
     let selector_d=iff(labels_selector == '', dynamic(['']), split(labels_selector, ',')); //if selector labels, convert into select format, otherwise default empty selector
     let etime = ago(offset);
     let stime = etime - lookback;
     metrics_tbl
     | extend
         timestamp = column_ifexists(timestamp_col, datetime(null)),
         name = column_ifexists(name_col, ''),
         labels = column_ifexists(labels_col, dynamic(null)),
         value = column_ifexists(value_col, 0)
     | extend labels = dynamic_to_json(labels)       //  convert to string and sort by key
     | where name == metric_name and timestamp between(stime .. etime)
     | order by timestamp asc
     | summarize timestamp = make_list(timestamp), value=make_list(value) by name, labels
     | where labels has_all (selector_d) //like contains but for a list of terms, constructed by "let selector_d"
 }
 ;
0 Votes 0 ·
ChristophHinterleitner-5350 avatar image ChristophHinterleitner-5350 ChristophHinterleitner-5350 ·

StartTime should be timespan() instead of ago(), sorry. But doesn't change the problem.

0 Votes 0 ·

Sure, here is my query, part 2:


 let series_rate_fl=(tbl:(timestamp:dynamic, value:dynamic), n_bins:int=1, fix_reset:bool=true)
 {
     tbl
     | where fix_reset                                                   //  Prometheus counters can only go up
     | mv-apply value to typeof(double) on   
     ( extend correction = iff(value < prev(value), prev(value), 0.0)    // if the value decreases we assume it was reset to 0, so add last value
     | extend cum_correction = row_cumsum(correction)
     | extend corrected_value = value + cum_correction
     | summarize value = make_list(corrected_value))
     | union (tbl | where not(fix_reset))
     | extend timestampS = array_shift_right(timestamp, n_bins), valueS = array_shift_right(value, n_bins)
     | extend dt = series_subtract(timestamp, timestampS)
     | extend dt = series_divide(dt, 1e7)                              //  converts from ticks to seconds
     | extend dv = series_subtract(value, valueS)
     | extend rate = series_divide(dv, dt)
     | project-away dt, dv, timestampS, value, valueS
 }
 ;
0 Votes 0 ·

Query part 3:

 InsightsMetrics
 | extend Tags = todynamic(Tags)
 | invoke series_metric_fl('TimeGenerated', 'Name', 'Tags', 'Val', 'istio_requests_total', lookback = StartTime)
 | invoke series_rate_fl()  //this function call breaks the IDE
 | mv-expand timestamp, rate
 | extend timestamp=todatetime(timestamp)
 | extend RequestsPerMinute = toreal(rate) * 60
 | sort by timestamp desc
 | project timestamp, tostring(labels), RequestsPerMinute
 | render timechart
0 Votes 0 ·
SwathiDhanwada-MSFT avatar image SwathiDhanwada-MSFT ChristophHinterleitner-5350 ·

@ChristophHinterleitner-5350 Thanks for sharing the query. I will check and revert to you.

1 Vote 1 ·

0 Answers