cancel
Showing results for 
Search instead for 
Did you mean: 
intapiuser
Community Team Member
Community Team Member

Use case

Imagine you're Jeff Bezos and you own a few servers. You sell compute on these servers to customers and you want to make sure that you always have enough computer power to meet demand. This means when overall RAM consumption approaches the max RAM of your servers you must buy more servers so your customers never have an outage! But it takes at least a week to set everything up! 
In this scenario, we need to be alerted to a metric hitting a maximum ahead of time. This is done with a forecasted value.

Solution

We can use the R integration to predict n days ahead and trigger a pulse alert to notify us when predicted values breach a threshold value.
In this example, we will use the Prophet library to forecast our data, but any library can be used - even regression.
As an example, let’s look at a time series of the log daily page views for the Wikipedia page for Peyton Manning. Peyton Manning provides a nice example because it illustrates some of Prophet’s features, like multiple seasonality, changing growth rates, and the ability to model special days (such as Manning’s playoff and superbowl appearances). The CSV is available here.

Steps to implement

1. Elasticube Setup:
In the Elasticube, break up the date you will forecast over into independent Year, Month, and Day integer columns using custom columns for each.
custom column name: function
year: getYear(date)
month: getMonth(date)
days: getDay(date)
2. RServe & Environment Setup
Run RServe and download the following libraries to R
  • Tidyr
  • Dplyr
  • Prophet
3. Sisense Indicator and Function Setup
Paste the following code into an indicator's function editor.
RDOUBLE(
TRUE,
"library('tidyr');
library('dplyr');
library('prophet');

df <- data.frame(y=args[[1]], year=args[[2]], month=args[[3]], day=args[[4]]);
df <- df %>% unite('ds', year, month, day, sep='-', remove = FALSE);
df <- df[c('ds', 'y')];
df$ds <- as.Date(df$ds , format = '%Y-%m-%d');
m <- prophet(df);
future <- make_future_dataframe(m, periods = args[[5]], include_history = FALSE);
forecast <- predict(m, future);
max(forecast$yhat);
",
[y]*1,[year]*1,[month]*1,[day]*1, 60)
In the code above the arguments to the function are columns y (as all items), year (as all items), day (as all items), and the number 60.
  • y: the value to forecast
  • year: the integer year portion of the date
  • month: the integer month portion of the date
  • day: the integer day portion of the date
  • 60: the parameter that determines how many days into the future to forecast
Save the widget.
This number represents the maximum value among forecasted values.
4. Creating the Pulse Alert
On the widget you just made, create a pulse alert, and set a threshold. Use the "greater than" option.
When any of the values in the forecast go above the threshold you will be notified!
2020-10-19_23h02_11.png
This works with data security, so each tenant's data will be forecasted and evaluated against the threshold when the elasticube is built. Only users who's forecasted values are greater than the threshold will be notified.
Cheers!
Rate this article:
Version history
Last update:
‎02-21-2024 12:15 PM
Updated by: