Ejemplo n.º 1
0
        protected override void ProcessRecordInternal()
        {
            if (String.IsNullOrWhiteSpace(this.DynamicThreshold))
            {
                List <MetricDimension> metricDimensions = new List <MetricDimension>();

                if (this.DimensionSelection != null && this.DimensionSelection.Length > 0)
                {
                    foreach (var dimension in this.DimensionSelection)
                    {
                        if (dimension.IncludeValues != null && dimension.IncludeValues.Count() > 0)
                        {
                            metricDimensions.Add(new MetricDimension(dimension.Dimension, "Include", dimension.IncludeValues));
                        }
                        if (dimension.ExcludeValues != null && dimension.ExcludeValues.Count() > 0)
                        {
                            metricDimensions.Add(new MetricDimension(dimension.Dimension, "Exclude", dimension.ExcludeValues));
                        }
                    }
                }
                else
                {
                    metricDimensions = null;
                }
                MetricCriteria   metricCriteria = new MetricCriteria(name: "metric1", metricName: this.MetricName, operatorProperty: this.Operator, timeAggregation: this.TimeAggregation, threshold: this.Threshold, metricNamespace: this.MetricNamespace, dimensions: metricDimensions);
                PSMetricCriteria result         = new PSMetricCriteria(metricCriteria);
                WriteObject(sendToPipeline: result);
            }
            else
            {
                WriteExceptionError(new Exception("Creating criteria for Dynamic Threshold is not yet supported"));
            }
        }
        protected override void ProcessRecordInternal()
        {
            List <MetricDimension> metricDimensions = new List <MetricDimension>();

            if (this.DimensionSelection != null && this.DimensionSelection.Length > 0)
            {
                foreach (var dimension in this.DimensionSelection)
                {
                    if (dimension.IncludeValues != null && dimension.IncludeValues.Count() > 0)
                    {
                        metricDimensions.Add(new MetricDimension(dimension.Dimension, "Include", dimension.IncludeValues));
                    }
                    if (dimension.ExcludeValues != null && dimension.ExcludeValues.Count() > 0)
                    {
                        metricDimensions.Add(new MetricDimension(dimension.Dimension, "Exclude", dimension.ExcludeValues));
                    }
                }
            }
            else
            {
                metricDimensions = null;
            }

            IPSMultiMetricCriteria result;

            if (this.WebTest.IsPresent || !string.IsNullOrWhiteSpace(this.WebTestId))
            {
                WebtestLocationAvailabilityCriteria webtestMetricCriteria = new WebtestLocationAvailabilityCriteria(this.WebTestId, this.ApplicationInsightsId, this.FailedLocationCount);
                result = new PSWebtestLocationAvailabilityCriteria(webtestMetricCriteria);
            }
            else if (this.DynamicThreshold.IsPresent)
            {
                DynamicThresholdFailingPeriods failingPeriods        = new DynamicThresholdFailingPeriods(this.ExaminedAggregatedPointCount, this.ViolationCount);
                DynamicMetricCriteria          dynamicMetricCriteria = new DynamicMetricCriteria(name: "metric1",
                                                                                                 metricName: this.MetricName,
                                                                                                 operatorProperty: this.Operator,
                                                                                                 timeAggregation: this.TimeAggregation,
                                                                                                 metricNamespace: this.MetricNamespace,
                                                                                                 dimensions: metricDimensions,
                                                                                                 failingPeriods: failingPeriods,
                                                                                                 alertSensitivity: this.ThresholdSensitivity,
                                                                                                 ignoreDataBefore: this.IsParameterBound(c => c.IgnoreDataBefore) ? (DateTime?)this.IgnoreDataBefore : null,
                                                                                                 skipMetricValidation: this.SkipMetricValidation
                                                                                                 );
                result = new PSDynamicMetricCriteria(dynamicMetricCriteria);
            }
            else
            {
                MetricCriteria metricCriteria = new MetricCriteria(name: "metric1", metricName: this.MetricName, operatorProperty: this.Operator, timeAggregation: this.TimeAggregation, threshold: this.Threshold, metricNamespace: this.MetricNamespace, dimensions: metricDimensions, skipMetricValidation: this.SkipMetricValidation);
                result = new PSMetricCriteria(metricCriteria);
            }

            WriteObject(sendToPipeline: result);
        }