Skip to content

Commit

Permalink
Add resource type "metric filter" (aws-cloudformation#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
Maria Ines Parnisari authored May 19, 2020
1 parent b2b6b83 commit 6db90de
Show file tree
Hide file tree
Showing 27 changed files with 2,107 additions and 0 deletions.
20 changes: 20 additions & 0 deletions aws-logs-metricfilter/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# macOS
.DS_Store
._*

# Maven outputs
.classpath

# IntelliJ
*.iml
.idea/
out.java
out/
.settings
.project

# auto-generated files
target/

# our logs
rpdk.log
16 changes: 16 additions & 0 deletions aws-logs-metricfilter/.rpdk-config
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"typeName": "AWS::Logs::MetricFilter",
"language": "java",
"runtime": "java8",
"entrypoint": "software.amazon.logs.metricfilter.HandlerWrapper::handleRequest",
"testEntrypoint": "software.amazon.logs.metricfilter.HandlerWrapper::testEntrypoint",
"settings": {
"namespace": [
"software",
"amazon",
"logs",
"metricfilter"
],
"codegen_template_path": "guided_aws"
}
}
12 changes: 12 additions & 0 deletions aws-logs-metricfilter/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# AWS::Logs::MetricFilter

Congratulations on starting development! Next steps:

1. Write the JSON schema describing your resource, `aws-logs-metricfilter.json`
1. Implement your resource handlers.

The RPDK will automatically generate the correct resource model from the schema whenever the project is built via Maven. You can also do this manually with the following command: `cfn generate`.

> Please don't modify files under `target/generated-sources/rpdk`, as they will be automatically overwritten.
The code uses [Lombok](https://projectlombok.org/), and [you may have to install IDE integrations](https://projectlombok.org/setup/overview) to enable auto-complete for Lombok-annotated classes.
123 changes: 123 additions & 0 deletions aws-logs-metricfilter/aws-logs-metricfilter.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
{
"typeName": "AWS::Logs::MetricFilter",
"resourceLink": {
"templateUri": "/cloudwatch/home?region=${awsRegion}#logsV2:log-groups/log-group/${LogGroupName}/edit-metric-filter/${MetricName}",
"mappings": {
"MetricName": "/MetricName",
"LogGroupName": "/LogGroupName"
}
},
"description": "Specifies a metric filter that describes how CloudWatch Logs extracts information from logs and transforms it into Amazon CloudWatch metrics.",
"sourceUrl": "https://github.com/aws-cloudformation/aws-cloudformation-resource-providers-logs.git",
"definitions": {
"MetricTransformation": {
"type": "object",
"properties": {
"DefaultValue": {
"description": "The value to emit when a filter pattern does not match a log event. This value can be null.",
"type": "number"
},
"MetricName": {
"description": "The name of the CloudWatch metric. Metric name must be in ASCII format.",
"type": "string",
"minLength": 1,
"maxLength": 255,
"pattern": "^((?![:*$])[\\x00-\\x7F]){1,255}"
},
"MetricNamespace": {
"$comment": "Namespaces can be up to 256 characters long; valid characters include 0-9A-Za-z.-_/#",
"description": "The namespace of the CloudWatch metric.",
"type": "string",
"minLength": 1,
"maxLength": 256,
"pattern": "^[0-9a-zA-Z\\.\\-_\\/#]{1,256}"
},
"MetricValue": {
"description": "The value to publish to the CloudWatch metric when a filter pattern matches a log event.",
"type": "string",
"minLength": 1,
"maxLength": 100
}
},
"required": [
"MetricName",
"MetricNamespace",
"MetricValue"
],
"additionalProperties": false
}
},
"properties": {
"FilterName": {
"description": "A name for the metric filter.",
"type": "string",
"minLength": 1,
"maxLength": 512,
"pattern": "^[^:*]{1,512}"
},
"FilterPattern": {
"description": "Pattern that Logs follows to interpret each entry in a log.",
"type": "string",
"maxLength": 1024
},
"LogGroupName": {
"description": "Existing log group that you want to associate with this filter.",
"type": "string",
"minLength": 1,
"maxLength": 512,
"pattern": "^[.\\-_/#A-Za-z0-9]{1,512}"
},
"MetricTransformations": {
"description": "A collection of information that defines how metric data gets emitted.",
"type": "array",
"minItems": 1,
"maxItems": 1,
"items": {
"$ref": "#/definitions/MetricTransformation"
}
}
},
"handlers": {
"create": {
"permissions": [
"logs:PutMetricFilter",
"logs:DescribeMetricFilters"
]
},
"read": {
"permissions": [
"logs:DescribeMetricFilters"
]
},
"update": {
"permissions": [
"logs:PutMetricFilter",
"logs:DescribeMetricFilters"
]
},
"delete": {
"permissions": [
"logs:DeleteMetricFilter"
]
},
"list": {
"permissions": [
"logs:DescribeMetricFilters"
]
}
},
"required": [
"FilterPattern",
"LogGroupName",
"MetricTransformations"
],
"createOnlyProperties": [
"/properties/FilterName",
"/properties/LogGroupName"
],
"primaryIdentifier": [
"/properties/LogGroupName",
"/properties/FilterName"
],
"additionalProperties": false
}
1 change: 1 addition & 0 deletions aws-logs-metricfilter/lombok.config
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lombok.addLombokGeneratedAnnotation = true
14 changes: 14 additions & 0 deletions aws-logs-metricfilter/overrides.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"CREATE": {
"/LogGroupName": "this-is-a-random-loggroup",
"/FilterName": "my-metric-filter",
"/FilterPattern": "[size]",
"/MetricTransformations": [
{
"MetricValue": 10,
"MetricNamespace": "my-namespace",
"MetricName": "metric-name"
}
]
}
}
Loading

0 comments on commit 6db90de

Please sign in to comment.