Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
自前運用の Zabbix から Mackerel へ - ソーシャルゲームタイトルのサーバ監視...
Search
jetzou
January 26, 2019
1.9k
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
自前運用の Zabbix から Mackerel へ - ソーシャルゲームタイトルのサーバ監視の移行事例
jetzou
January 26, 2019
Featured
See All Featured
Java REST API Framework Comparison - PWX 2021
mraible
34
9.7k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
1k
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
6
1.2k
Product Roadmaps are Hard
iamctodd
55
13k
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.5k
BBQ
matthewcrist
89
10k
30 Presentation Tips
portentint
PRO
1
410
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
2k
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
2
930
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
120
120k
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
300
Mobile First: as difficult as doing things right
swwweet
225
10k
Transcript
監視 移⾏事例 ⾃前運⽤ Zabbix Mackerel YAPC::Tokyo 2019 jetzou
⾃⼰紹介 • 株式会社 SRE 所属 • 新卒3年⽬ • 僕 甲⼦園
運⽤ 担当 • 3⼈兄弟 ⻑男
発表 • 監視・ 移植 • 通知 対処法 • ⾃作 ・
利⽤ 監視 • mackerel 便利 機能 • / 付 合 ⼯夫 • ryotarai/waker 連携 • mackerel service discovery 利⽤ 緊急 ⽅法
甲⼦園! • 以下 • 4周年 迎 • Perl5 書 •
AWS • Packer, Chef , 構成管理 • Consul, stretcher 仕組 • ⾃前運⽤ Zabbix 監視
Zabbix • Zabbix 運⽤ 必要 • 追従 • 現⾏: 2.0.x
• 最新 : 4.0 • 各 ⾜並 必要 難
• 提供 SaaS型 監視 • mackerel-agent: 動作 監視 • AWS
: 向 • zabbix-server 監視 運⽤ 不要 mackerel
監視移植 • Zabbix (監視項⽬) 列挙 • mackerel 監視 / 監視
• mackerel-agent.conf 等 chef recipe 追加 • Zabbix mackerel 並⾏運⽤ • 同 ⾶ 確認 OK • Zabbix 監視 抜
Zabbix ・ 列挙 • 各EC2 役割 (role) • web, batch,
log-aggregator… • 50 ~ 80 • 各 ・ Template 組 合 • EC2 ⽤ 基本的 Template + 各role⽤ Template • 継承 Template 各 設定 値 違 • 各 role 適⽤ 洗 出
Zabbix mackerel 監視 • 監視 監視 • 選定 • ⾜
機能 PR 送 作 • 深刻度 対応付
監視 監視 • 監視 • agent mackerel 送 、 値
設 • 監視設定 mackerel 上 定義 • 監視 • agent 実⾏ 結果 監視項⽬ • 監視設定 agent 設定 定義 • 何 異常 如何 、 値 形 • 監視 設定 起 • 移⾏中 設定 誤発⽕・不発 監視 多
監視 監視 • 監視 • agent mackerel 送 、 値
設 • 監視設定 mackerel 上 定義 • 監視 • agent 実⾏ 結果 監視項⽬ • 監視設定 agent 設定 定義 • 何 異常 如何 、 値 形 • 監視 設定 起 • 移⾏中 設定 誤発⽕・不発 監視 多 監視 寄
監視
監視 WARN, CRIT 値 無効化
監視 WARN, CRIT 値 無効化 n点 平均値 評価
監視 WARN, CRIT 値 無効化 n点 平均値 評価 n回連続
監視 WARN, CRIT 値 無効化 n点 平均値 評価 n回連続 /
単位 監視対象絞 込 /除外
監視例 # CRITICAL consulͷHTTPΤϯυϙΠϯτࢹ [plugin.checks.consul_http_listen] command = "check-tcp --port 8500”
# CRITICAL consulͷDNS Interfaceࢹ [plugin.checks.consul_dns_listen] command = "check-tcp --port 8600” mackerel-agent.conf
監視例 # CRITICAL consulͷHTTPΤϯυϙΠϯτࢹ [plugin.checks.consul_http_listen] command = "check-tcp --port 8500”
# CRITICAL consulͷDNS Interfaceࢹ [plugin.checks.consul_dns_listen] command = "check-tcp --port 8600” mackerel-agent.conf 深刻度 *1 *1現在 memo 要素 使 良
選定 • 公式 充実 、 探 • : mackerelio/mackerel-agent-plugins •
監視 : mackerelio/go-check-plugins • 各 README • ⼿元 動 ・ 読 • README.md 有⽤
無 、機能 ⾜ • 公式 機能 ⾜ 場合 PR 出
• • mysql: Aurora *1 • redis: CONFIG cmd 対応*2, Uptime 収集*3 • 監視 • check-tcp: 疎通失敗時 WARN 選 *4 *1 https://github.com/mackerelio/mackerel-agent-plugins/pull/462 *2 https://github.com/mackerelio/mackerel-agent-plugins/pull/463 *3 https://github.com/mackerelio/mackerel-agent-plugins/pull/502 *4 https://github.com/mackerelio/go-check-plugins/pull/212
• 作 • • https://github.com/kayac/mackerel-plugin-katsubushi • https://github.com/kayac/mackerel-plugin-gunfish • https://github.com/kayac/mackerel-plugin-kuiperbelt •
監視 • https://github.com/kayac/check-consul • https://github.com/kayac/check-crontab • https://github.com/kayac/check-reboot 無 、機能 ⾜
深刻度 対応付 • 使⽤ Zabbix 深刻度 4段階 • INFO(情報)/WARN(警告)/Average(軽度 障害)/High(重度
障害) • mackerel 深刻度 2段階 • WARN/CRITICAL • 深刻度 通知先 変
深刻度 Zabbix mackerel 通知 情報 (INFO) slack 警告 (WARN) WARNING
slack 軽度 障害 (AVG) CRITICAL slack @channel, waker, mail 重度 障害 (HIGH) CRITICAL slack @channel, waker, mail
深刻度 Zabbix mackerel 通知 情報 (INFO) slack 警告 (WARN) WARNING
slack 軽度 障害 (AVG) CRITICAL slack @channel, waker, mail 重度 障害 (HIGH) CRITICAL slack @channel, waker, mail 同 通知先 CRITICAL
深刻度 Zabbix mackerel 通知 情報 (INFO) slack 警告 (WARN) WARNING
slack 軽度 障害 (AVG) CRITICAL slack @channel, waker, mail 重度 障害 (HIGH) CRITICAL slack @channel, waker, mail INFO ?
通知 対処法 • INFO • 障害・ 通知 事項 • 具体例
• norikra 変更検知 • consul 交代 • 低度 Load Average 増加
Songmu/horenso • Usage: horenso ̶reporter /path/reporter.pl ̶ /path/job.sh • 実⾏結果
slack 通知 • cron 実⾏結果 報告 使 • ref: 0 * * * * /path/job.sh >/dev/null 2>&1*1 • INFO 相当 ? *1 cron >/dev/null 椅⼦ 投 3 ⽅法 https://sfujiwara.hatenablog.com/entry/20120613/1339547638
Songmu/horenso • reporter 受 取 JSON • exitCode ⾒ 平常時
• perl+shell reporter *1 { "command": "perl -E 'say 1;warn \"$$\\n\";'", "commandArgs": [ "perl", "-E", "say 1;warn \"$$\\n\";" ], "output": "1\n95030\n", "stdout": "1\n", "stderr": "95030\n", "exitCode": 0, "result": "command exited with code: 0", "pid": 95030, "startAt": "2015-12-28T00:37:10.494282399+09:00", "endAt": "2015-12-28T00:37:10.546466379+09:00", "hostname": "webserver.example.com", "systemTime": 0.034632, "userTime": 0.026523 } *1 horenso slack reporter 書 https://beatsync.net/main/log20160330.html
Songmu/horenso • horenso 終了 対象 終了 • agent 異常系 終了
伝 ⾶ • horenso 常 終了 0 返 追加 • Author 意図 期待 挙動 相談 上 PR 送 *1 *1 add override command status option #16 https://github.com/Songmu/horenso/pull/16
mackerel-info # INFO [plugin.checks.consul_leader_changed] command = "/usr/local/bin/mackerel-info check-consul leader-changed" #!/bin/bash
export PATH="$PATH:/usr/local/bin" export SLACK_ENDPOINT="<%= @webhook_uri %>" export SLACK_USERNAME="Mackerel horenso" export SLACK_CHANNEL="<%= node[:horenso][:slack_channel] %>" export SLACK_ICON_EMOJI=":mackerel:" export SLACK_MUTE_ON_NORMAL=1 exec horenso -o -r slack_reporter.pl -- "$@" mackerel-agent.conf /usr/local/bin/mackerel-info
None
深刻度 Zabbix mackerel 通知 情報 (INFO) INFO (horenso) slack 警告
(WARN) WARNING slack 軽度 障害 (AVG) CRITICAL slack @channel, waker, mail 重度 障害 (HIGH) CRITICAL slack @channel, waker, mail
mackerel-agent 設定 追加 • 構成管理 Chef • recipe mackerel-agent, ,
設定 管理 • /etc/mackerel-agent/mackerel-agent.conf • EC2 共通 、 記述 • /etc/mackerel-agent/conf.d/*.conf • role 分 、 記述 • Chef recipe 分
mackerel-agent 設定 追加 • role 対応 roles/*.json 読 込 •
run_list role 固有 監視設定 配置 recipe ⾜ • 例: • role 監視 ⼊ "run_list": [ "role[stretcher]", "recipe[gearmand]", + "recipe[mackerel-agent::gearmand]", "recipe[haproxy]", + "recipe[mackerel-agent::haproxy]", roles/batch.json
Zabbix mackerel 並⾏利⽤ • mackerel 監視 導⼊後 Zabbix 継続 利⽤
• 移⾏中 mackerel 監視設定 • 不発、 暴発 • 移⾏作業中 何度 • 実績 Zabbix 監視設定 信⽤ • 移⾏期間中 監視 質 下 • 監視項⽬ 発動 障害 気付 不安 無
mackerel 便利機能: • Google 記録 残 • 通称: • mackerel
上 情報 出 便利 • • 指定 時間帯 注釈
None
• 投稿 • 1⾏追加 対応完了 # mackerel ʹάϥϑΞϊςʔγϣϯΛՃ͢Δ mkr annotations
create —-service prod \ -—title "$event_name" \ --from $(date +%s --date "$start_time") \ --to $(date +%s --date "$end_time")
/ 付 合
• 捌 web • 起動時 AMI作成時 構成 最新 状態 ⾛
• 、 Chef 実⾏ • agent ⾃動 ⽴ 上 中 監視 始 • InService 各役割 満 状態 • 監視対象 準備 済 ⾶
• 退役時 各種 ・ 終了 • mackerel-agent 終了順序 遅 …
• 監視対象 先 落 ⾶ • 各種 agent 起動・終了順序 考慮 動作
起動時 制御 • rc.local 実⾏ • Chef, , consul maint
解除 • mackerel-agent ⾃動起動 無効 rc.local 最後 起動 • Chef mackerel-agent 起動
退役時 制御 • /etc/init.d/autoscale • 退役処理 init • fluentd ,
consul /ELB leave … • mackerel-agent 終了順序 考慮 • mackerel-agent K05 、 autoscale 当初 K00 • autoscale 優先度 mackerel-agent 落 ( K00 -> K10 )
固定 • =固定 • 基本的 頻繁 起動・ 考慮 • mackerel-agent
⾃動起動 ON
Packer • 各 role Packer AMI 作成 • Chef 実⾏
• mackerel-agent 起動 • AMI 作 mackerel 登録 • role ⾃動起動 無効
service “mackerel-agent” resource supports = node[:roles].include?("packer") ? {:start => false,
:reload => false} : {:reload => true} if node[:roles].include?("autoscale") && node[:roles].include?("packer") then actions = [:disable, :stop] elsif node[:roles].include?("autoscale") then actions = [:enable] elsif node[:roles].include?("packer") then actions = [:enable, :stop] else actions = [:enable, :start] end service "mackerel-agent" do action actions supports supports end
service “mackerel-agent” resource supports = node[:roles].include?("packer") ? {:start => false,
:reload => false} : {:reload => true} if node[:roles].include?("autoscale") && node[:roles].include?("packer") then actions = [:disable, :stop] elsif node[:roles].include?("autoscale") then actions = [:enable] elsif node[:roles].include?("packer") then actions = [:enable, :stop] else actions = [:enable, :start] end service "mackerel-agent" do action actions supports supports end
service “mackerel-agent” resource supports = node[:roles].include?("packer") ? {:start => false,
:reload => false} : {:reload => true} if node[:roles].include?("autoscale") && node[:roles].include?("packer") then actions = [:disable, :stop] elsif node[:roles].include?("autoscale") then actions = [:enable] elsif node[:roles].include?("packer") then actions = [:enable, :stop] else actions = [:enable, :start] end service "mackerel-agent" do action actions supports supports end
service “mackerel-agent” resource supports = node[:roles].include?("packer") ? {:start => false,
:reload => false} : {:reload => true} if node[:roles].include?("autoscale") && node[:roles].include?("packer") then actions = [:disable, :stop] elsif node[:roles].include?("autoscale") then actions = [:enable] elsif node[:roles].include?("packer") then actions = [:enable, :stop] else actions = [:enable, :start] end service "mackerel-agent" do action actions supports supports end
service “mackerel-agent” resource supports = node[:roles].include?("packer") ? {:start => false,
:reload => false} : {:reload => true} if node[:roles].include?("autoscale") && node[:roles].include?("packer") then actions = [:disable, :stop] elsif node[:roles].include?("autoscale") then actions = [:enable] elsif node[:roles].include?("packer") then actions = [:enable, :stop] else actions = [:enable, :start] end service "mackerel-agent" do action actions supports supports end
service “mackerel-agent” resource supports = node[:roles].include?("packer") ? {:start => false,
:reload => false} : {:reload => true} if node[:roles].include?("autoscale") && node[:roles].include?("packer") then actions = [:disable, :stop] elsif node[:roles].include?("autoscale") then actions = [:enable] elsif node[:roles].include?("packer") then actions = [:enable, :stop] else actions = [:enable, :start] end service "mackerel-agent" do action actions supports supports end
ryotarai/waker 連携 https://github.com/ryotarai/waker
waker • https://github.com/ryotarai/waker • • Zabbix mackerel 受 取 、担当者
電話 • 担当者 応答 次 担当者 発呼 • Google ⼊ 替
waker mackerel 連携 • Zabbix waker 送 • mackerel waker
登録 • webhook 通知 使 • mackerel ⽤ 作成 PR 送 *1 *1 https://github.com/ryotarai/waker/pull/42
mackerel 利⽤ 緊急 ⼊ ⽅ • 通常時 consul template nginx
設定 書 換 ⼊ • consul 崩壊 • ⼊ 、 出来 • 各 ssh ⼊ nginx 設定 書 換 • 普段 memberlist 使 ssh 接続先 補完 、 各 回 ⼀苦労
• mkr hosts web IP 取得 • nssh /var/tmp/503 設置
• nginx 503 返 • consul 復旧 mackerel 利⽤ 緊急 ⼊ ⽅ $ mkr hosts --service prod --role web | jq -r ".[].ipAddresses.eth0" >web-ip-list $ nssh -f web-ip-list "touch /var/tmp/503"
• 監視 Zabbix mackerel 移⾏ • ⾜ 機能 ⾃分 作
PR 送 : 育 監視 • Zabbix 並⾏ 運⽤ 、監視設定 確認 • 付 合 • agent 起動・終了順序 地味 丁寧 • mackerel 情報 使 緊急 ⼊ 仕組 ⼊