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

Datadog Agent on CloudRunによるGCPトレーサビリティの向上

Datadog Agent on CloudRunによるGCPトレーサビリティの向上

More Decks by 株式会社ビットキー / Bitkey Inc.

Other Decks in Technology

Transcript

  1. ࠤʑ໦ྃ 3ZP4BTBLJ   ๭௨৴ܥ4*FSೖࣾ ɾݩʑ͸/8ΤϯδχΞͩͬͨͷͰ#(1࢖ͬͨଞڌ఺/8࡞ͬͨΓͱ͔ ɾ࣏ࣗମͱ͔׭ެிܥγεςϜʹܞΘͬͨΓ͢Δ͜ͱ͕ଟ͔͔ͬͨͳ ɾڮྊ఺ݕϩϘοτ։ൃ΍ͬͨΓͱ͔ ϑϦʔϥϯεʹస޲ ɾϖωτϨʔγϣϯςετ΍ͬͨΓͱ͔

    ɾ0QFO4UBULͱ0QFO4IJGU݁ߏ΍ͬͯͨΓͱ͔ ɾϋΠϒϦουΫϥ΢υ࡞ͬͨΓͱ͔  ϏοτΩʔʹ43&ͱͯ͠δϣΠϯ ˞ͿͬͪΌ͚͋·Γ43&΍ͬͯͳ͍͚ͲͶ ެͷ৔Ͱਓʹઆ໌Ͱ͖ΔΑ͏ͳً͔͍͠ܦྺ͸࣋ͬͯͳ͍ͷͰ αΫοͱྲྀ͠·͢ʂʂʂ
  2. Bitkeyʹ͓͚ΔαʔϏεΞʔΩςΫνϟ - جຊతʹ($1Λར༻ͨ͠αʔόʔϨεΞʔΩςΫνϟ - CloudFunctions (AWSͰ͍͏ͱ͜ΖͷLambda) - CloudRun (AWSͰ͍͏ͱ͜ΖͷAppRunner͕͍ۙ) -

    *P5੡඼͕͍͔ͭ͘ଘࡏ͢Δ͕ɺͦΕΒ͸AWS IoTʹΑͬͯߏ੒ - Ճ͑ͯͦΕΒΛॲཧ͢ΔͨΊʹLambda API GatewayΛར༻  GCP x AWS ͳ ΞʔΩςΫνϟ
  3. Bitkeyʹ͓͚Δݱঢ়ͷ෼ࢄτϨʔεར༻ʹ͍ͭͯ - ͳͥDatadog APMͷTraceػೳͰ͸μϝͩͬͨͷʁ - ࠷ॳʹߟ͑ͨͷ͸౰વDatadog APMͩͬͨ - "1.ར༻ͷͨΊʹ͸ Datadog

    Agent ͕ඞཁ - LT΍"84'BSHBUFͰ͸ެࣜαϙʔτ͞Ε͍ͯΔ͕ɺ 
 #JULFZͷϝΠϯͰ͋Δ($1$MPVE'VODUJPOTͰ͸αϙʔτ͞Ε͍ͯͳ͍  ͦΕ΋ͦͷ͸ͣͰAgent͸αΠυΧʔతʹಈ͘ ※k8sͷ৔߹ͪΐͬͱޠฐͷ͋Δݴ͍ํ͚ͩͲ
  4. Bitkeyʹ͓͚Δݱঢ়ͷ෼ࢄτϨʔεར༻ʹ͍ͭͯ - -BNCEBͰ͋Ε͹Extension΍Datadog ForwarderͳͲΛ࢖ͬͯ؆୯ʹτϨʔε΍ ϩάσʔλΛऩूͰ͖Δ - 93BZͰྑ͍ͳΒ͞Βʹ؆୯ʹ࿈ܞͰ͖Δ - EEUSBDFWT93BZ͸ҎԼΛࢀর -

    IUUQTEPDTEBUBEPHIRDPNKBTFSWFSMFTTEJTUSJCVUFE@USBDJOH - 'BSHBUFͷ৔߹ɺͦ΋ͦ΋1PEతʹෳ਺ίϯςφΛ·ͱΊͯىಈͰ͖ΔͨΊ 
 "HFOUΛαΠυΧʔͱͯ͠ىಈͰ͖Δ  GCF ΍ CloudRun Ͱ͸͜Ε͕Ͱ͖ͳ͍
  5. Datadog AgentΛGCPͰ௿ίετͰ࢖͏ͨΊʹؤுͬͨ࿩ FYQPSUFSͷ౤͛ઌΛม͑Δ͚ͩʂʂʂʂ  gcloud beta run deploy dd-agent \

    --image gcr.io/datadoghq/agent \ --port 8126 \ --memory 1024Mi \ --region asia-northeast1 \ --allow-unauthenticated \ --set-env-vars "DD_HOSTNAME=common-dd-agent" \ --set-env-vars "DD_APM_ENABLED=true" \ --set-env-vars "DD_APM_NON_LOCAL_TRAFFIC=true" \ --set-secrets "DD_API_KEY=DD_API_KEY:latest" \ --execution-environment gen2 ͓΋ΉΖʹgcloudίϚϯυΛࡌ͓ͤͯ͘ɻ͜ΕͰऴΘΓɻ
  6. Datadog AgentΛGCPͰ௿ίετͰ࢖͏ͨΊʹؤுͬͨ࿩ Datadog Agent on CloudRunͷྑ͞ - ϑϧϚωʔδυͳͷͰΊͪΌͪ͘Όӡ༻ίετ͕௿͍ - ෇ਵϦιʔε

    71$΍-# ͷઃܭ΍؅ཧ͕ෆཁ - ެࣜʹఏڙ͞Ε͍ͯΔίϯςφΠϝʔδΛ࢖ͬͯɺ͋ͱ͸؀ڥม਺ͱͯ͠ 
 ίϯϑΟάΛ༩͑ͯ͋͛Ε͹ͦΕͰऴΘΓ  $MPVE'VODUJPOT %BUBEPH"HFOUPO$MPVE3VO EEUSBDF1VTI $POUBJOFS 3FHJTUSZ
  7. Datadog AgentΛGCPͰ௿ίετͰ࢖͏ͨΊʹؤுͬͨ࿩ Datadog Agent on CloudRunͷྑ͞ - Կ΋ߟ͑ͣͱ΋উखʹΦʔτεέʔϧͯ͘͠ΕΔͷͰ 
 ࠓޙͷεέʔϥϏϦςΟʹ΋ඇৗʹ༏ΕΔ

    - #JULFZ࣮੷ͩͱɺΠϯελϯε਺d͙Β͍Ͱ೔ʑεέʔϧ͍ͯ͠Δ - Ͳ͏ͤ($1ͷ%$಺෦ͰΠϯλʔίωΫτͳ௨৴͕ߦΘΕΔͷͰ 
 ($'͔ΒݟͯϨΠςϯγ͕ݱ࣮తʹ໰୊ʹͳΔ͜ͱ͸ͳ͍͸ͣ ໝ૝ 
  8. Datadog AgentΛGCPͰ௿ίετͰ࢖͏ͨΊʹؤுͬͨ࿩ • ࢀߟఔ౓ʹ%BUBEPH"HFOUͰ࢖͏؀ڥม਺ͱ͔ ◦ IUUQTEPDTEBUBEPHIRDPNKBDPOUBJOFSTEPDLFS UBC&"&#"FOWJSPONFOUWBSJBCMFT ◦ IUUQTEPDTEBUBEPHIRDPNKBDPOUBJOFSTEPDLFSBQN UBCMJOVY

    • ͜ͷลΛΑ͘࢖͏͸ͣ  Key Value ิ଍ DD_APM_ENV your_environment datadog্Ͱೝࣝ͞ΕΔenvͷσϑΥϧτઃఆɻ ΫϥΠΞϯτίʔυଆͰ্ॻ͖Ͱ͖Δɻ DD_HOSTNAME your_ddagent_name ࢦఆͨ͠ϗετ໊Ͱdatadogʹه࿥͞ΕΔͷͰͪΌΜ ͱߟ͑ͯʂ DD_APM_ENABLED true APMͷ༗ޮԽઃఆ DD_OTLP_CONFIG_RECEIVER_PROT OCOLS_HTTP_ENDPOINT 0.0.0.0:4318 ޙड़͢ΔOpenTelemetyͷαϙʔτͷͨΊʹඞਢ DD_APM_NON_LOCAL_TRAFFIC true ֎෦τϥϑΟοΫΛड͚෇͚Δઃఆɻ ࠓճͷΑ͏ͳέʔεͷ৔߹trueඞਢ DD_API_KEY Secret:DD_API_KEY:latest ݴΘͣ΋͕ͳɻฏจͰஔ͔ͳ͍Α͏ʹ͠·͠ΐ͏ɻ
  9. Datadog AgentΛGCPͰ௿ίετͰ࢖͏ͨΊʹؤுͬͨ࿩ ஫ҙ఺ - $MPVE3VOͷGen2 Λ࢖͓͏ - (FO͸-JOVYͷΤϛϡϨʔγϣϯͰ͋Δ͜ͱ΋͋ͬͯΊͪΌͪ͘ΌΤϥʔग़Δ - Gen2͸Linuxͦͷ΋ͷͳͷͰશ͘໰୊ͳ͠

    - ͨͩͦ͠ΕͰ΋%BUBEPH"HFOU͕ఏڙ͢Δ֤छػೳ͕ 
 ͪΐͪ͜ΐ͜Τϥʔग़͢λΠϛϯά͕͋ΔͷͰແବͳػೳ͸ఀࢭͪ͠Όͬͨํ͕ྑ͍ - QSPDFTTͱ͔TZTQSPCFͱ͔ 
  10. Datadog AgentΛGCPͰ௿ίετͰ࢖͏ͨΊʹؤுͬͨ࿩  Infrastructure as Code ΋ָউ • طʹCloudRunΛߏ੒͢ΔͨΊͷterraformίʔυ͸ࣾ಺Ͱطʹཱ֬ ◦

    ͜ͷߏ੒΋αΫοͱίʔυԽ׬ྃʂ • $MPVE3VOͳͷͰ༨ܭͳ͜ͱΛߟ͑Δ͜ͱ΋গͳ͘ΊͪΌͪ͘ΌָͪΜӡ༻ʂ • উखʹεέʔϧͯ͘͠ΕΔͷͰ࠾༻ϓϩμΫτ͕૿͖͔͑ͯͨΒෛՙ͕ɾɾɾͱ͔ ߟ͑ͳͯ͘0,
  11. Datadog AgentΛGCPͰ௿ίετͰ࢖͏ͨΊʹؤுͬͨ࿩ FYQPSUFSͷ౤͛ઌΛม͑Δ͚ͩʂʂʂʂ  import tracer from 'dd-trace'; export const

    setupTracing = (args: {serviceName?: string; serviceVersion?: string}) => { return tracer.init({ service: args.serviceName ?? 'unknownFunction', version: args.serviceVersion ?? 'unknownVersion', url: 'https://your-dd-agent.run.app', env: 'develop', }); }; ͍ͬ͢͝୯७ɻurl౉ͯ͋͛͠Δ͚ͩɻ؀ڥม਺Ͱ΋Մɻ
  12. Datadog AgentΛGCPͰ௿ίετͰ࢖͏ͨΊʹؤுͬͨ࿩ - yes - ͋Δఔ౓ɺ$MPVE"SNPSͰෆਖ਼ͳ௨৴͸๷ޚՄೳ - ͕ɺͦͷΤϯυϙΠϯτʹରͯ͠%BUBEPH"HFOU͕ߏங͞Ε͍ͯΔ͜ͱΛ 
 ஌ΒΕͨ৔߹ʹ͸Ͳ͏͠Α͏΋ͳ͍

    - ݱ࣮తʹຊ൪؀ڥͰ࠾༻͢ΔͷͰ͋Ε͹ɺαʔόʔϨείωΫλʔͰ 
 ($'΍$MPVE3VOͨͪͱΠϯλʔφϧ઀ଓ͠ɺ಺෦తͳΞΫηε͚ͩʹ 
 ݶఆ͓͍ͯͨ͠ํ͕ઈରྑ͍ 
  13. ݒ೦఺ͱࠓޙͷ࿩ - ·ͱΊ - %BUBEPH"1.͸6*69͕༏Ε͍ͯͯϚδͰ௙ΔΑ - LT΍"84ʹґଘͨ͠αʔϏε͡Όͳ͍ΜͩΑͳ͊ɾɾɾ 
 "1.࢖͑ͳ͍Μ͔ͳ͍͊ͬͯ͏ਓɺఘΊͳ͍Ͱʂʂ -

    ίϯςφΠϝʔδ͕͋ΔΜ͔ͩΒͲ͏ʹͰ΋ͳΔΑ - $MPVE3VO࢖͑͹ϚδͰ௒ઈָͪΜʹ࣮૷ͱӡ༻͕Ͱ͖ΔΑ - ࠓͷ%BUBEPH"HFOU͸0QFO5FMFNFUSZʹରԠ͍ͯ͠ΔͷͰɺ 
 طଘ࣮૷͔ΒͷϚΠάϨʔγϣϯ͸௿ίετʹ͍͚ΔΑ 
  14. ݒ೦఺ͱࠓޙͷ࿩ - Φν - LT࢖͍׳ΕͯΔͳΒ 
 (,&"VUPQJMPUͰ࣮૷ͨ͠ํ͕ 
 ָͩ҆͠৺Ͱ͖ͦ͏ɻ 


    )FMNͰΠϯετʔϧ΋Ͱ͖Δ͠Ͷɻ - ࢀߟIUUQTEPDTEBUBEPHIRDPNKBDPOUBJOFSTLVCFSOFUFTEJTUSJCVUJPOT UBCIFMNBVUPQJMPU  apiVersion: apps/v1 kind: Deployment metadata: name: dd-agent spec: replicas: 3 selector: matchLabels: app: dd-agent template: metadata: labels: app: dd-agent spec: containers: - name: dd-agent image: datadog/agent:latest ports: - containerPort: 8126 env: - name: DD_API_KEY valueFrom: secretKeyRef: name: dd-api-key key: DD_API_KEY