Skip to content

Instantly share code, notes, and snippets.

@Insidexa
Created February 25, 2021 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Insidexa/eaa0899edaa323ccb95c0842ec7c9b3b to your computer and use it in GitHub Desktop.
Save Insidexa/eaa0899edaa323ccb95c0842ec7c9b3b to your computer and use it in GitHub Desktop.
cloudwatch memory usage ( CloudFormation, Elastic Beanstalk )
Resources:
CloudWatchRamDashboard:
Type: 'AWS::CloudWatch::Dashboard'
Properties:
DashboardName: !Sub '${ProjectId}-board'
DashboardBody: !Sub >-
{
"widgets": [
{
"type": "metric",
"properties": {
"metrics": [
[
{
"expression": "SEARCH('{${ProjectId}-backend,RAMPercent,InstanceId} MetricName=mem_used', 'Average', 30)",
"region": "us-east-1",
"label": "${!PROP('Dim.InstanceId')} used"
}
],
[
{
"expression": "SEARCH('{${ProjectId}-backend,RAMPercent,InstanceId} MetricName=mem_total', 'Average', 30)",
"region": "us-east-1",
"label": "${!PROP('Dim.InstanceId')} total"
}
]
],
"region": "${AWS::Region}",
"period": 300,
"view": "timeSeries",
"stat": "Average",
"stacked": false,
"title": "${ProjectId}-backend-ram",
"setPeriodToTimeRange": true
}
},
{
"type": "metric",
"properties": {
"metrics": [
[
{
"expression": "SEARCH('{${ProjectId}-worker,RAMPercent,InstanceId} MetricName=mem_used', 'Average', 30)",
"region": "us-east-1",
"label": "${!PROP('Dim.InstanceId')} used"
}
],
[
{
"expression": "SEARCH('{${ProjectId}-worker,RAMPercent,InstanceId} MetricName=mem_total', 'Average', 30)",
"region": "us-east-1",
"label": "${!PROP('Dim.InstanceId')} total"
}
]
],
"region": "${AWS::Region}",
"period": 300,
"view": "timeSeries",
"stat": "Average",
"stacked": false,
"title": "${ProjectId}-worker-ram",
"setPeriodToTimeRange": true
}
}
]
}
{
"agent": {
"metrics_collection_interval": 30,
"run_as_user": "root"
},
"metrics": {
"namespace": "${ProjectId}", // replace ${ProjectId} to custom namespace name and remove this comment
"append_dimensions": {
"InstanceId": "${aws:InstanceId}"
},
"metrics_collected": {
"mem": {
"append_dimensions": {
"RAMPercent": "${ProjectId}-ram" // replace ${ProjectId} to custom namespace name and remove this comment
},
"measurement": [
{ "name": "mem_total", "unit": "Percent" },
{ "name": "mem_used", "unit": "Percent" }
],
"metrics_collection_interval": 30
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment