Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
#!/bin/bash
set -eu
api_key="__MACKEREL_API_KEY__"
url="https://mackerel.io/api/v0/graph-defs/create"
curl -s -S -X POST \
-H "X-Api-Key:${api_key}" \
-H 'Content-Type: application/json' \
-d "[{ \
\"name\": \"custom.rds.cpuUtilization\", \
\"displayName\": \"CPU\", \
\"unit\": \"float\", \
\"metrics\": [
{ \"name\": \"custom.rds.cpuUtilization.guest\", \"displayName\": \"guest\", \"isStacked\": false }, \
{ \"name\": \"custom.rds.cpuUtilization.irq\", \"displayName\": \"irq\", \"isStacked\": false }, \
{ \"name\": \"custom.rds.cpuUtilization.system\", \"displayName\": \"system\", \"isStacked\": false }, \
{ \"name\": \"custom.rds.cpuUtilization.wait\", \"displayName\": \"iowait\", \"isStacked\": false }, \
{ \"name\": \"custom.rds.cpuUtilization.idle\", \"displayName\": \"idle\", \"isStacked\": false }, \
{ \"name\": \"custom.rds.cpuUtilization.user\", \"displayName\": \"user\", \"isStacked\": false }, \
{ \"name\": \"custom.rds.cpuUtilization.total\", \"displayName\": \"total\", \"isStacked\": false }, \
{ \"name\": \"custom.rds.cpuUtilization.steal\", \"displayName\": \"steal\", \"isStacked\": false }, \
{ \"name\": \"custom.rds.cpuUtilization.nice\", \"displayName\": \"nice\", \"isStacked\": false } \
] \
}]" ${url}
curl -s -S -X POST \
-H "X-Api-Key:${api_key}" \
-H 'Content-Type: application/json' \
-d "[{ \
\"name\": \"custom.rds.loadAverageMinute\", \
\"displayName\": \"Load Average\", \
\"unit\": \"float\", \
\"metrics\": [
{ \"name\": \"custom.rds.loadAverageMinute.fifteen\", \"displayName\": \"fifteen\", \"isStacked\": false }, \
{ \"name\": \"custom.rds.loadAverageMinute.five\", \"displayName\": \"five\", \"isStacked\": false }, \
{ \"name\": \"custom.rds.loadAverageMinute.one\", \"displayName\": \"one\", \"isStacked\": false } \
] \
}]" ${url}
curl -s -S -X POST \
-H "X-Api-Key:${api_key}" \
-H 'Content-Type: application/json' \
-d "[{ \
\"name\": \"custom.rds.diskIO\", \
\"displayName\": \"Disk I/O\", \
\"unit\": \"integer\", \
\"metrics\": [
{ \"name\": \"custom.rds.diskIO.avgQueueLen\", \"displayName\": \"avgQueueLen\", \"isStacked\": false }, \
{ \"name\": \"custom.rds.diskIO.await\", \"displayName\": \"await\", \"isStacked\": false }, \
{ \"name\": \"custom.rds.diskIO.rrqmPS\", \"displayName\": \"rrqmPS\", \"isStacked\": false }, \
{ \"name\": \"custom.rds.diskIO.tps\", \"displayName\": \"tps\", \"isStacked\": false }, \
{ \"name\": \"custom.rds.diskIO.wrqmPS\", \"displayName\": \"wrqmPS\", \"isStacked\": false } \
] \
}]" ${url}
curl -s -S -X POST \
-H "X-Api-Key:${api_key}" \
-H 'Content-Type: application/json' \
-d "[{ \
\"name\": \"custom.rds.diskBytes\", \
\"displayName\": \"Disk I/O Bytes\", \
\"unit\": \"bytes\", \
\"metrics\": [
{ \"name\": \"custom.rds.diskBytes.readKb\", \"displayName\": \"readKb\", \"isStacked\": false }, \
{ \"name\": \"custom.rds.diskBytes.readKbPS\", \"displayName\": \"readKbPS\", \"isStacked\": false }, \
{ \"name\": \"custom.rds.diskBytes.writeKb\", \"displayName\": \"writeKb\", \"isStacked\": false }, \
{ \"name\": \"custom.rds.diskBytes.writeKbPS\", \"displayName\": \"writeKbPS\", \"isStacked\": false } \
] \
}]" ${url}
curl -s -S -X POST \
-H "X-Api-Key:${api_key}" \
-H 'Content-Type: application/json' \
-d "[{ \
\"name\": \"custom.rds.iops\", \
\"displayName\": \"IOPS\", \
\"unit\": \"iops\", \
\"metrics\": [
{ \"name\": \"custom.rds.iops.readIOsPS\", \"displayName\": \"readIOsPS\", \"isStacked\": false }, \
{ \"name\": \"custom.rds.iops.writeIOsPS\", \"displayName\": \"writeIOsPS\", \"isStacked\": false } \
] \
}]" ${url}
curl -s -S -X POST \
-H "X-Api-Key:${api_key}" \
-H 'Content-Type: application/json' \
-d "[{ \
\"name\": \"custom.rds.iopsThoughtput\", \
\"displayName\": \"IOPS Thoughtput\", \
\"unit\": \"float\", \
\"metrics\": [
{ \"name\": \"custom.rds.iopsThoughtput.readThoughtput\", \"displayName\": \"readThoughtput\", \"isStacked\": false }, \
{ \"name\": \"custom.rds.iopsThoughtput.writeThoughtput\", \"displayName\": \"writeThoughtput\", \"isStacked\": false } \
] \
}]" ${url}
curl -s -S -X POST \
-H "X-Api-Key:${api_key}" \
-H 'Content-Type: application/json' \
-d "[{ \
\"name\": \"custom.rds.iopsLatency\", \
\"displayName\": \"IOPS Latency\", \
\"unit\": \"float\", \
\"metrics\": [
{ \"name\": \"custom.rds.iopsLatency.readLatency\", \"displayName\": \"readLatency\", \"isStacked\": false }, \
{ \"name\": \"custom.rds.iopsLatency.writeLatency\", \"displayName\": \"writeLatency\", \"isStacked\": false } \
] \
}]" ${url}
curl -s -S -X POST \
-H "X-Api-Key:${api_key}" \
-H 'Content-Type: application/json' \
-d "[{ \
\"name\": \"custom.rds.files\", \
\"displayName\": \"Inode\", \
\"unit\": \"integer\", \
\"metrics\": [
{ \"name\": \"custom.rds.files.maxFiles\", \"displayName\": \"max\", \"isStacked\": false }, \
{ \"name\": \"custom.rds.files.usedFiles\", \"displayName\": \"used\", \"isStacked\": false } \
] \
}]" ${url}
curl -s -S -X POST \
-H "X-Api-Key:${api_key}" \
-H 'Content-Type: application/json' \
-d "[{ \
\"name\": \"custom.rds.fileSys\", \
\"displayName\": \"File System\", \
\"unit\": \"bytes\", \
\"metrics\": [
{ \"name\": \"custom.rds.fileSys.total\", \"displayName\": \"total\", \"isStacked\": false }, \
{ \"name\": \"custom.rds.fileSys.used\", \"displayName\": \"used\", \"isStacked\": false } \
] \
}]" ${url}
curl -s -S -X POST \
-H "X-Api-Key:${api_key}" \
-H 'Content-Type: application/json' \
-d "[{ \
\"name\": \"custom.rds.diskUtilization\", \
\"displayName\": \"Disk Utilization\", \
\"unit\": \"percentage\", \
\"metrics\": [
{ \"name\": \"custom.rds.diskUtilization.usedFilePercent\", \"displayName\": \"usedFilePercent\", \"isStacked\": false }, \
{ \"name\": \"custom.rds.diskUtilization.usedPercent\", \"displayName\": \"usedPercent\", \"isStacked\": false } \
] \
}]" ${url}
curl -s -S -X POST \
-H "X-Api-Key:${api_key}" \
-H 'Content-Type: application/json' \
-d "[{ \
\"name\": \"custom.rds.memory\", \
\"displayName\": \"Memory\", \
\"unit\": \"bytes\", \
\"metrics\": [
{ \"name\": \"custom.rds.memory.active\", \"displayName\": \"active\", \"isStacked\": false }, \
{ \"name\": \"custom.rds.memory.buffers\", \"displayName\": \"buffers\", \"isStacked\": false }, \
{ \"name\": \"custom.rds.memory.cached\", \"displayName\": \"cached\", \"isStacked\": false }, \
{ \"name\": \"custom.rds.memory.dirty\", \"displayName\": \"dirty\", \"isStacked\": false }, \
{ \"name\": \"custom.rds.memory.unassignedFree\", \"displayName\": \"unassignedFree\", \"isStacked\": false }, \
{ \"name\": \"custom.rds.memory.inactive\", \"displayName\": \"inactive\", \"isStacked\": false }, \
{ \"name\": \"custom.rds.memory.mapped\", \"displayName\": \"mapped\", \"isStacked\": false }, \
{ \"name\": \"custom.rds.memory.pageTables\", \"displayName\": \"pageTables\", \"isStacked\": false }, \
{ \"name\": \"custom.rds.memory.slab\", \"displayName\": \"slab\", \"isStacked\": false }, \
{ \"name\": \"custom.rds.memory.total\", \"displayName\": \"total\", \"isStacked\": false }, \
{ \"name\": \"custom.rds.memory.writeback\", \"displayName\": \"writeback\", \"isStacked\": false } \
] \
}]" ${url}
curl -s -S -X POST \
-H "X-Api-Key:${api_key}" \
-H 'Content-Type: application/json' \
-d "[{ \
\"name\": \"custom.rds.hugePages\", \
\"displayName\": \"HugePages\", \
\"unit\": \"integer\", \
\"metrics\": [
{ \"name\": \"custom.rds.hugePages.hugePagesFree\", \"displayName\": \"hugePagesFree\", \"isStacked\": false }, \
{ \"name\": \"custom.rds.hugePages.hugePagesRsvd\", \"displayName\": \"hugePagesRsvd\", \"isStacked\": false }, \
{ \"name\": \"custom.rds.hugePages.hugePagesSurp\", \"displayName\": \"hugePagesSurp\", \"isStacked\": false }, \
{ \"name\": \"custom.rds.hugePages.hugePagesTotal\", \"displayName\": \"hugePagesTotal\", \"isStacked\": false } \
] \
}]" ${url}
curl -s -S -X POST \
-H "X-Api-Key:${api_key}" \
-H 'Content-Type: application/json' \
-d "[{ \
\"name\": \"custom.rds.network\", \
\"displayName\": \"Network\", \
\"unit\": \"float\", \
\"metrics\": [
{ \"name\": \"custom.rds.network.rx\", \"displayName\": \"rx\", \"isStacked\": false }, \
{ \"name\": \"custom.rds.network.tx\", \"displayName\": \"tx\", \"isStacked\": false } \
] \
}]" ${url}
curl -s -S -X POST \
-H "X-Api-Key:${api_key}" \
-H 'Content-Type: application/json' \
-d "[{ \
\"name\": \"custom.rds.swap\", \
\"displayName\": \"Swap\", \
\"unit\": \"bytes\", \
\"metrics\": [
{ \"name\": \"custom.rds.swap.cached\", \"displayName\": \"cached\", \"isStacked\": false }, \
{ \"name\": \"custom.rds.swap.free\", \"displayName\": \"free\", \"isStacked\": false }, \
{ \"name\": \"custom.rds.swap.total\", \"displayName\": \"total\", \"isStacked\": false } \
] \
}]" ${url}
curl -s -S -X POST \
-H "X-Api-Key:${api_key}" \
-H 'Content-Type: application/json' \
-d "[{ \
\"name\": \"custom.rds.tasks\", \
\"displayName\": \"Task\", \
\"unit\": \"integer\", \
\"metrics\": [
{ \"name\": \"custom.rds.tasks.blocked\", \"displayName\": \"blocked\", \"isStacked\": false }, \
{ \"name\": \"custom.rds.tasks.running\", \"displayName\": \"running\", \"isStacked\": false }, \
{ \"name\": \"custom.rds.tasks.sleeping\", \"displayName\": \"sleeping\", \"isStacked\": false }, \
{ \"name\": \"custom.rds.tasks.stopped\", \"displayName\": \"stopped\", \"isStacked\": false }, \
{ \"name\": \"custom.rds.tasks.total\", \"displayName\": \"total\", \"isStacked\": false }, \
{ \"name\": \"custom.rds.tasks.zombie\", \"displayName\": \"zombie\", \"isStacked\": false } \
] \
}]" ${url}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment