func validateConfiguration()

in processor/metricstransformprocessor/factory.go [63:124]


func validateConfiguration(config *Config) error {
	for _, transform := range config.Transforms {
		if transform.MetricIncludeFilter.Include == "" {
			return fmt.Errorf("missing required field %q", includeFieldName)
		}

		if transform.MetricIncludeFilter.MatchType != "" && !transform.MetricIncludeFilter.MatchType.isValid() {
			return fmt.Errorf("%q must be in %q", matchTypeFieldName, matchTypes)
		}

		if transform.MetricIncludeFilter.MatchType == regexpMatchType {
			_, err := regexp.Compile(transform.MetricIncludeFilter.Include)
			if err != nil {
				return fmt.Errorf("%q, %w", includeFieldName, err)
			}
		}

		if !transform.Action.isValid() {
			return fmt.Errorf("%q must be in %q", actionFieldName, actions)
		}

		if transform.Action == Insert && transform.NewName == "" {
			return fmt.Errorf("missing required field %q while %q is %v", newNameFieldName, actionFieldName, Insert)
		}

		if transform.Action == Group && transform.GroupResourceLabels == nil {
			return fmt.Errorf("missing required field %q while %q is %v", groupResourceLabelsFieldName, actionFieldName, Group)
		}

		if transform.AggregationType != "" && !transform.AggregationType.IsValid() {
			return fmt.Errorf("%q must be in %q", aggregationTypeFieldName, aggregateutil.AggregationTypes)
		}

		if transform.SubmatchCase != "" && !transform.SubmatchCase.isValid() {
			return fmt.Errorf("%q must be in %q", submatchCaseFieldName, submatchCases)
		}

		for i, op := range transform.Operations {
			if !op.Action.isValid() {
				return fmt.Errorf("operation %v: %q must be in %q", i+1, actionFieldName, operationActions)
			}

			if op.Action == updateLabel && op.Label == "" {
				return fmt.Errorf("operation %v: missing required field %q while %q is %v", i+1, labelFieldName, actionFieldName, updateLabel)
			}
			if op.Action == addLabel && op.NewLabel == "" {
				return fmt.Errorf("operation %v: missing required field %q while %q is %v", i+1, newLabelFieldName, actionFieldName, addLabel)
			}
			if op.Action == addLabel && op.NewValue == "" {
				return fmt.Errorf("operation %v: missing required field %q while %q is %v", i+1, newValueFieldName, actionFieldName, addLabel)
			}
			if op.Action == scaleValue && op.Scale == 0 {
				return fmt.Errorf("operation %v: missing required field %q while %q is %v", i+1, scaleFieldName, actionFieldName, scaleValue)
			}

			if op.AggregationType != "" && !op.AggregationType.IsValid() {
				return fmt.Errorf("operation %v: %q must be in %q", i+1, aggregationTypeFieldName, aggregateutil.AggregationTypes)
			}
		}
	}
	return nil
}