-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmetric-stream.yaml
135 lines (123 loc) · 4.03 KB
/
metric-stream.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
AWSTemplateFormatVersion: "2010-09-09"
Description: "CloudFormation template for Highlight.io metrics integration"
Parameters:
HighlightProjectID:
Type: String
Description: Your Highlight.io Project ID
OTelEndpoint:
Type: String
Description: OpenTelemetry endpoint URL for metrics
Default: https://otel.highlight.io/v1/metrics
MonitoredRegions:
Type: CommaDelimitedList
Description: List of AWS regions to monitor (e.g., us-east-1,us-west-2)
Default: us-east-1
MetricNamespaces:
Type: CommaDelimitedList
Description: List of CloudWatch namespaces to monitor
Default: AWS/EC2,AWS/Lambda,AWS/RDS
Resources:
MetricStreamRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Principal:
Service: streams.metrics.cloudwatch.amazonaws.com
Action: sts:AssumeRole
Policies:
- PolicyName: MetricStreamPolicy
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Action:
- firehose:PutRecord
- firehose:PutRecordBatch
Resource: !GetAtt DeliveryStream.Arn
BackupBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: !Sub highlight-metrics-backup-${AWS::StackName}-${AWS::AccountId}
LifecycleConfiguration:
Rules:
- Id: DeleteOldBackups
Status: Enabled
ExpirationInDays: 14
FirehoseRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Principal:
Service: firehose.amazonaws.com
Action: sts:AssumeRole
Policies:
- PolicyName: FirehosePolicy
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Action:
- logs:CreateLogStream
- logs:PutLogEvents
Resource: !Sub arn:aws:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/kinesisfirehose/highlight-metrics-${AWS::StackName}:*
- Effect: Allow
Action:
- s3:PutObject
- s3:GetObject
Resource:
- !Sub ${BackupBucket.Arn}/*
DeliveryStream:
Type: AWS::KinesisFirehose::DeliveryStream
Properties:
DeliveryStreamName: !Sub highlight-metrics-${AWS::StackName}
DeliveryStreamType: DirectPut
HttpEndpointDestinationConfiguration:
EndpointConfiguration:
Url: !Ref OTelEndpoint
RequestConfiguration:
ContentEncoding: GZIP
CommonAttributes:
- Key: x-highlight-project
Value: !Ref HighlightProjectID
BufferingHints:
IntervalInSeconds: 60
SizeInMBs: 1
RoleARN: !GetAtt FirehoseRole.Arn
S3BackupMode: FailedDataOnly
S3Configuration:
BucketARN: !GetAtt BackupBucket.Arn
BufferingHints:
IntervalInSeconds: 300
SizeInMBs: 5
CompressionFormat: GZIP
RoleARN: !GetAtt FirehoseRole.Arn
Prefix: failed-metrics/
MetricStream:
Type: AWS::CloudWatch::MetricStream
Properties:
FirehoseArn: !GetAtt DeliveryStream.Arn
IncludeFilters:
Fn::Transform:
- Name: "AWS::Include"
Parameters:
Location: !Sub "${MetricNamespaces}"
OutputFormat: opentelemetry0.7
RoleArn: !GetAtt MetricStreamRole.Arn
Name: !Sub highlight-metric-stream-${AWS::StackName}
IncludeRegions: !Ref MonitoredRegions
Outputs:
MetricStreamArn:
Description: ARN of the created metric stream
Value: !GetAtt MetricStream.Arn
FirehoseArn:
Description: ARN of the created Kinesis Firehose
Value: !GetAtt DeliveryStream.Arn
BackupBucketName:
Description: Name of the S3 bucket for failed delivery backups
Value: !Ref BackupBucket