agent-pluginを使ってEC2関連の監視設定を追加していきます。
IAM Policy設定
CloudWatch経由の取得のため GetMetricStatistics を IAMrole または IAMuser へ付与します。
- cloudwatch:GetMetricStatistics
- IAM role で設定されていれば access-key-id、secret-access-key の指定は不要
CPU credit
- mackerel-plugin-aws-ec2-cpucredit
aws-ec2-cpucredit.conf
# mackerel-plugin-aws-ec2-cpucredit [-instance-id=] [-region= ] [-access-key-id= ] [-secret-access-key= ] [-tempfile= ] [plugin.metrics.aws-ec2_cpucredit] command = "/usr/local/bin/mackerel-plugin-aws-ec2-cpucredit -access-key-id AWS_ACCESS_KEY_ID -secret-access-key AWS_SECRET_ACCESS_KEY"
ダッシュボードへ反映
- 置換文字列
__ORG__ = Organization __SERVICE__ = Service __ROLE___ = Role __PERIOD__ = Period {m(分), h(時間), d(日), w(週), mo(月), y(年)}
[![graph](https://mackerel.io/embed/orgs/__ORG__/services/__SERVICE__/__ROLE__.png?graph=custom.ec2.cpucredit.usage&stacked=false&simplified=false&period=__PERIOD__)](https://mackerel.io/orgs/__ORG__/services/__SERVICE__/__ROLE__/-/graph?name=custom.ec2.cpucredit.usage) [![graph](https://mackerel.io/embed/orgs/__ORG__/services/__SERVICE__/__ROLE__.png?graph=custom.ec2.cpucredit.balance&stacked=false&simplified=false&period=__PERIOD__)](https://mackerel.io/orgs/__ORG__/services/__SERVICE__/__ROLE__/-/graph?name=custom.ec2.cpucredit.balance)
EBS
- mackerel-plugin-aws-ec2-ebs
aws-ec2-ebs.conf
# mackerel-plugin-aws-ec2-ebs [-instance-id=] [-region= ] [-access-key-id= ] [-secret-access-key= ] [-tempfile= ] [plugin.metrics.aws-ec2_ebs] command = "/usr/local/bin/mackerel-plugin-aws-ec2-ebs -access-key-id AWS_ACCESS_KEY_ID -secret-access-key AWS_SECRET_ACCESS_KEY"
ダッシュボードへ反映
volume-id がメトリクス名として設定されてしまうため、同一グラフ上でまとめて表示させるには一手間掛かりそうです。
ホスト単位であれば複数ボリュームを纏めて表示できるようなので別途考えたいと思います。
mackerel-plugin-linux
- type オプションのデフォルトはall
GLOBAL OPTIONS: --tempfile, -t "/tmp/mackerel-plugin-linux" Set temporary file path. [$ENVVAR_TEMPFILE] --type, -p "all" Select metrics: all, swap, netstat, diskstats, proc_stat, users [$ENVVAR_TYPE] --help, -h show help --version, -v print the version
linux.conf
[plugin.metrics.linux] command = "/usr/local/bin/mackerel-plugin-linux" type = "metric"
ダッシュボードへ反映
# process |:---|:---| | **# context_switches** | **# Login users** | | [![graph](https://mackerel.io/embed/orgs/__ORG__/services/__SERVICE__/__ROLE__.png?graph=custom.linux.context_switches.context_switches&stacked=false&simplified=false&period=__PERIOD__)](https://mackerel.io/orgs/__ORG__/services/__SERVICE__/__ROLE__/-/graph?name=custom.linux.context_switches.context_switches) | [![graph](https://mackerel.io/embed/orgs/__ORG__/services/__SERVICE__/__ROLE__.png?graph=custom.linux.users.users&stacked=false&simplified=false&period=__PERIOD__)](https://mackerel.io/orgs/__ORG__/services/__SERVICE__/__ROLE__/-/graph?name=custom.linux.users.users) | | **# forks** | **# interrupts(proc_stat)** | | [![graph](https://mackerel.io/embed/orgs/__ORG__/services/__SERVICE__/__ROLE__.png?graph=custom.linux.forks.forks&stacked=false&simplified=false&period=__PERIOD__)](https://mackerel.io/orgs/__ORG__/services/__SERVICE__/__ROLE__/-/graph?name=custom.linux.forks.forks) | [![graph](https://mackerel.io/embed/orgs/__ORG__/services/__SERVICE__/__ROLE__.png?graph=custom.linux.interrupts.interrupts&stacked=false&simplified=false&period=__PERIOD__)](https://mackerel.io/orgs/__ORG__/services/__SERVICE__/__ROLE__/-/graph?name=custom.linux.interrupts.interrupts) | # netstat |:---|:---| | **# ESTABLISHED** | **# FIN-WAIT-1** | | [![graph](https://mackerel.io/embed/orgs/__ORG__/services/__SERVICE__/__ROLE__.png?graph=custom.linux.ss.ESTAB&stacked=false&simplified=false&period=__PERIOD__)](https://mackerel.io/orgs/__ORG__/services/__SERVICE__/__ROLE__/-/graph?name=custom.linux.ss.ESTAB) | [![graph](https://mackerel.io/embed/orgs/__ORG__/services/__SERVICE__/__ROLE__.png?graph=custom.linux.ss.FIN-WAIT-1&stacked=false&simplified=false&period=__PERIOD__)](https://mackerel.io/orgs/__ORG__/services/__SERVICE__/__ROLE__/-/graph?name=custom.linux.ss.FIN-WAIT-1) | | **# LISTEN** | **# TIME-WAIT** | | [![graph](https://mackerel.io/embed/orgs/__ORG__/services/__SERVICE__/__ROLE__.png?graph=custom.linux.ss.LISTEN&stacked=false&simplified=false&period=__PERIOD__)](https://mackerel.io/orgs/__ORG__/services/__SERVICE__/__ROLE__/-/graph?name=custom.linux.ss.LISTEN) | [![graph](https://mackerel.io/embed/orgs/__ORG__/services/__SERVICE__/__ROLE__.png?graph=custom.linux.ss.TIME-WAIT&stacked=false&simplified=false&period=__PERIOD__)](https://mackerel.io/orgs/__ORG__/services/__SERVICE__/__ROLE__/-/graph?name=custom.linux.ss.TIME-WAIT) | | **# SYN-RECV** | **# SYN-SENT** | | [![graph](https://mackerel.io/embed/orgs/__ORG__/services/__SERVICE__/__ROLE__.png?graph=custom.linux.ss.SYN-RECV&stacked=false&simplified=false&period=__PERIOD__)](https://mackerel.io/orgs/__ORG__/services/__SERVICE__/__ROLE__/-/graph?name=custom.linux.ss.SYN-RECV) | [![graph](https://mackerel.io/embed/orgs/__ORG__/services/__SERVICE__/__ROLE__.png?graph=custom.linux.ss.SYN-SENT&stacked=false&simplified=false&period=__PERIOD__)](https://mackerel.io/orgs/__ORG__/services/__SERVICE__/__ROLE__/-/graph?name=custom.linux.ss.SYN-SENT) | # swap |:---|:---| | **# sw__ROLE__n** | **# swapout** | | [![graph](https://mackerel.io/embed/orgs/__ORG__/services/__SERVICE__/__ROLE__.png?graph=custom.linux.swap.pswpin&stacked=false&simplified=false&period=__PERIOD__)](https://mackerel.io/orgs/__ORG__/services/__SERVICE__/__ROLE__/-/graph?name=custom.linux.swap.pswpin) | [![graph](https://mackerel.io/embed/orgs/__ORG__/services/__SERVICE__/__ROLE__.png?graph=custom.linux.swap.pswpout&stacked=false&simplified=false&period=__PERIOD__)](https://mackerel.io/orgs/__ORG__/services/__SERVICE__/__ROLE__/-/graph?name=custom.linux.swap.pswpout) |