"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.MetricFilter=void 0;const jsiiDeprecationWarnings=require("../../.warnings.jsii.js"),JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti"),logs_generated_1=require("./logs.generated"),aws_cloudwatch_1=require("../../aws-cloudwatch"),core_1=require("../../core");class MetricFilter extends core_1.Resource{constructor(scope,id,props){super(scope,id,{physicalName:props.filterName});try{jsiiDeprecationWarnings.aws_cdk_lib_aws_logs_MetricFilterProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,MetricFilter),error}this.metricName=props.metricName,this.metricNamespace=props.metricNamespace;const numberOfDimensions=Object.keys(props.dimensions??{}).length;if(numberOfDimensions>3)throw new Error(`MetricFilter only supports a maximum of 3 dimensions but received ${numberOfDimensions}.`);new logs_generated_1.CfnMetricFilter(this,"Resource",{logGroupName:props.logGroup.logGroupName,filterName:this.physicalName,filterPattern:props.filterPattern.logPatternString,metricTransformations:[{metricNamespace:props.metricNamespace,metricName:props.metricName,metricValue:props.metricValue??"1",defaultValue:props.defaultValue,dimensions:props.dimensions?Object.entries(props.dimensions).map(([key,value])=>({key,value})):void 0,unit:props.unit}]})}metric(props){try{jsiiDeprecationWarnings.aws_cdk_lib_aws_cloudwatch_MetricOptions(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.metric),error}return new aws_cloudwatch_1.Metric({metricName:this.metricName,namespace:this.metricNamespace,statistic:"avg",...props}).attachTo(this)}}exports.MetricFilter=MetricFilter,_a=JSII_RTTI_SYMBOL_1,MetricFilter[_a]={fqn:"aws-cdk-lib.aws_logs.MetricFilter",version:"2.96.1"};
