Example #1
0
        private DimensionInfo SeparateDimension(Dictionary <string, Object> dimensions, Object aggSymbol)
        {
            DimensionInfo info = new DimensionInfo();

            foreach (KeyValuePair <string, Object> entry in dimensions)
            {
                string key = entry.Key;
                if (object.Equals(aggSymbol, entry.Value))
                {
                    info.AggDims.Add(key);
                }
                else
                {
                    info.DetailDims.Add(key);
                }
            }

            return(info);
        }
Example #2
0
        private TimeSeriesPoint GetPointByDimension(Dictionary <Dictionary <string, Object>, TimeSeriesPoint> dimPointMapping, Dictionary <string, Object> dimension, PointTree pointTree, AggregateType aggType, Object aggSymbol)
        {
            if (dimPointMapping.ContainsKey(dimension))
            {
                return(dimPointMapping[dimension]);
            }

            int                         count         = 0;
            TimeSeriesPoint             p             = new TimeSeriesPoint(dimension);
            DimensionInfo               dimensionInfo = SeparateDimension(dimension, aggSymbol);
            Dictionary <string, Object> subDim        = GetSubDim(dimension, dimensionInfo.DetailDims);

            foreach (TimeSeriesPoint leave in pointTree.Leaves)
            {
                if (ContainsAll(leave.Dimension, subDim))
                {
                    count++;

                    p.Value         = +leave.Value;
                    p.ExpectedValue = +leave.ExpectedValue;
                    p.Delta         = +leave.Delta;
                }
            }
            if (aggType.Equals(AggregateType.Avg))
            {
                p.Value         = p.Value / count;
                p.ExpectedValue = p.ExpectedValue / count;
                p.Delta         = p.Delta / count;
            }

            if (count > 0)
            {
                return(p);
            }
            else
            {
                return(null);
            }
        }
        /// <summary>
        ///  This is a function for analyze one layer for root cause, we select one dimension with values who contributes the most to the anomaly.
        /// </summary>
        private RootCause AnalyzeOneLayer(RootCauseLocalizationInput src)
        {
            RootCause dst = new RootCause();

            dst.Items = new List <RootCauseItem>();

            DimensionInfo dimensionInfo = SeparateDimension(src.AnomalyDimension, src.AggregateSymbol);
            Tuple <PointTree, PointTree, Dictionary <Dictionary <string, object>, TimeSeriesPoint> > pointInfo = GetPointsInfo(src, dimensionInfo);
            PointTree pointTree   = pointInfo.Item1;
            PointTree anomalyTree = pointInfo.Item2;
            Dictionary <Dictionary <string, Object>, TimeSeriesPoint> dimPointMapping = pointInfo.Item3;

            //which means there is no anomaly point with the anomaly dimension or no point under anomaly dimension
            if (anomalyTree.ParentNode == null || dimPointMapping.Count == 0)
            {
                return(dst);
            }

            dst.Items.AddRange(LocalizeRootCauseByDimension(anomalyTree, pointTree, src.AnomalyDimension, dimensionInfo.AggDims));
            GetRootCauseDirectionAndScore(dimPointMapping, src.AnomalyDimension, dst, _beta, pointTree, src.AggregateType, src.AggregateSymbol);

            return(dst);
        }
Example #4
0
        private Tuple <PointTree, PointTree, Dictionary <Dictionary <string, object>, TimeSeriesPoint> > GetPointsInfo(RootCauseLocalizationInput src, DimensionInfo dimensionInfo)
        {
            PointTree         pointTree   = new PointTree();
            PointTree         anomalyTree = new PointTree();
            DimensionComparer dc          = new DimensionComparer();
            Dictionary <Dictionary <string, object>, TimeSeriesPoint> dimPointMapping = new Dictionary <Dictionary <string, object>, TimeSeriesPoint>(dc);

            List <TimeSeriesPoint>      totalPoints = GetTotalPointsForAnomalyTimestamp(src);
            Dictionary <string, Object> subDim      = GetSubDim(src.AnomalyDimension, dimensionInfo.DetailDims);

            foreach (TimeSeriesPoint point in totalPoints)
            {
                if (ContainsAll(point.Dimension, subDim))
                {
                    if (!dimPointMapping.ContainsKey(point.Dimension))
                    {
                        dimPointMapping.Add(point.Dimension, point);
                        bool isValidPoint = point.IsAnomaly == true;
                        if (ContainsAll(point.Dimension, subDim))
                        {
                            BuildTree(pointTree, dimensionInfo.AggDims, point, src.AggregateSymbol);

                            if (isValidPoint)
                            {
                                BuildTree(anomalyTree, dimensionInfo.AggDims, point, src.AggregateSymbol);
                            }
                        }
                    }
                }
            }

            return(new Tuple <PointTree, PointTree, Dictionary <Dictionary <string, Object>, TimeSeriesPoint> >(pointTree, anomalyTree, dimPointMapping));
        }