Skip to content

Instantly share code, notes, and snippets.

@DaisukeMiyamoto
Last active March 24, 2020 17:18
Show Gist options
  • Select an option

  • Save DaisukeMiyamoto/17c7356ec9dad7afb60fa2a45fc4c7f7 to your computer and use it in GitHub Desktop.

Select an option

Save DaisukeMiyamoto/17c7356ec9dad7afb60fa2a45fc4c7f7 to your computer and use it in GitHub Desktop.
CloudFormation template for creating Amazon EFS Dashboard based on https://github.com/aws-samples/amazon-efs-tutorial/tree/master/monitoringto exclude IAM permission.
---
AWSTemplateFormatVersion: 2010-09-09
Description: Creates an Amazon CloudWatch dashboard with Metric Math expressions to monitor an Amazon EFS file system. Customized for exclude IAM permissions.
Metadata:
Authors:
Description: Darryl Osborne ([email protected]) / Modified by midaisuk@
License:
Description: 'Copyright 2018 Amazon.com, Inc. and its affiliates. All Rights Reserved.
Licensed under the Amazon Software License (the "License"). You may not use this file
except in compliance with the License. A copy of the License is located at
http://aws.amazon.com/asl/
or in the "license" file accompanying this file. This file is distributed on an "AS IS"
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations under the License.'
AWS::CloudFormation::Interface:
ParameterGroups:
- Label:
default: File System Parameters
Parameters:
- ElasticFileSystem
- DeletionPolicy
ParameterLabels:
DeletionPolicy:
default: Retain or Delete
ElasticFileSystem:
default: Amazon EFS File System
Parameters:
DeletionPolicy:
AllowedValues:
- Delete
- Retain
Default: Delete
Description: Retain or delete the Amazon EFS Dashboard after the CloudFormation stack is deleted.
Type: String
ElasticFileSystem:
AllowedPattern: ^(fs-)([a-z0-9]{8})$
Description: Amazon EFS file system id.
Type: String
Conditions:
Delete:
!Equals [ !Ref DeletionPolicy, Delete ]
Retain:
!Equals [ !Ref DeletionPolicy, Retain ]
Resources:
EfsDashboardRetain:
Type: AWS::CloudWatch::Dashboard
Condition: Retain
DeletionPolicy: Retain
Properties:
DashboardName: !Join [ '_', [ !Ref 'AWS::Region', !Ref ElasticFileSystem, 'mm' ] ]
DashboardBody:
!Sub |
{
"widgets": [
{
"type": "metric",
"x": 0,
"y": 3,
"width": 15,
"height": 9,
"properties": {
"view": "timeSeries",
"stacked": false,
"metrics": [
[ { "expression": "(m1/1048576)/PERIOD(m1)", "label": "Total Throughput (MiB/s)", "id": "e1", "yAxis": "left", "color": "#2ca02c" } ],
[ { "expression": "(m2/1048576)/PERIOD(m2)", "label": "Data Write Throughput (MiB/s)", "id": "e2", "yAxis": "left", "color": "#1f77b4" } ],
[ { "expression": "(m3/1048576)/PERIOD(m3)", "label": "Data Read Throughput (MiB/s)", "id": "e3", "yAxis": "left", "color": "#ff7f0e" } ],
[ { "expression": "(m4/1048576)/PERIOD(m4)", "label": "Metadata Throughput (MiB/s)", "id": "e4", "yAxis": "left", "color": "#d62728" } ],
[ "AWS/EFS", "TotalIOBytes", "FileSystemId", "${ElasticFileSystem}", { "id": "m1", "stat": "Sum", "period": 60, "yAxis": "right", "visible": false } ],
[ ".", "DataWriteIOBytes", ".", ".", { "period": 60, "stat": "Sum", "id": "m2", "yAxis": "right", "visible": false } ],
[ ".", "DataReadIOBytes", ".", ".", { "period": 60, "stat": "Sum", "id": "m3", "yAxis": "right", "visible": false } ],
[ ".", "MetadataIOBytes", ".", ".", { "period": 60, "stat": "Sum", "id": "m4", "yAxis": "right", "visible": false } ]
],
"region": "${AWS::Region}",
"period": 60,
"title": "Total Throughput (MiB/s)"
}
},
{
"type": "metric",
"x": 15,
"y": 18,
"width": 9,
"height": 6,
"properties": {
"view": "timeSeries",
"stacked": false,
"metrics": [
[ { "expression": "(m1/1024)/m2", "label": "Data Write IO Size (KiB)", "id": "e1", "color": "#1f77b4" } ],
[ { "expression": "(m3/1024)/m4", "label": "Data Read IO Size (KiB)", "id": "e2", "color": "#ff7f0e" } ],
[ { "expression": "(m5/1024)/m6", "label": "Metadata IO Size (KiB)", "id": "e3", "color": "#d62728" } ],
[ "AWS/EFS", "DataWriteIOBytes", "FileSystemId", "${ElasticFileSystem}", { "stat": "Sum", "period": 60, "id": "m1", "visible": false } ],
[ "...", { "stat": "SampleCount", "period": 60, "id": "m2", "visible": false } ],
[ ".", "DataReadIOBytes", ".", ".", { "period": 60, "stat": "Sum", "id": "m3", "visible": false } ],
[ "...", { "period": 60, "stat": "SampleCount", "id": "m4", "visible": false } ],
[ ".", "MetadataIOBytes", ".", ".", { "period": 60, "stat": "Sum", "id": "m5", "visible": false } ],
[ "...", { "period": 60, "stat": "SampleCount", "id": "m6", "visible": false } ]
],
"region": "${AWS::Region}",
"title": "Avg. IO Size (KiB)",
"period": 60
}
},
{
"type": "metric",
"x": 0,
"y": 18,
"width": 15,
"height": 6,
"properties": {
"view": "timeSeries",
"stacked": false,
"metrics": [
[ { "expression": "((m1/1048576)/PERIOD(m1))", "label": "Avgerage Throughput (MiB/s)", "id": "e1", "period": 60, "color": "#2ca02c", "yAxis": "right" } ],
[ { "expression": "(m2/1048576)", "label": "Permitted Throughput", "id": "e2" } ],
[ { "expression": "e2-e1", "label": "Available Throughput (MiB/s)", "id": "e3", "color": "#17becf" } ],
[ { "expression": "((e1)*100)/(e2)", "label": "Percent Throughput Utilization (%)", "id": "e3" } ],
[ "AWS/EFS", "TotalIOBytes", "FileSystemId", "${ElasticFileSystem}", { "id": "m1", "visible": false } ],
[ ".", "PermittedThroughput", ".", ".", { "id": "m2", "visible": false, "stat": "Average" } ]
],
"region": "${AWS::Region}",
"title": "Throughput Utilization (MiB/s)",
"period": 60
}
},
{
"type": "metric",
"x": 15,
"y": 3,
"width": 9,
"height": 9,
"properties": {
"view": "timeSeries",
"stacked": false,
"metrics": [
[ { "expression": "(m1)/PERIOD(m1)", "label": "Total iops", "id": "e1", "yAxis": "left", "stat": "SampleCount", "color": "#2ca02c" } ],
[ { "expression": "(m2)/PERIOD(m2)", "label": "Data Write iops", "id": "e2", "stat": "SampleCount", "color": "#1f77b4" } ],
[ { "expression": "(m3)/PERIOD(m3)", "label": "Data Read iops", "id": "e3", "stat": "SampleCount", "color": "#ff7f0e" } ],
[ { "expression": "(m4)/PERIOD(m4)", "label": "Metadata iops", "id": "e4", "stat": "SampleCount", "color": "#d62728" } ],
[ "AWS/EFS", "TotalIOBytes", "FileSystemId", "${ElasticFileSystem}", { "id": "m1", "stat": "SampleCount", "period": 60, "visible": false } ],
[ ".", "DataWriteIOBytes", ".", ".", { "period": 60, "stat": "SampleCount", "id": "m2", "visible": false } ],
[ ".", "DataReadIOBytes", ".", ".", { "period": 60, "stat": "SampleCount", "id": "m3", "visible": false } ],
[ ".", "MetadataIOBytes", ".", ".", { "period": 60, "stat": "SampleCount", "id": "m4", "visible": false } ]
],
"region": "${AWS::Region}",
"period": 60,
"title": "Total IOPS"
}
},
{
"type": "metric",
"x": 15,
"y": 12,
"width": 9,
"height": 6,
"properties": {
"view": "timeSeries",
"metrics": [
[ { "expression": "m2*100/m1", "label": "Data Write (%)", "id": "e1", "color": "#1f77b4" } ],
[ { "expression": "m3*100/m1", "label": "Data Read (%)", "id": "e2", "color": "#ff7f0e" } ],
[ { "expression": "m4*100/m1", "label": "Metadata (%)", "id": "e3", "color": "#d62728" } ],
[ "AWS/EFS", "TotalIOBytes", "FileSystemId", "${ElasticFileSystem}", { "stat": "SampleCount", "period": 60, "id": "m1", "visible": false } ],
[ ".", "DataWriteIOBytes", ".", ".", { "stat": "SampleCount", "period": 60, "id": "m2", "visible": false } ],
[ ".", "DataReadIOBytes", ".", ".", { "stat": "SampleCount", "period": 60, "id": "m3", "visible": false } ],
[ ".", "MetadataIOBytes", ".", ".", { "stat": "SampleCount", "period": 60, "id": "m4", "visible": false } ]
],
"region": "${AWS::Region}",
"stacked": false,
"title": "Percent IOPS Type",
"period": 60
}
},
{
"type": "metric",
"x": 0,
"y": 12,
"width": 15,
"height": 6,
"properties": {
"view": "timeSeries",
"metrics": [
[ { "expression": "m2*100/m1", "label": "Data Write (%)", "id": "e1", "stat": "Sum", "color": "#1f77b4" } ],
[ { "expression": "m3*100/m1", "label": "Data Read (%)", "id": "e2", "stat": "Sum", "color": "#ff7f0e" } ],
[ { "expression": "m4*100/m1", "label": "Metadata (%)", "id": "e3", "stat": "Sum", "color": "#d62728" } ],
[ "AWS/EFS", "TotalIOBytes", "FileSystemId", "${ElasticFileSystem}", { "stat": "Sum", "period": 60, "id": "m1", "visible": false } ],
[ ".", "DataWriteIOBytes", ".", ".", { "stat": "Sum", "period": 60, "id": "m2", "visible": false } ],
[ ".", "DataReadIOBytes", ".", ".", { "stat": "Sum", "period": 60, "id": "m3", "visible": false } ],
[ ".", "MetadataIOBytes", ".", ".", { "stat": "Sum", "period": 60, "id": "m4", "visible": false } ]
],
"region": "${AWS::Region}",
"stacked": false,
"title": "Percent Throughput Type",
"period": 60
}
},
{
"type": "text",
"x": 15,
"y": 0,
"width": 9,
"height": 3,
"properties": {
"markdown": "\n# Amazon EFS file system: ${ElasticFileSystem}\n## Region: ${AWS::Region}\n"
}
},
{
"type": "metric",
"x": 0,
"y": 0,
"width": 15,
"height": 3,
"styles": "undefined",
"properties": {
"view": "singleValue",
"metrics": [
[ { "expression": "m2/1048576", "label": "Permitted Throughput (MiB/s)", "id": "e1" } ],
[ "Custom/EFS", "SizeInBytes", "FileSystemId", "${ElasticFileSystem}", { "label": "Metered Size (Bytes)", "id": "m1" } ],
[ "AWS/EFS", "PermittedThroughput", ".", ".", { "label": "Permitted Throughput", "id": "m2", "visible": false } ],
[ ".", "BurstCreditBalance", ".", ".", { "label": "BurstCreditBalance", "id": "m3" } ]
],
"region": "${AWS::Region}",
"period": 60,
"title": "File system metrics"
}
}
]
}
EfsDashboardDelete:
Type: AWS::CloudWatch::Dashboard
Condition: Delete
DeletionPolicy: Delete
Properties:
DashboardName: !Join [ '_', [ !Ref 'AWS::Region', !Ref ElasticFileSystem, 'mm' ] ]
DashboardBody:
!Sub |
{
"widgets": [
{
"type": "metric",
"x": 0,
"y": 3,
"width": 15,
"height": 9,
"properties": {
"view": "timeSeries",
"stacked": false,
"metrics": [
[ { "expression": "(m1/1048576)/PERIOD(m1)", "label": "Total Throughput (MiB/s)", "id": "e1", "yAxis": "left", "color": "#2ca02c" } ],
[ { "expression": "(m2/1048576)/PERIOD(m2)", "label": "Data Write Throughput (MiB/s)", "id": "e2", "yAxis": "left", "color": "#1f77b4" } ],
[ { "expression": "(m3/1048576)/PERIOD(m3)", "label": "Data Read Throughput (MiB/s)", "id": "e3", "yAxis": "left", "color": "#ff7f0e" } ],
[ { "expression": "(m4/1048576)/PERIOD(m4)", "label": "Metadata Throughput (MiB/s)", "id": "e4", "yAxis": "left", "color": "#d62728" } ],
[ "AWS/EFS", "TotalIOBytes", "FileSystemId", "${ElasticFileSystem}", { "id": "m1", "stat": "Sum", "period": 60, "yAxis": "right", "visible": false } ],
[ ".", "DataWriteIOBytes", ".", ".", { "period": 60, "stat": "Sum", "id": "m2", "yAxis": "right", "visible": false } ],
[ ".", "DataReadIOBytes", ".", ".", { "period": 60, "stat": "Sum", "id": "m3", "yAxis": "right", "visible": false } ],
[ ".", "MetadataIOBytes", ".", ".", { "period": 60, "stat": "Sum", "id": "m4", "yAxis": "right", "visible": false } ]
],
"region": "${AWS::Region}",
"period": 60,
"title": "Total Throughput (MiB/s)"
}
},
{
"type": "metric",
"x": 15,
"y": 18,
"width": 9,
"height": 6,
"properties": {
"view": "timeSeries",
"stacked": false,
"metrics": [
[ { "expression": "(m1/1024)/m2", "label": "Data Write IO Size (KiB)", "id": "e1", "color": "#1f77b4" } ],
[ { "expression": "(m3/1024)/m4", "label": "Data Read IO Size (KiB)", "id": "e2", "color": "#ff7f0e" } ],
[ { "expression": "(m5/1024)/m6", "label": "Metadata IO Size (KiB)", "id": "e3", "color": "#d62728" } ],
[ "AWS/EFS", "DataWriteIOBytes", "FileSystemId", "${ElasticFileSystem}", { "stat": "Sum", "period": 60, "id": "m1", "visible": false } ],
[ "...", { "stat": "SampleCount", "period": 60, "id": "m2", "visible": false } ],
[ ".", "DataReadIOBytes", ".", ".", { "period": 60, "stat": "Sum", "id": "m3", "visible": false } ],
[ "...", { "period": 60, "stat": "SampleCount", "id": "m4", "visible": false } ],
[ ".", "MetadataIOBytes", ".", ".", { "period": 60, "stat": "Sum", "id": "m5", "visible": false } ],
[ "...", { "period": 60, "stat": "SampleCount", "id": "m6", "visible": false } ]
],
"region": "${AWS::Region}",
"title": "Avg. IO Size (KiB)",
"period": 60
}
},
{
"type": "metric",
"x": 0,
"y": 18,
"width": 15,
"height": 6,
"properties": {
"view": "timeSeries",
"stacked": false,
"metrics": [
[ { "expression": "((m1/1048576)/PERIOD(m1))", "label": "Avgerage Throughput (MiB/s)", "id": "e1", "period": 60, "color": "#2ca02c", "yAxis": "right" } ],
[ { "expression": "(m2/1048576)", "label": "Permitted Throughput (MiB/s)", "id": "e2" } ],
[ { "expression": "e2-e1", "label": "Available Throughput (MiB/s)", "id": "e3", "color": "#17becf" } ],
[ { "expression": "((e1)*100)/(e2)", "label": "Percent Throughput Utilization (%)", "id": "e3" } ],
[ "AWS/EFS", "TotalIOBytes", "FileSystemId", "${ElasticFileSystem}", { "id": "m1", "visible": false } ],
[ ".", "PermittedThroughput", ".", ".", { "id": "m2", "visible": false, "stat": "Average" } ]
],
"region": "${AWS::Region}",
"title": "Throughput Utilization",
"period": 60
}
},
{
"type": "metric",
"x": 15,
"y": 3,
"width": 9,
"height": 9,
"properties": {
"view": "timeSeries",
"stacked": false,
"metrics": [
[ { "expression": "(m1)/PERIOD(m1)", "label": "Total iops", "id": "e1", "yAxis": "left", "stat": "SampleCount", "color": "#2ca02c" } ],
[ { "expression": "(m2)/PERIOD(m2)", "label": "Data Write iops", "id": "e2", "stat": "SampleCount", "color": "#1f77b4" } ],
[ { "expression": "(m3)/PERIOD(m3)", "label": "Data Read iops", "id": "e3", "stat": "SampleCount", "color": "#ff7f0e" } ],
[ { "expression": "(m4)/PERIOD(m4)", "label": "Metadata iops", "id": "e4", "stat": "SampleCount", "color": "#d62728" } ],
[ "AWS/EFS", "TotalIOBytes", "FileSystemId", "${ElasticFileSystem}", { "id": "m1", "stat": "SampleCount", "period": 60, "visible": false } ],
[ ".", "DataWriteIOBytes", ".", ".", { "period": 60, "stat": "SampleCount", "id": "m2", "visible": false } ],
[ ".", "DataReadIOBytes", ".", ".", { "period": 60, "stat": "SampleCount", "id": "m3", "visible": false } ],
[ ".", "MetadataIOBytes", ".", ".", { "period": 60, "stat": "SampleCount", "id": "m4", "visible": false } ]
],
"region": "${AWS::Region}",
"period": 60,
"title": "Total IOPS"
}
},
{
"type": "metric",
"x": 15,
"y": 12,
"width": 9,
"height": 6,
"properties": {
"view": "timeSeries",
"metrics": [
[ { "expression": "m2*100/m1", "label": "Data Write (%)", "id": "e1", "color": "#1f77b4" } ],
[ { "expression": "m3*100/m1", "label": "Data Read (%)", "id": "e2", "color": "#ff7f0e" } ],
[ { "expression": "m4*100/m1", "label": "Metadata (%)", "id": "e3", "color": "#d62728" } ],
[ "AWS/EFS", "TotalIOBytes", "FileSystemId", "${ElasticFileSystem}", { "stat": "SampleCount", "period": 60, "id": "m1", "visible": false } ],
[ ".", "DataWriteIOBytes", ".", ".", { "stat": "SampleCount", "period": 60, "id": "m2", "visible": false } ],
[ ".", "DataReadIOBytes", ".", ".", { "stat": "SampleCount", "period": 60, "id": "m3", "visible": false } ],
[ ".", "MetadataIOBytes", ".", ".", { "stat": "SampleCount", "period": 60, "id": "m4", "visible": false } ]
],
"region": "${AWS::Region}",
"stacked": false,
"title": "Percent IOPS",
"period": 60
}
},
{
"type": "metric",
"x": 0,
"y": 12,
"width": 15,
"height": 6,
"properties": {
"view": "timeSeries",
"metrics": [
[ { "expression": "m2*100/m1", "label": "Data Write (%)", "id": "e1", "stat": "Sum", "color": "#1f77b4" } ],
[ { "expression": "m3*100/m1", "label": "Data Read (%)", "id": "e2", "stat": "Sum", "color": "#ff7f0e" } ],
[ { "expression": "m4*100/m1", "label": "Metadata (%)", "id": "e3", "stat": "Sum", "color": "#d62728" } ],
[ "AWS/EFS", "TotalIOBytes", "FileSystemId", "${ElasticFileSystem}", { "stat": "Sum", "period": 60, "id": "m1", "visible": false } ],
[ ".", "DataWriteIOBytes", ".", ".", { "stat": "Sum", "period": 60, "id": "m2", "visible": false } ],
[ ".", "DataReadIOBytes", ".", ".", { "stat": "Sum", "period": 60, "id": "m3", "visible": false } ],
[ ".", "MetadataIOBytes", ".", ".", { "stat": "Sum", "period": 60, "id": "m4", "visible": false } ]
],
"region": "${AWS::Region}",
"stacked": false,
"title": "Percent Throughput",
"period": 60
}
},
{
"type": "text",
"x": 15,
"y": 0,
"width": 9,
"height": 3,
"properties": {
"markdown": "\n# Amazon EFS file system: ${ElasticFileSystem}\n## Region: ${AWS::Region}\n"
}
},
{
"type": "metric",
"x": 0,
"y": 0,
"width": 15,
"height": 3,
"styles": "undefined",
"properties": {
"view": "singleValue",
"metrics": [
[ { "expression": "m2/1048576", "label": "Permitted Throughput (MiB/s)", "id": "e1" } ],
[ "Custom/EFS", "SizeInBytes", "FileSystemId", "${ElasticFileSystem}", { "label": "Metered Size (Bytes)", "id": "m1" } ],
[ "AWS/EFS", "PermittedThroughput", ".", ".", { "label": "Permitted Throughput", "id": "m2", "visible": false } ],
[ ".", "BurstCreditBalance", ".", ".", { "label": "BurstCreditBalance", "id": "m3" } ]
],
"region": "${AWS::Region}",
"period": 60,
"title": "File system metrics"
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment