MetricFilterProps Struct
Properties for a MetricFilter.
| Source | aws-logs/lib/metric-filter.ts |
|---|---|
| Type last changed |
Example
const repository = new ecr.Repository(this, 'TestRepository');
const runtime = new agentcore.Runtime(this, 'Runtime', {
agentRuntimeArtifact: agentcore.AgentRuntimeArtifact.fromEcrRepository(repository, 'v1.0.0'),
});
new logs.MetricFilter(this, 'ToolErrors', {
logGroup: runtime.applicationLogGroup,
filterPattern: logs.FilterPattern.stringValue('$.tool_status', '=', 'error'),
metricNamespace: 'MyApp',
metricName: 'ToolExecutionErrors',
});
repository = ecr.Repository(self, "TestRepository")
runtime = agentcore.Runtime(self, "Runtime",
agent_runtime_artifact=agentcore.AgentRuntimeArtifact.from_ecr_repository(repository, "v1.0.0")
)
logs.MetricFilter(self, "ToolErrors",
log_group=runtime.application_log_group,
filter_pattern=logs.FilterPattern.string_value("$.tool_status", "=", "error"),
metric_namespace="MyApp",
metric_name="ToolExecutionErrors"
)
Repository repository = new Repository(this, "TestRepository");
Runtime runtime = Runtime.Builder.create(this, "Runtime")
.agentRuntimeArtifact(AgentRuntimeArtifact.fromEcrRepository(repository, "v1.0.0"))
.build();
MetricFilter.Builder.create(this, "ToolErrors")
.logGroup(runtime.getApplicationLogGroup())
.filterPattern(FilterPattern.stringValue("$.tool_status", "=", "error"))
.metricNamespace("MyApp")
.metricName("ToolExecutionErrors")
.build();
// Install: dotnet add package Amazon.CDK.Lib
var repository = new Repository(this, "TestRepository");
var runtime = new Runtime(this, "Runtime", new RuntimeProps {
AgentRuntimeArtifact = AgentRuntimeArtifact.FromEcrRepository(repository, "v1.0.0")
});
new MetricFilter(this, "ToolErrors", new MetricFilterProps {
LogGroup = runtime.ApplicationLogGroup,
FilterPattern = FilterPattern.StringValue("$.tool_status", "=", "error"),
MetricNamespace = "MyApp",
MetricName = "ToolExecutionErrors"
});
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
repository := ecr.NewRepository(this, jsii.String("TestRepository"))
runtime := agentcore.NewRuntime(this, jsii.String("Runtime"), &RuntimeProps{
AgentRuntimeArtifact: agentcore.AgentRuntimeArtifact_FromEcrRepository(repository, jsii.String("v1.0.0")),
})
logs.NewMetricFilter(this, jsii.String("ToolErrors"), &MetricFilterProps{
LogGroup: runtime.applicationLogGroup,
FilterPattern: logs.FilterPattern_StringValue(jsii.String("$.tool_status"), jsii.String("="), jsii.String("error")),
MetricNamespace: jsii.String("MyApp"),
MetricName: jsii.String("ToolExecutionErrors"),
})
Properties
applyOnTransformedLogsoptionalbooleanapply_on_transformed_logsoptionalboolapplyOnTransformedLogsoptionalBooleanApplyOnTransformedLogsoptionalboolApplyOnTransformedLogsoptional*bool = false #This parameter is valid only for log groups that have an active log transformer. If this value is true, the metric filter is applied on the transformed version of the log events instead of the original ingested log events.
defaultValueoptionalnumberdefault_valueoptionalint | floatdefaultValueoptionalNumberDefaultValueoptionaldoubleDefaultValueoptional*float64 #Default: No metric emitted.
dimensionsoptional{ [key: string]: string }dimensionsoptionaltyping.Mapping[str, str]dimensionsoptionalMap<String, String>DimensionsoptionalIDictionary<string, string>Dimensionsoptional*map[string]*string #Default: No dimensions attached to metrics.
One metric filter can include as many as three dimensions.
filterNameoptionalstringfilter_nameoptionalstrfilterNameoptionalStringFilterNameoptionalstringFilterNameoptional*string #Default: Cloudformation generated name.
filterPatternIFilterPatternfilter_patternIFilterPatternfilterPatternIFilterPatternFilterPatternIFilterPatternFilterPatternIFilterPattern required #logGroupILogGroupReflog_groupILogGroupReflogGroupILogGroupRefLogGroupILogGroupRefLogGroupILogGroupRef required #metricNamespacestringmetric_namespacestrmetricNamespaceStringMetricNamespacestringMetricNamespace*string required #metricValueoptionalstringmetric_valueoptionalstrmetricValueoptionalStringMetricValueoptionalstringMetricValueoptional*string = "1" #notes
Can either be a literal number (typically "1"), or the name of a field in the structure to take the value from the matched event. If you are using a field value, the field value must have been matched using the pattern.
If you want to specify a field from a matched JSON structure, use '
If you want to specify a field from a matched space-delimited structure, use '$fieldName'.