opensearch-project / anomaly-detection-dashboards-plugin

Manage your detectors and identify atypical data in OpenSearch Dashboards
https://opensearch.org/docs/latest/monitoring-plugins/ad/index/
Apache License 2.0
29 stars 58 forks source link

[FEATURE] Create a visualization with a fixed interval to display forecasting results #441

Open amitgalitz opened 1 year ago

amitgalitz commented 1 year ago

Is your feature request related to a problem? As part of https://github.com/opensearch-project/anomaly-detection/issues/615 we will want to display forecasting results in a visualization that has a fixed interval. Forecasting results will be displayed in terms of x intervals into the future so in order to accurately display them we need to have consistent intervals.

What solution would you like? Our first goal is to create a proof of concept to enable fixed interval visualizations in the anomaly-detection-dashboard plugin. In the AD plugin we don’t adhere to the same global time range and same editing workflow as OpenSearch Dashboard which is what leads to the automatic changes in interval lengths.

Solution POC

Currently we use the this pipelineBuilder in order to create expressions that will later be rendered as visualizations on Dashboards.

In order to create a fixed interval visualization on a plugin like AD-Dashboards we will need to create customized simpler buildPipeline function which will handle creating expressions for line charts based on how we want to show them. This will allow us to pass our own fixed interval to the aggConfigs section of the expression bypassing the automatic interval logic that currently exists.

After creating our own expression function we can render that expression using react_expression_render.

In order to render the visualization, these are the lines of code needed:

const expressionString: ReactExpressionRendererProps = {expression: exp};
const expressions = getExpressions();
return expressions.ReactExpressionRenderer(expressionString);
amitgalitz commented 1 year ago

I was able to render a line chart visualization on the AD plugin page based on an existing expression function. The next step is to re-create a simpler buildPipeline function in order to create the wanted expression function from scratch.

Additionally their is a problem I am looking further into with the simple rendering of a viz on the AD plugin.

  1. While the graph and data does abide by whatever fixed interval I choose, the X-axis as can be seen in the photo below is in-correct. Screenshot 2023-03-22 at 2 27 19 PM