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);
        }
Example #2
0
 IWithConditionAttach <MetricAlert.Update.IUpdate> IWithFailingPeriods <MetricAlert.Update.IUpdate> .WithFailingPeriods(DynamicThresholdFailingPeriods failingPeriods)
 {
     return(this.WithFailingPeriods(failingPeriods));
 }
Example #3
0
 IUpdateStages IUpdateStages.WithFailingPeriods(DynamicThresholdFailingPeriods failingPeriods)
 {
     return(this.WithFailingPeriods(failingPeriods));
 }
Example #4
0
 IWithConditionAttach <MetricAlert.Definition.IWithCreateDynamicCondition> IWithFailingPeriods <MetricAlert.Definition.IWithCreateDynamicCondition> .WithFailingPeriods(DynamicThresholdFailingPeriods failingPeriods)
 {
     return(this.WithFailingPeriods(failingPeriods));
 }
Example #5
0
 public MetricDynamicAlertConditionImpl WithFailingPeriods(DynamicThresholdFailingPeriods failingPeriods)
 {
     this.Inner.FailingPeriods = failingPeriods;
     return(this);
 }