読者です 読者をやめる 読者になる 読者になる

vague memory

うろ覚えを無くしていこうともがき苦しむ人の備忘録

Mackerel事始め agent-plugin EC2関連

mackerel AWS

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=<id>] [-region=<aws-region>] [-access-key-id=<id>] [-secret-access-key=<key>] [-tempfile=<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"

f:id:htnosm:20160409180638p:plain

ダッシュボードへ反映

  • 置換文字列
__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&amp;stacked=false&amp;simplified=false&amp;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&amp;stacked=false&amp;simplified=false&amp;period=__PERIOD__)](https://mackerel.io/orgs/__ORG__/services/__SERVICE__/__ROLE__/-/graph?name=custom.ec2.cpucredit.balance)

f:id:htnosm:20160409180639p:plain

EBS

  • mackerel-plugin-aws-ec2-ebs

aws-ec2-ebs.conf

# mackerel-plugin-aws-ec2-ebs [-instance-id=<id>] [-region=<aws-region>] [-access-key-id=<id>] [-secret-access-key=<key>] [-tempfile=<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"

f:id:htnosm:20160409180640p:plain

ダッシュボードへ反映

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"

f:id:htnosm:20160409180641p:plain

ダッシュボードへ反映

# process
|:---|:---|
| **# context_switches** | **# Login users** |
| [![graph](https://mackerel.io/embed/orgs/__ORG__/services/__SERVICE__/__ROLE__.png?graph=custom.linux.context_switches.context_switches&amp;stacked=false&amp;simplified=false&amp;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&amp;stacked=false&amp;simplified=false&amp;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&amp;stacked=false&amp;simplified=false&amp;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&amp;stacked=false&amp;simplified=false&amp;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&amp;stacked=false&amp;simplified=false&amp;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&amp;stacked=false&amp;simplified=false&amp;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&amp;stacked=false&amp;simplified=false&amp;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&amp;stacked=false&amp;simplified=false&amp;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&amp;stacked=false&amp;simplified=false&amp;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&amp;stacked=false&amp;simplified=false&amp;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&amp;stacked=false&amp;simplified=false&amp;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&amp;stacked=false&amp;simplified=false&amp;period=__PERIOD__)](https://mackerel.io/orgs/__ORG__/services/__SERVICE__/__ROLE__/-/graph?name=custom.linux.swap.pswpout) |

f:id:htnosm:20160405195837p:plain