Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CloudWatch Alarms for Observability #12

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ const configureLogger = (context, callback) => {

// Set common error handler for logger.send() and logger.flush()
logger.error = (error, payload) => {
console.log('error', error, 'context', payload);
// console.log('error', error, 'context', payload);
console.log('SplunkHECError', error, 'URL', loggerConfig.url, 'Token', loggerConfig.token, 'context', payload);
callback(error);
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
import base64
import json
import gzip
import StringIO
import io
from io import StringIO
import boto3


Expand Down Expand Up @@ -86,7 +87,7 @@ def processRecords(records):
return_event['sourcetype'] = st
return_event['event'] = data['detail']

data = base64.b64encode(json.dumps(return_event))
data = base64.b64encode(json.dumps(return_event).encode('utf-8')).decode('utf-8')
yield {
'data': data,
'result': 'Ok',
Expand Down
130 changes: 130 additions & 0 deletions splunk-aws-automation/trumpet_full_v0.2.json
Original file line number Diff line number Diff line change
Expand Up @@ -1560,6 +1560,136 @@
]
}
}
},
"SplunkConfigNotificationDeliveryCloudWatchAlarm": {
"Type": "AWS::CloudWatch::Alarm",
"Properties": {
"AlarmName": "splunk-config-notification-delivery-fail",
"AlarmDescription": "Config notification failing to deliver to Splunk",
"Namespace": "AWS/Firehose",
"MetricName": "DeliveryToSplunk.Success",
"Dimensions": [
{
"Name": "DeliveryStreamName",
"Value": "splunk-confignotify-cwe-monitoring"
}
],
"Statistic": "Average",
"Period": 3600,
"EvaluationPeriods": 1,
"Threshold": 1,
"ComparisonOperator": "LessThanThreshold",
"TreatMissingData": "notBreaching",
"AlarmActions": [
{
"Fn::Sub": "arn:aws:sns:${AWS::Region}:${AWS::AccountId}:splunk-cloudwatch-alarms"
}
]
}
},
"SplunkConfigSnapshotDeliveryCloudWatchAlarm": {
"Type": "AWS::CloudWatch::Alarm",
"Properties": {
"AlarmName": "splunk-config-snapshot-delivery-fail",
"AlarmDescription": "Config snapshot failing to deliver to Splunk",
"Namespace": "SplunkHECStream",
"MetricName": "DepliveryError",
"Statistic": "Average",
"Period": 900,
"EvaluationPeriods": 1,
"Threshold": 5,
"ComparisonOperator": "GreaterThanOrEqualToThreshold",
"TreatMissingData": "notBreaching",
"AlarmActions": [
{
"Fn::Sub": "arn:aws:sns:${AWS::Region}:${AWS::AccountId}:splunk-cloudwatch-alarms"
}
]
}
},
"ConfigSnapshotStreamStatusFilter": {
"Type": "AWS::Logs::MetricFilter",
"Properties": {
"LogGroupName": {
"Fn::Join": [
"/",
[
"/aws/lambda",
{
"Ref": "BackingLambdaConfigLogProcessor"
}
]
]
},
"FilterPattern": "SplunkHECError",
"MetricTransformations": [
{
"MetricValue": "1",
"MetricNamespace": "SplunkHECStream",
"MetricName": "DepliveryError"
}
]
}
},
"SplunkCWAlarmTopic": {
"Type": "AWS::SNS::Topic",
"Properties": {
"TopicName": "splunk-cloudwatch-alarms"
}
},
"SplunkCWAlarmTopicPolicy": {
"Type": "AWS::SNS::TopicPolicy",
"Properties": {
"Topics": [
{
"Ref": "SplunkCWAlarmTopic"
}
],
"PolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Sid": "__default_statement_ID",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": [
"SNS:GetTopicAttributes",
"SNS:SetTopicAttributes",
"SNS:AddPermission",
"SNS:RemovePermission",
"SNS:DeleteTopic",
"SNS:Subscribe",
"SNS:ListSubscriptionsByTopic",
"SNS:Publish",
"SNS:Receive"
],
"Resource": {
"Ref": "SplunkCWAlarmTopic"
},
"Condition": {
"StringEquals": {
"AWS:SourceOwner": {
"Fn::Sub": "${AWS::AccountId}"
}
}
}
},
{
"Sid": "AllowCloudWatchEvents",
"Effect": "Allow",
"Principal": {
"Service": "events.amazonaws.com"
},
"Action": "sns:Publish",
"Resource": {
"Ref": "SplunkCWAlarmTopic"
}
}
]
}
}
}
}
}