Skip to content

Commit

Permalink
Merge pull request #17 from SumoLogic/SUMO-232581-sam-infra
Browse files Browse the repository at this point in the history
Updating MongoDB SAM app to python3.11
  • Loading branch information
himanshu219 authored Dec 13, 2023
2 parents d7f9bdc + ac52caa commit 7a74be9
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 10 deletions.
10 changes: 5 additions & 5 deletions packaged.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ Metadata:
- atlas
- serverless
- MongoDBAtlas
LicenseUrl: s3://appdevstore/MongoDBAtlas/v1.0.15/5122657d5b9a0d3713e24d3a33eae431
LicenseUrl: s3://appdevstore/MongoDBAtlas/v1.0.17/5122657d5b9a0d3713e24d3a33eae431
Name: sumologic-mongodb-atlas
ReadmeUrl: s3://appdevstore/MongoDBAtlas/v1.0.15/5866849a98131c58cb7edb85893d4414
SemanticVersion: 1.0.15
ReadmeUrl: s3://appdevstore/MongoDBAtlas/v1.0.17/3088978c83fe207a640a2584aff2c79d
SemanticVersion: 1.0.17
SourceCodeUrl: https://github.com/SumoLogic/sumologic-mongodb-atlas
SpdxLicenseId: Apache-2.0
Outputs:
Expand All @@ -44,7 +44,7 @@ Parameters:
Resources:
MongoDBAtlasFunction:
Properties:
CodeUri: s3://appdevstore/MongoDBAtlas/v1.0.15/60d2a1994510235d0222728d75fe810f
CodeUri: s3://appdevstore/MongoDBAtlas/v1.0.17/56c4530782ed537044f71da21d57b605
Environment:
Variables:
ENABLE_CONSOLE_LOG: 'false'
Expand All @@ -70,7 +70,7 @@ Resources:
MemorySize: 256
Policies:
- AmazonDynamoDBFullAccess
Runtime: python3.7
Runtime: python3.11
Timeout: 900
Type: AWS::Serverless::Function
Metadata:
Expand Down
20 changes: 18 additions & 2 deletions sumomongodbatlascollector/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ def get_state(self):
obj = self.kvstore.get(key)
return obj

# API Ref: https://www.mongodb.com/docs/atlas/reference/api-resources-spec/v1/#tag/Monitoring-and-Logs/operation/downloadHostLogs
def build_fetch_params(self):
start_time_epoch, end_time_epoch = self.get_window(self.get_state()['last_time_epoch'])

Expand Down Expand Up @@ -296,6 +297,7 @@ def get_state(self):
obj = self.kvstore.get(key)
return obj

# API Ref: https://www.mongodb.com/docs/atlas/reference/api-resources-spec/v1/#tag/Monitoring-and-Logs/operation/getHostMeasurements
def build_fetch_params(self):
start_time_epoch, end_time_epoch = self.get_window(self.get_state()['last_time_epoch'])
start_time_date = convert_epoch_to_utc_date(start_time_epoch, date_format=self.isoformat)
Expand Down Expand Up @@ -368,7 +370,7 @@ def get_state(self):
self.save_state(self.DEFAULT_START_TIME_EPOCH)
obj = self.kvstore.get(key)
return obj

# API Ref: https://www.mongodb.com/docs/atlas/reference/api-resources-spec/v1/#tag/Monitoring-and-Logs/operation/getDiskMeasurements
def build_fetch_params(self):
start_time_epoch, end_time_epoch = self.get_window(self.get_state()['last_time_epoch'])
start_time_date = convert_epoch_to_utc_date(start_time_epoch, date_format=self.isoformat)
Expand Down Expand Up @@ -443,6 +445,7 @@ def get_state(self):
obj = self.kvstore.get(key)
return obj

# API Ref: https://www.mongodb.com/docs/atlas/reference/api-resources-spec/v1/#tag/Monitoring-and-Logs/operation/getDatabaseMeasurements
def build_fetch_params(self):
start_time_epoch, end_time_epoch = self.get_window(self.get_state()['last_time_epoch'])
start_time_date = convert_epoch_to_utc_date(start_time_epoch, date_format=self.isoformat)
Expand Down Expand Up @@ -510,6 +513,7 @@ def get_state(self):
obj = self.kvstore.get(key)
return obj

# API Ref: https://www.mongodb.com/docs/atlas/reference/api-resources-spec/v1/#tag/Events/operation/listProjectEvents
def build_fetch_params(self):
state = self.get_state()
if state["page_num"] == 0:
Expand Down Expand Up @@ -546,6 +550,9 @@ def check_move_fetch_window(self, kwargs):

def transform_data(self, data):

# assuming file content is small so inmemory possible
# https://stackoverflow.com/questions/11914472/stringio-in-python3
# https://stackoverflow.com/questions/8858414/using-python-how-do-you-untar-purely-in-memory
last_time_epoch = self.DEFAULT_START_TIME_EPOCH
event_logs = []
for obj in data['results']:
Expand Down Expand Up @@ -577,6 +584,7 @@ def get_state(self):
obj = self.kvstore.get(key)
return obj

# API Ref: https://www.mongodb.com/docs/atlas/reference/api-resources-spec/v1/#tag/Events/operation/listOrganizationEvents
def build_fetch_params(self):
state = self.get_state()
if state["page_num"] == 0:
Expand Down Expand Up @@ -613,6 +621,9 @@ def check_move_fetch_window(self, kwargs):

def transform_data(self, data):

# assuming file content is small so inmemory possible
# https://stackoverflow.com/questions/11914472/stringio-in-python3
# https://stackoverflow.com/questions/8858414/using-python-how-do-you-untar-purely-in-memory
last_time_epoch = self.DEFAULT_START_TIME_EPOCH
event_logs = []
for obj in data['results']:
Expand Down Expand Up @@ -646,6 +657,7 @@ def get_state(self):
obj = self.kvstore.get(key)
return obj

# API Ref: https://www.mongodb.com/docs/atlas/reference/api-resources-spec/v1/#tag/Alerts/operation/listAlerts
def build_fetch_params(self):
state = self.get_state()
if state["page_num"] == 0:
Expand All @@ -666,6 +678,10 @@ def build_send_params(self):

def transform_data(self, data):

# assuming file content is small so inmemory possible
# https://stackoverflow.com/questions/11914472/stringio-in-python3
# https://stackoverflow.com/questions/8858414/using-python-how-do-you-untar-purely-in-memory

event_logs = []
for obj in data['results']:
event_logs.append(obj)
Expand Down Expand Up @@ -727,4 +743,4 @@ def fetch(self):
next_request = fetch_success and send_success and has_next_page and self.is_time_remaining()
finally:
sess.close()
self.log.info(f'''Completed LogType: {log_type} Count: {count} Page: {kwargs['params']['pageNum']}''')
self.log.info(f'''Completed LogType: {log_type} Count: {count} Page: {kwargs['params']['pageNum']}''')
1 change: 0 additions & 1 deletion sumomongodbatlascollector/mongodbatlas.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ MongoDBAtlas:
DISK_METRICS:
- DISK_PARTITION_IOPS_READ
- DISK_PARTITION_IOPS_WRITE
- DISK_PARTITION_UTILIZATION
- DISK_PARTITION_LATENCY_READ
- DISK_PARTITION_LATENCY_WRITE
- DISK_PARTITION_SPACE_PERCENT_FREE
Expand Down
4 changes: 2 additions & 2 deletions template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Metadata:
LicenseUrl: ./LICENSE
Name: sumologic-mongodb-atlas
ReadmeUrl: ./README.md
SemanticVersion: 1.0.16
SemanticVersion: 1.0.17
SourceCodeUrl: https://github.com/SumoLogic/sumologic-mongodb-atlas
SpdxLicenseId: Apache-2.0
Outputs:
Expand Down Expand Up @@ -70,7 +70,7 @@ Resources:
MemorySize: 256
Policies:
- AmazonDynamoDBFullAccess
Runtime: python3.7
Runtime: python3.11
Timeout: 900
Type: AWS::Serverless::Function
Transform: AWS::Serverless-2016-10-31

0 comments on commit 7a74be9

Please sign in to comment.