Upgrade to Pro — share decks privately, control downloads, hide ads and more …

CloudWatch&MonitoringTools

youyo
May 21, 2016

 CloudWatch&MonitoringTools

JAWS-UG函館20160521

youyo

May 21, 2016
Tweet

More Decks by youyo

Other Decks in Technology

Transcript

  1. "CloudWatch" » CloudWatchͰऔಘͰ͖ΔσʔλΛ΋͏গ͠ࡉ͔͘ݟ ͍ͯ͘ͱ » CPU࢖༻཰(CPUUtilization)ͱ͍͏߲໨ = Metrics » EC2ͱ͍͏αʔϏε

    = Namespace » MetricsΛಛఆͷ஋ͰΧςΰϥΠζ͢Δ΋ͷ = Dimension ͜ͷ̏ͭΛࢦఆ͢Δ͜ͱͰ໨తͷσʔλ͕ݟΕΔ Ωʔϫʔυ: Metrics,Namespace,Dimension
  2. "CloudWatch" » ΧελϜϝτϦΫε » ඪ४ϝτϦΫεҎ֎ͷಠࣗʹઃఆ͢ΔϝτϦΫε » APIܦ༝ͰఆٛՄೳ $ aws cloudwatch

    put-metric-data \ --namespace "MyService" \ --metric-name "ProcessCount" \ --dimensions InstanceId=i-xxxxxxxx \ --value 15
  3. "CloudWatch" » ΧελϜϝτϦΫε » σʔλαΠζʹ͸੍ݶ͕͋Δ » HTTP GET͸8KB » HTTP

    POST͸40KB » 1ͭͷPutMetricsDataϦΫΤετʹ20σʔλ· Ͱ » APIίʔϧ਺ʹ΋੍ݶ͋Γ
  4. "CloudWatch" » ֤छαʔϏεͷϦιʔεΛՄࢹԽ(άϥϑԽ)Ͱ͖Δ » ࣗ༝ʹϝτϦΫεΛ૊Έ߹ΘͤͨμογϡϘʔυ͕ ࡞ΕΔ » Create Dashboard =>

    Add widget » Widgetʹ͸Metrics graphͱText widgetͷ 2छྨ͋Δ » Text widgetʹ͸markdownܗࣜͷจষΛ࡞ΕΔ
  5. "CloudWatch-Logs" » AWSͷͦͷଞαʔϏε͕ग़ྗ͢Δϩάͷू໿ઌ » CloudWatch Logs AgentΛ࢖͏͜ͱͰEC2Πϯε λϯε಺෦ͷϩάͷू໿΋Մೳ » CloudWatch

    Logs Metrics Filter Ͱϩά͔Β ಛఆจࣈྻͷϑΟϧλϦϯά͕Մೳ » ϑΟϧλϦϯά݁ՌΛड͚औΔΧελϜϝτϦΫε Λ࡞੒͠ɺCloudWatchͷΞϥʔϜػೳͱ૊Έ߹ ΘͤͯΞΫγϣϯΛ࣮ߦՄೳ
  6. "CloudWatch-Logs" » CloudWatch Logs AgentΛ࢖͏͜ͱͰEC2Πϯε λϯε಺෦ͷϩάͷू໿΋Մೳ » CloudWatch-Logsʹॻ͖ࠐΉͷͰpermission ઃఆ͕ඞཁ »

    EC2 Role͔CloudWatch Logs AgentΠϯ ετʔϧޙͷΞΫηεΩʔઃఆ » AmazonLinuxͩͱΠϯετʔϧ΋؆୯ $ sudo yum install awslogs
  7. "CloudWatch-Logs" » CloudWatch Logs Agent ஫ҙ఺ » సૹͰ͖ΔϩάϝοηʔδαΠζ » Agent͕1ճʹϓογϡͰ͖ΔαΠζ͸࠷େ

    32KB » ͦΕΛ௒͑Δͱtruncate(੾Γ٧ΊΒΕΔ) » ରԠ͍ͯ͠Δϩάϩʔςʔγϣϯ » rename-recreate΍copy-truncateͳͲ
  8. "CloudWatch-Events" » AWSϦιʔεͷมߋ(Πϕϯτ)Λݕ஌ͯ͠ɺετϦʔ Ϝ఻ୡ(ΞΫγϣϯΛى͜͢͜ͱ)͕Ͱ͖ΔαʔϏε » Πϕϯτ: EC2 instance state change

    notification, AWS API Call, Auto Scaling, Schedule » ΞΫγϣϯ: AWS LambdaɺAmazon Kinesis StreamɺAmazon SNS, Bullet-inλʔήοτ » ϙʔϦϯάͰͷঢ়ଶ؂ࢹ͔Βͷղ์ » EventDrivenArchitectureͷத৺ʹͳΔͷ͔ͳʁ
  9. "CloudWatch-Events" » EC2 instance state change notification » ಛఆɺ·ͨ͸͍ͣΕ͔ͷΠϯελϯεͷঢ়ଶʹมԽ ͕͋ͬͨΒετϦʔϜ

    » runningʹͳͬͨΒɺͱ͔ɺrunningҎ֎ʹ ͳͬͨΒɺͳͲ » ঢ়ଶ͕stoppedʹͳͬͨΒrebootɺͱ͔ઃఆͰ ͖ͪΌ͏
  10. "CloudWatch-Events" » AWS API Call, Auto Scaling΋ಉ༷ » ΠϕϯτʹԠͯ͡ετϦʔϜ »

    AWS API Call: RDSͷDeleteDBInstance͕ ݺ͹ΕͨΒͱ͔ » Auto Scaling: EC2 Launch Successfulͩ ͬͨΒͱ͔ » ࠓ͸ϝδϟʔͳαʔϏεʹ͔͠ରԠͯ͠ͳ͍͚Ͳࠓޙ ରԠαʔϏεΛ૿΍͢༧ఆ ͬͯawsͷϒϩάʹॻ͍ͯͨͷͰ૿͍͑ͯ͘ͱࢥ͏
  11. "CloudWatch-Events" » ΞΫγϣϯ » Bullet-inλʔήοτ » Create a Snapshot of

    an EBS volume » Reboot EC2 instance » Terminate EC2 instance » Stop EC2 instance
  12. "CloudWatch-Events" » ScheduleͱCreate a Snapshot of an EBS volume૊Έ߹Θͤͯຖ೔εφοϓγϣοτࣗಈͰऔ ΕΔ

    » ศརɻ͓खܰɻ » Ͱ΋Snapshot࡟আʹ͸ରԠͯ͠ͳ͍ » ࡟আ͸ಉ͡Α͏ʹScheduleͰLambdaͰ΋ಈ͔ͯ͠ ΍Ε͹͍͍
  13. "Zabbix" » Ͳ͏͍͏ํ਑Ͱ؂ࢹ͍͔ͯ͘͠Α͘ߟ͑Δඞཁ͕͋Δ » ࠷ۙ͸MackerelྲྀߦͬͯΔ͠AWSΠϯςάϨʔγϣ ϯग़ͨ͠ɺMonitoring as a Service࢖͏ͷ΋શ વ͋Γɻ

    » ͦ΋ͦ΋CloudWatch͕ͦΕͩ͠ɺCloudWatchʹ· ͱΊΔͷ΋Ұͭͷղ » ສ͕ҰCloudWatchʹো֐ى͜ΔͱɺͦΕΛࣗ෼Ͱ͸ ίϯτϩʔϧͰ͖ͳ͍ɻ؂ࢹαʔϏεΛఏڙ͢Δฐࣾ ͱͯ͠͸NG
  14. "ϝϯςφϯεΠϕϯτΛݕ஌͍ͨ͠" » CloudWatch-Events + AWS Lambda + Slack » ࢦఆͨ͠ΞΧ΢ϯτ಺ͷશΠϯελϯεͷϝϯςφϯ

    εΠϕϯτͷ༗ແΛνΣοΫ͢ΔLambda Function Λ࡞੒ » ͦΕΛCloudWatch-EventsͷScheduleͰ1೔1ճ ࣮ߦ » ϝϯςφϯεΠϕϯτ͕͋Ε͹Slackʹ௨஌͍ͯ͠Δ
  15. "ͳΜͪΌͬͯAmazon RDS for Aurora" » Amazon RDS for AuroraͰ͸ετϨʔδ͕ࣗಈ֦ ு͢Δ

    » Amazon RDS for MySQLͰ͸ετϨʔδαΠζΛࣗ ෼Ͱઃఆ͢Δ » ετϨʔδͷۭ͖༰ྔ͕গͳ͘ͳͬͨͱ͖ʹΞΫγϣ ϯى͜͢ΞϥʔϜઃఆͰ͖Δ
  16. "ͳΜͪΌͬͯAmazon RDS for Aurora" » ΠϕϯτυϦϒϯʂ » ฐࣾZabbixͰ͓ࢼ͠த » ࣗಈͰετϨʔδ֦ு͞Ε

    ͨΒSlackʹ΋௨஌͞ΕΔ (ਤʹࡌͤ๨Εͨ) » ֦ுத͸ύϑΥʔϚϯε௿ ԼͷڪΕ͋Δ͚ͲɺͦΕ͕ উखʹ࣮ߦ͞ΕΔ͜ͱΛڐ ༰Ͱ͖ΔͳΒ͋Γ