-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Chirag Soni <[email protected]>
- Loading branch information
1 parent
f34a803
commit b936e22
Showing
10 changed files
with
327 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file removed
BIN
-5.73 MB
...ynamodbOverCloudtrailPackage/DynamoDB/logstash-filter-dynamodb_guardium_plugin_filter.zip
Binary file not shown.
63 changes: 63 additions & 0 deletions
63
...h-filter-dynamodb-guardium/DynamodbOverCloudwatchPackage/DynamoDB/dynamodbCloudwatch.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# | ||
# Copyright 2022-2023 IBM Inc. All rights reserved | ||
# SPDX-License-Identifier: Apache2.0 | ||
# | ||
|
||
input{ | ||
cloudwatch_logs { | ||
#Mandatory arguments: | ||
log_group => ["<Enter the aws log group>"] #e.g., ["aws-dynamodb-logs"] | ||
access_key_id => "<Enter the access key id>" | ||
secret_access_key => "<Enter the secret access key id>" | ||
region => "<Enter aws region>" #Region that has the DB, Default value: us-east-1 | ||
start_position => "end" | ||
interval => 5 | ||
event_filter => "" | ||
type => "dynamodb" | ||
#Insert the account id of the AWS account where dynamodb is present. | ||
add_field => {"account_id" => "<Enter Aws account Id>"} | ||
} | ||
} | ||
|
||
filter { | ||
if [type] == 'dynamodb' { | ||
json { | ||
source => "message" | ||
target => "parsed_json" | ||
} | ||
|
||
if [parsed_json][detail] { | ||
|
||
mutate { | ||
add_field => { | ||
"new_event_source" => "%{[parsed_json][detail][eventSource]}" | ||
} | ||
|
||
replace => { | ||
"message" => "%{[parsed_json][detail]}" | ||
} | ||
} | ||
|
||
} else { | ||
|
||
mutate { | ||
add_field => { | ||
"new_event_source" => "%{[parsed_json][eventSource]}" | ||
} | ||
} | ||
} | ||
|
||
ruby { code => 'event.set("message", event.get("message").to_s)' } | ||
|
||
if [new_event_source] { | ||
if[new_event_source] =~ "dynamodb.amazonaws.com" { | ||
dynamodb_guardium_plugin_filter {} | ||
} | ||
else { | ||
drop {} | ||
} | ||
} | ||
|
||
prune { whitelist_names => [ "GuardRecord" ] } | ||
} | ||
} |
23 changes: 0 additions & 23 deletions
23
...ugin/logstash-filter-dynamodb-guardium/DynamodbOverCloudwatchPackage/DynamoDB/filter.conf
This file was deleted.
Oops, something went wrong.
Binary file removed
BIN
-5.73 MB
...ynamodbOverCloudwatchPackage/DynamoDB/logstash-filter-dynamodb_guardium_plugin_filter.zip
Binary file not shown.
48 changes: 48 additions & 0 deletions
48
...in/logstash-filter-dynamodb-guardium/DynamodbOverSQSPackage/DynamoDB/dynamodbOverSqs.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# | ||
# Copyright 2022-2023 IBM Inc. All rights reserved | ||
# SPDX-License-Identifier: Apache2.0 | ||
# | ||
|
||
input{ | ||
sqs { | ||
access_key_id => "<Enter the access key id>" | ||
secret_access_key => "<Enter the secret access key id>" | ||
region => "<Enter aws region>" #Region that has the Queue, Default value: us-east-1 | ||
queue => "<Enter the sqs queue name>" #This parameter simply holds the Queue name and not the URL | ||
codec => plain | ||
type => "dynamodb" | ||
#Insert the account id of the AWS account | ||
add_field => {"account_id" => "<Enter aws account id>"} | ||
} | ||
} | ||
|
||
filter { | ||
if [type] == "Dynamodb" { | ||
mutate { gsub => [ "message", "'", '"' ] } | ||
mutate { gsub => [ "message", '\"', '"' ] } | ||
mutate { gsub => [ "message", '"{', '{' ] } | ||
mutate { gsub => [ "message", '}"', '}' ] } | ||
json { | ||
source => "message" | ||
target => "parsed_json" | ||
} | ||
mutate { | ||
add_field => { | ||
"new_event_source" => "%{[parsed_json][message][eventSource]}" | ||
} | ||
replace => { | ||
"message" => "%{[parsed_json][message]}" | ||
} | ||
} | ||
if [new_event_source] { | ||
if[new_event_source] =~ "dynamodb.amazonaws.com" { | ||
dynamodb_guardium_plugin_filter {} | ||
} | ||
else { | ||
drop {} | ||
} | ||
} | ||
|
||
mutate { remove_field => [ "parsed_json", "new_event_source", "message", "cloudwatch_logs", "@timestamp", "@version", "type", "host", "sequence" ] } | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
filter-plugin/logstash-filter-dynamodb-guardium/DynamodbOverSQSPackage/lambda.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# | ||
# Copyright 2022-2023 IBM Inc. All rights reserved | ||
# SPDX-License-Identifier: Apache2.0 | ||
# | ||
|
||
import boto3 | ||
import os | ||
from datetime import datetime, timedelta | ||
GROUP_NAME = os.environ['GROUP_NAME'] | ||
QUEUE_NAME = os.environ['QUEUE_NAME'] | ||
|
||
def lambda_handler(event, context): | ||
|
||
currentTime = datetime.now() | ||
StartDate = currentTime - timedelta(minutes = 2) | ||
EndDate = currentTime | ||
|
||
|
||
fromDate = int(StartDate.timestamp() * 1000) | ||
toDate = int(EndDate.timestamp() * 1000) | ||
|
||
|
||
client = boto3.client('logs') | ||
sqs = boto3.client('sqs') | ||
|
||
logGroupDetails = client.describe_log_streams( | ||
logGroupName = GROUP_NAME, | ||
orderBy = 'LastEventTime', | ||
descending = True | ||
) | ||
|
||
for logStream in logGroupDetails['logStreams'] : | ||
logStreamNameObt = logStream['logStreamName'] | ||
response = client.get_log_events( | ||
logGroupName=GROUP_NAME, | ||
logStreamName=logStreamNameObt, | ||
startTime=fromDate, | ||
endTime=toDate, | ||
startFromHead=True, | ||
) | ||
|
||
for event in response['events'] : | ||
sqs.send_message( | ||
QueueUrl = QUEUE_NAME, | ||
MessageBody=str(event) | ||
) | ||
|
||
print("New response",response) |
Oops, something went wrong.