Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Switch services using the Version drop-down list. Learn more about navigation.
Applies to: ✅ Azure Data Explorer ✅ Azure Monitor ✅ Microsoft Sentinel
Cleans anomalous points in a series.
The function series_clean_anomalies_fl() is a user-defined function (UDF) that takes a dynamic numerical array as input and another numerical array of anomalies and replaces the anomalies in the input array with interpolated value of their adjacent points.
Syntax
series_clean_anomalies_fl(y_series, anomalies)
Learn more about syntax conventions.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| y_series | dynamic |
✔️ | The input array of numeric values. |
| anomalies | dynamic |
✔️ | The anomalies array containing either 0 for normal points or any other value for anomalous points. |
Function definition
You can define the function by either embedding its code as a query-defined function, or creating it as a stored function in your database, as follows:
Define the function using the following let statement. No permissions are required.
Important
A let statement can't run on its own. It must be followed by a tabular expression statement. To run a working example of series_clean_anomalies_fl(), see Example.
let series_clean_anomalies_fl = (y_series:dynamic, anomalies:dynamic)
{
let fnum = array_iff(series_not_equals(anomalies, 0), real(null), y_series); // replace anomalies with null values
series_fill_linear(fnum)
};
// Write your query to use the function here.
Example
To use a query-defined function, invoke it after the embedded function definition.
let series_clean_anomalies_fl = (y_series:dynamic, anomalies:dynamic)
{
let fnum = array_iff(series_not_equals(anomalies, 0), real(null), y_series); // replace anomalies with null values
series_fill_linear(fnum)
}
;
let min_t = datetime(2016-08-29);
let max_t = datetime(2016-08-31);
demo_make_series1
| make-series num=count() on TimeStamp from min_t to max_t step 20m by OsVer
| extend anomalies = series_decompose_anomalies(num, 0.8)
| extend num_c = series_clean_anomalies_fl(num, anomalies)
| render anomalychart with (anomalycolumns=anomalies)
Output