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
CloudWatch から Mackerel にメトリックを送る方法 2019年版 / Mac...
Search
FUJIWARA Shunichiro
March 01, 2019
Technology
3.4k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
CloudWatch から Mackerel にメトリックを送る方法 2019年版 / Mackerel Meetup 13
FUJIWARA Shunichiro
March 01, 2019
More Decks by FUJIWARA Shunichiro
See All by FUJIWARA Shunichiro
多摩川(.dev)ランニング入門 / Tamagawa.dev#3
fujiwara3
3
530
クラウドを使う側から、作る側へ / 大吉祥寺.pm 2026前夜祭
fujiwara3
8
2.2k
作るべきものと向き合う - ecspresso 8年間の開発史から学ぶ技術選定 / 技術選定con findy 2026
fujiwara3
9
6.1k
さくらのクラウドでのシークレット管理を考える/tamachi.sre#2
fujiwara3
2
400
Amazon ECS デプロイツール ecspresso の開発を支える「正しい抽象化」の探求 / YAPC::Fukuoka 2025
fujiwara3
13
14k
パフォーマンスチューニングのために普段からできること/Performance Tuning: Daily Practices
fujiwara3
9
6.9k
alecthomas/kong はいいぞ
fujiwara3
7
2.6k
ecspressoの設計思想に至る道 / sekkeinight2025
fujiwara3
12
3.8k
さくらのIaaS基盤のモニタリングとOpenTelemetry/OSC Hokkaido 2025
fujiwara3
4
5.6k
Other Decks in Technology
See All in Technology
すぐできる衛星通信対応 あとは山奥に行くだけ
tatetate55
0
130
顧客に向き合う開発組織へ。リアーキテクチャとフィーチャーチーム化で挑む組織改革
safie
0
2k
Cloudflare Workers 向けアプリを C# で構築する ~WASM Native AOT への道~
nenonaninu
1
210
人間はどの意思決定を手放せるのか
kawasima
15
7.2k
30座EKS, 180次升級淬煉的EKS Upgrade Skill 的歷程
eric8230
0
170
Vibe Coding で作ったプロダクトをどう安全に動かすか / How to Safely Run Products Built with Vibe Coding
glidenote
0
110
安心して変更できるWebフロントエンドの作り方
pirosikick
5
2.7k
例外の正しい扱い方 そのエラー try-catchして大丈夫?
jinwatanabe
3
510
Slack上でインフラをトラブルシュートする! Agentic Platform Engineeringの第一歩
teru0x1
5
1.8k
Claude Codeを「使うほど育つ」AI秘書にするノウハウ
minorun365
PRO
31
27k
DEFCON34-Write-up_HYCu-MYCu
daikiokazaki
0
160
幾何アルゴリズムで なめらかなピン操作を / iOSDC Japan 2026 / smoothpin
kazumanagano
0
360
Featured
See All Featured
Building the Perfect Custom Keyboard
takai
2
880
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
490
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
2
2.1k
Abbi's Birthday
coloredviolet
4
10k
Chasing Engaging Ingredients in Design
codingconduct
0
310
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
260
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.5k
WCS-LA-2024
lcolladotor
0
830
GitHub's CSS Performance
jonrohan
1033
470k
New Earth Scene 8
popppiees
4
2.6k
The Limits of Empathy - UXLibs8
cassininazir
1
680
Documentation Writing (for coders)
carmenintech
77
5.5k
Transcript
CloudWatch ͔Β Mackerel ʹϝτϦοΫ ΛૹΔํ๏ 2019൛ 2019-03-01 Mackerel Meetup #13
@fujiwara
ΞϯόαμʔʹͳΓ·ͨ͠
CloudWatch → Mackerel ϝτϦοΫΛసૹ͍ͨ͠ AWS ΠϯςάϨʔγϣϯͰαϙʔτ͞Ε͍ͯͳ͍ͷ άϥϑɾΞϥʔτ Mackerel ଆͰݟ͍ͨ
fluentd + plugin AWSͷCloudWatchͷϝτϦοΫ͔ΒELBؔ࿈ͷϝτϦοΫΛ αʔϏεϝτϦοΫʹߘ͢Δ mackerel.io/ja/docs/entry/advanced/fluentd#example-elb fluent-plugin-cloudwatch (input plugin) Ͱऔಘ
fluent-plugin-mackerel (output plugin) Ͱૹ৴ Ͳ͜Ͱಈ͔͢? 1͚ͩઃఆ͢Δ? ͱ͔໘͕͍Ζ͍Ζ
Metrin - AWS CloudWatchͷ൚༻ࢹϓϥάΠϯ github.com/y13i/metrin $ metrin --namespace AWS/EC2 \
--metric-name CPUUtilization \ --statistic Average --dimension InstanceId:i-xxxxxxxxx \ --start-time -600 print --last-value-only CloudWatch.InstanceId.i-xxxxxxxxx.CPUUtilization.Average 1.468 1482596160 mackerel-agent ͕ѻ͑ΔܗࣜͰprint͢ΔͷͰ agent ͔Βୟ͘ 1ϝτϦοΫ͝ͱʹίϚϯυ࣮ߦ αʔϏεϝτϦοΫ mackerel-agent ͰߘͰ͖ͳ͍
mackerel-cloudwatch-forwarder github.com/shogo82148/mackerel-cloudwatch-forwarder Lambda function. JSONͰऔಘ͢ΔϝτϦοΫΛఆٛ { "service_metrics": [ { "service":
"your service name", "name": "metric name on mackerel", "metric": [ "Namespace", "MetricName", "Dimension1Name", "Dimension1Value", {} ], "stat": "Sum" } ], "host_metrics": [ { "hostId": "host id", "name": "metric name on mackerel", "metric": [ "Namespace", "MetricName", "Dimension1Name", "Dimension1Value", {} ], "stat": "Sum" } ] }
͜Ε·ͰͷιϦϡʔγϣϯ CloudWatch ͷ GetMetricStatistics API Λ͍ͬͯΔ → 1ϝτϦοΫ͝ͱʹ 1 API
call ͕ൃੜ͢Δ ઃఆͷ֬ೝ͕͍͠ → ಈ͔ͯ͠Έͳ͍ͱҙਤ͕ͨ͠సૹͰ͖͍ͯΔ͔͔ΓͮΒ ͍ (MackerelʹؒҧͬͨΛೖΕͯ͠·͏ͱফͮ͠Β͍)
cloudwatch-to-mackerel ෳͷϝτϦοΫΛҰׅऔಘͰ͖Δ GetMetricData API ͕ 20189݄ʹϦϦʔε ϝτϦοΫసૹπʔϧ & Go ϥΠϒϥϦΛ࡞Γ·ͨ͠
github.com/fujiwara/cloudwatch-to-mackerel MetricDataQuery JSON ͰऔಘɾసૹΛߦ͏ͷ
MetricDataQuery JSON [{ "Id": "m1", "Label": "service=MyService:alb.my-alb.response-time.p99", "MetricStat": { "Metric":
{ "Namespace": "AWS/ApplicationELB", "MetricName": "TargetResponseTime", "Dimensions": [{ "Name": "LoadBalancer", "Value": "app/my-alb/8e0641feccf3491c" }] }, "Period": 60, "Stat": "p99" } }, { "Id": "m2", "Label": "service=MyService:alb.my-alb.response-time.p90", "MetricStat": { "Metric": { "Namespace": "AWS/ApplicationELB", "MetricName": "TargetResponseTime", "Dimensions": [{ "Name": "LoadBalancer", "Value": "app/my-alb/8e0641feccf3491c" }] }, "Period": 60, "Stat": "p90" } }]
CLI $ cw2mkr metric-data-query.json ڥมͰೝূใ͕దʹઃఆͯ͋͠Ε͜Ε͚ͩ σϑΥϧτͰۙ3ͷϝτϦοΫΛసૹ -start-time -end-time Λࢦఆ͢Δͱաڈ্ॻ͖Ͱ͖Δ (Mackerelաڈ24࣌ؒ·Ͱड͚͚)
Go ϥΠϒϥϦ import ( "github.com/fujiwara/cloudwatch-to-mackerel/agent" ) query := []byte(`[ ...
]`) // MetricDataQuery JSON err := agent.Run(agent.Option{Query: query}) ڥมͰೝূใ͕దʹઃఆͯ͋͠Ε͜Ε͚ͩ Lambda Ͱಈ͔ͤ·͢
͍͍ͱ͜Ζ MetricDataQuery JSON aws-cli Ͱ͑ΔܗࣜͱಉҰ → aws cloudwatch get-metric-data
Ͱઃఆ֬ೝ͕༰қ ϗετɾαʔϏεϝτϦοΫ྆ରԠ Metric Math ʹରԠ → ෳϝτϦοΫͷԋࢉ݁ՌͰΞϥʔτͱ͔ Enjoy!