Skip to content

Commit

Permalink
Merge pull request #5 from dlcs/feature/metrics_update
Browse files Browse the repository at this point in the history
Updates to raised CW metrics
  • Loading branch information
donaldgray authored Oct 17, 2023
2 parents 2129855 + 301e377 commit 4cbf48a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
2 changes: 0 additions & 2 deletions .env-dist
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ CONNECTION_TIMEOUT=
AWS_PROFILE=
DRY_RUN=
ENABLE_CLOUDWATCH_INTEGRATION=
CLOUDWATCH_CUSTOMER_DIFFERENCE_METRIC_NAME=
CLOUDWATCH_SPACE_DIFFERENCE_METRIC_NAME=
CLOUDWATCH_SPACE_DELETE_METRIC_NAME=
CLOUDWATCH_CUSTOMER_DELETE_METRIC_NAME=
CLOUDWATCH_SPACE_IMAGE_SIZE_DIFFERENCE_METRIC_NAME=
CLOUDWATCH_SPACE_IMAGE_NUMBER_DIFFERENCE_METRIC_NAME=
CLOUDWATCH_SPACE_THUMBNAIL_SIZE_DIFFERENCE_METRIC_NAME=
10 changes: 5 additions & 5 deletions src/customer_storage_recalculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def begin_cleanup():
def set_cloudwatch_metrics(records, cloudwatch, connection_info):
metric_data = []
dimensions = [{
'Name': "TABLE_NAME",
'Name': "DATABASE_NAME",
'Value': connection_info["database"]
},
{
Expand All @@ -61,27 +61,27 @@ def set_cloudwatch_metrics(records, cloudwatch, connection_info):
{
'MetricName': CLOUDWATCH_SPACE_IMAGE_SIZE_DIFFERENCE_METRIC_NAME,
'Dimensions': dimensions,
'Unit': 'None',
'Unit': 'Bytes',
'Value': space_total_image_size_delta
},
{
'MetricName': CLOUDWATCH_SPACE_IMAGE_NUMBER_DIFFERENCE_METRIC_NAME,
'Dimensions': dimensions,
'Unit': 'None',
'Unit': 'Count',
'Value': space_total_image_number_delta
},
{
'MetricName': CLOUDWATCH_SPACE_THUMBNAIL_SIZE_DIFFERENCE_METRIC_NAME,
'Dimensions': dimensions,
'Unit': 'None',
'Unit': 'Bytes',
'Value': space_total_thumbnail_size_delta
}
])

try:
logger.debug(f"updating cloudwatch metrics - {metric_data}")
cloudwatch.put_metric_data(MetricData=metric_data,
Namespace='Entity Counter Recalculator')
Namespace='Protagonist Recalculator')
return metric_data
except Exception as e:
logger.error(f"Error posting to cloudwatch: {e}")
Expand Down
8 changes: 4 additions & 4 deletions src/entity_counter_recalculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def begin_cleanup():
def set_cloudwatch_metrics(records, cloudwatch, connection_info):
metric_data = []
dimensions = [{
'Name': "TABLE_NAME",
'Name': "DATABASE_NAME",
'Value': connection_info["database"]
},
{
Expand All @@ -61,21 +61,21 @@ def set_cloudwatch_metrics(records, cloudwatch, connection_info):
{
'MetricName': CLOUDWATCH_SPACE_DIFFERENCE_METRIC_NAME,
'Dimensions': dimensions,
'Unit': 'None',
'Unit': 'Count',
'Value': space_delta
},
{
'MetricName': CLOUDWATCH_SPACE_DELETE_METRIC_NAME,
'Dimensions': dimensions,
'Unit': 'None',
'Unit': 'Count',
'Value': space_deletes_needed
}
])

try:
logger.debug(f"updating cloudwatch metrics - {metric_data}")
cloudwatch.put_metric_data(MetricData=metric_data,
Namespace='Entity Counter Recalculator')
Namespace='Protagonist Recalculator')
return metric_data
except Exception as e:
logger.error(f"Error posting to cloudwatch: {e}")
Expand Down

0 comments on commit 4cbf48a

Please sign in to comment.