Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
CloudWatch から Mackerel にメトリックを送る方法 2019年版 / Mac...
Search
FUJIWARA Shunichiro
March 01, 2019
Technology
3.3k
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
クラウドを使う側から、作る側へ / 大吉祥寺.pm 2026前夜祭
fujiwara3
8
2.1k
作るべきものと向き合う - ecspresso 8年間の開発史から学ぶ技術選定 / 技術選定con findy 2026
fujiwara3
9
5.6k
さくらのクラウドでのシークレット管理を考える/tamachi.sre#2
fujiwara3
2
380
Amazon ECS デプロイツール ecspresso の開発を支える「正しい抽象化」の探求 / YAPC::Fukuoka 2025
fujiwara3
13
13k
パフォーマンスチューニングのために普段からできること/Performance Tuning: Daily Practices
fujiwara3
9
6.8k
alecthomas/kong はいいぞ
fujiwara3
7
2.6k
ecspressoの設計思想に至る道 / sekkeinight2025
fujiwara3
12
3.8k
さくらのIaaS基盤のモニタリングとOpenTelemetry/OSC Hokkaido 2025
fujiwara3
4
5.1k
監視のこれまでとこれから/sakura monitoring seminar 2025
fujiwara3
12
5.9k
Other Decks in Technology
See All in Technology
コネクションをピン留めさせずに SELECTクエリのタイムアウトを設定した話
codmoninc
0
220
tamachi.go 誕生の裏側
rymiyamoto
1
200
【GCC2026】鉄拳8でのVFX開発事例
bandainamcostudios
PRO
0
280
MulticaとPi Coding Agentで、小規模OSSを30本同時運用した流れ
eiei114
0
140
【GCC2026】大規模言語モデルを活用した内製検索サービスの社内展開や業務活用
bandainamcostudios
PRO
0
520
【GCC2026】TrueHDRIを用いたルックデブ環境とライティングテクニック
bandainamcostudios
PRO
0
330
[potatotips #96] Give Your AI Agent the Flutter Playbook
korodroid
0
150
AI開発に用いられるHPC技術について
gpuunite_official
0
260
アクセスキーが漏れた日にやるべきこと- 無効化の先にある本当の対応
kazzpapa3
0
270
私がブラウザを自作したくなった理由
supurazako
1
280
AI時代に、人は何を、どう学ぶのか #pbl_pub / What and How Do We Learn in the AI Era?
takaking22
1
240
AI・HPC開発を支えるGPU環境の新しい選択肢 液冷GPUシステム「AquSys」の取り組み
gpuunite_official
0
230
Featured
See All Featured
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.8k
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
410
The Mindset for Success: Future Career Progression
greggifford
PRO
0
470
The browser strikes back
jonoalderson
0
1.5k
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
500
Designing for Performance
lara
611
70k
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
4.2k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
500
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
66
57k
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
470
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
1.1k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
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!