"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"),aws_cloudwatch_1=require("../../aws-cloudwatch"),core_1=require("../../core"),logs_generated_1=require("./logs.generated");class MetricFilter extends core_1.Resource{constructor(scope,id,props){super(scope,id);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}if(this.metricName=props.metricName,this.metricNamespace=props.metricNamespace,Object.keys(props.dimensions??{}).length>3)throw new Error("MetricFilter only supports a maximum of 3 Dimensions");new logs_generated_1.CfnMetricFilter(this,"Resource",{logGroupName:props.logGroup.logGroupName,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}]})}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.46.0"};
//# sourceMappingURL=metric-filter.js.map
