ããã«ã¡ã¯ã ã·ã¹ãã æ¬é¨CTO室ã®akasakasã§ãã
ä»åã¯ãDatadog Log Management ã使ã£ã¦ã¢ããªã±ã¼ã·ã§ã³ç¨¼åã¢ãã¿ãªã³ã°ããã¦ãã話ããããã¨æãã¾ãã
- ä¸ä¼ã®ã¢ãã¿ãªã³ã°å¨ãã®è©±
- ã¢ãã¿ãªã³ã°è¦³ç¹ã§ä¸ä¼ãæ±ãã¦ãã課é¡
- Datadog Log Management
- Datadog Log Management ããããã·ã¥ãã¼ãä½æ
- Datadog Log Management ããã¢ã©ã¼ãä½æ
- å¿ è¦ãªã¡ããªã¯ã¹ã¯ã«ã¹ã¿ã ã¡ããªã¯ã¹ãä½ã
- graph_snapshot API ã使ã£ã¦ããã¤ãªã¼ã¬ãã¼ã
- ã¾ã¨ã
- æå¾ã«
ä¸ä¼ã®ã¢ãã¿ãªã³ã°å¨ãã®è©±
Datadog Log Management ã¨ã¢ããªã±ã¼ã·ã§ã³ç¨¼åã¢ãã¿ãªã³ã°ã®è©±ãããåã«ãä¸ä¼ã§ã©ã®ãããªç£è¦ããã¦ããã®ãï¼ã¨ãã話ãç°¡åã«ãã¾ãã
ä¸ä¼ã§ã¯Datadogãã¢ãã¿ãªã³ã°ãã¼ã«ã¨ãã¦ä½¿ã£ã¦ãã¾ãã 主ãªç¨éã¯2ã¤ããã¾ãã
- ã¤ã³ãã©ã®ãªã½ã¼ã¹ã¢ãã¿ãªã³ã°
- å¤å½¢ç£è¦
ã¤ã³ãã©ã®ãªã½ã¼ã¹ã¢ãã¿ãªã³ã°
ã¤ã³ãã©ã¡ããªã¯ã¹ã®ããã·ã¥ãã¼ãã¨ã¢ã©ã¼ãã®è¨å®ã¯éç¨ã¨ãã¦ä¹ã£ã¦ãã¾ãã å ·ä½çã«ã¯ããµã¼ãã¹ï¼å®¿æ³ã»ã¬ã¹ãã©ã³etcï¼æ¯ã®ã¢ããªã±ã¼ã·ã§ã³ãµã¼ããDBãµã¼ãã®ã¢ãã¿ãªã³ã°ããã¦ãã¾ãã
CPUã§é¾å¤ãè¶ ããããSlackéç¥ãé£ã³ãã¨ã³ã¸ãã¢ã対å¿ããã¨ããå½¢ãã¨ã£ã¦ãã¾ãã
å¤å½¢ç£è¦
Datadog Synthetics API Tests ã使ã£ã¦ãå¤å½¢ç£è¦ããã¦ãã¾ãã ãã¡ããåæ§ã«ãå¤å½¢ç£è¦ã§ç°å¸¸ãèµ·ããããSlackã«éç¥ãé£ã³ãã¨ã³ã¸ãã¢ã対å¿ãã¾ãã
ã¢ãã¿ãªã³ã°è¦³ç¹ã§ä¸ä¼ãæ±ãã¦ãã課é¡
ã¤ã³ãã©ã¬ã¤ã¤ã¼ã§ã®ã¢ãã¿ãªã³ã°ã¯ã§ãã¦ããããã¢ããªã±ã¼ã·ã§ã³ã¬ã¤ã¤ã¼ã§ã®ã¢ãã¿ãªã³ã°ã¯ã§ãã¦ããªãã¨ããã®ã課é¡æã¨ãã¦ããã¾ããã
ããã§ããã¢ããªã±ã¼ã·ã§ã³ã¬ã¤ã¤ã¼ã§ã®ã¢ãã¿ãªã³ã°ã¨ã¯
- äºç´ãæ£å¸¸ã«ã§ãã¦ãããã©ãã
- ã¨ã©ã¼ãå¤çºãã¦ãªããï¼
- äºç´éç¥ã¡ã¼ã«ãæ£å¸¸ã«éããã¦ãããã©ãã
- ã¡ã¼ã«é信件æ°ãé©åãï¼ç°å¸¸ã«å¤ããå°ãªãã¨ãããã¨ã¯ãªããï¼
- æ¤ç´¢å°ç·ã§ã®ãªã¯ã¨ã¹ãæ°ãã©ã®ç¨åº¦ããã®ãï¼ã¨ã©ã¼ãã©ã®ç¨åº¦ããã®ãï¼
ã¨ãããµã¼ãã¹ã®ç¶æ ããã«ã·ã¼ãã©ããã¨ãã観ç¹ã§ãã
â»ã¬ã¤ãã³ã·ã¼ãã¨ã©ã¼ã¬ã¼ãã¨ãã£ãAPMã¨ã¯ç°ãªãã¾ããDatadog APMã¯ä¸é¨ã®ãµã¼ãã¹ã§éç¨ãã¦ãã¾ãã
ããããæç³»åã§ç£è¦ã(e.g. 10åæ¯ã®äºç´ä»¶æ°/1æ¥ãã¨ã®ã¡ã¼ã«é信件æ°) ç°å¤ãããã°ãã¢ã©ã¼ããé£ã°ãã¨ããä»çµã¿ãããã°ããã¡æ©ãé害ã«æ°ã¥ããã¨èãã¾ããã
Datadog Log Management
ãã®ã¢ããªã±ã¼ã·ã§ã³è¦³ç¹ã®ç£è¦ãããããã«ãDatadog Log Managementãæå¹ã ã¨èãã¾ããã
Datadog Log Management 㯠Datadog ä¸ã§ãã°ã管çãããµã¼ãã¹ã§ãã
ä¸ä¼ã§ã¯æ¨å¹´ãã°ç®¡çãµã¼ãã¹ãLogentriesããDatadog Log Management ã«å®å ¨ç§»è¡ãã¾ããã
å°å ¥æ¹æ³ã詳細ãªä½¿ãæ¹ã¯å²æãã¾ãã
Datadog Log Management ã使ã£ã¦ãã¢ããªã±ã¼ã·ã§ã³ãã°ã»ã¢ã¯ã»ã¹ãã°ããã¼ã¹ã«æç³»åã®äºç´ç¶æ³ã»æ¤ç´¢æ°ã®æ¨ç§»ã»ã¡ã¼ã«é信件æ°etcãéè¨&ããã·ã¥ãã¼ãã§ã°ã©ãå&ã¢ã©ã¼ãã®è¨å®ãã§ããã°ãã¢ããªã±ã¼ã·ã§ã³ç¨¼åã¢ãã¿ãªã³ã°ãå®ç¾ã§ããã¨èãã¾ããã
Datadog Log Management ããããã·ã¥ãã¼ãä½æ
å®éã«Datadog Log Management ããä½æããã¢ããªã±ã¼ã·ã§ã³ã¢ãã¿ãªã³ã°ã®ããã·ã¥ãã¼ãããã¡ãã§ãã
ã°ã©ãã®ä½ææ¹æ³ã¯
- LogEvents ãé¸æ
- ã¿ã°ã§çµãè¾¼ã¿
ã®ã¿ã§ãç°¡åã§ãã
Datadog Log Management ããã¢ã©ã¼ãä½æ
äºç´ç¶æ³ã®ç£è¦ãã¢ã©ã¼ãã§æ¤ç¥ãããã¨ãã§ãã¾ãã
New Monitor ãã Logs ãé¸æããæ¤ç´¢ã¯ã¨ãªãæå®ããã°ãMonitorãä½æã§ãã¾ãã
å¿ è¦ãªã¡ããªã¯ã¹ã¯ã«ã¹ã¿ã ã¡ããªã¯ã¹ãä½ã
Datadog Log Management ã§ã¯åå¾ã§ããªãã¡ããªã¯ã¹ãããã¨æãã¾ãã ãã®å ´åã¯ãDatadog API ã使ã£ã¦ãã«ã¹ã¿ã ã¡ããªã¯ã¹ãä½ãã¾ãã
ã¡ããªã¯ã¹ API ã«ã¤ãã¦ã¯ä¸è¨ãã覧ãã ããã docs.datadoghq.com
Datadog API ãæ±ãéã¯Rubyã¨Pythonã§ãããã API Clientãããã®ã§ããã¡ãã使ãã®ãããã¨æãã¾ãã
GitHub - DataDog/datadogpy: The Datadog Python library
GitHub - DataDog/dogapi-rb: Ruby client for Datadog's API
ã«ã¹ã¿ã ã¡ããªã¯ã¹ãä½ãä¾ã¨ãã¦ãä¸ä¼ã§ã¯æ¤ç´¢ã«Solrã使ã£ã¦ãã¾ãã Solrã®Indexæ°ãç£è¦ãããã¨ããå ´åã¯ãSolrããIndexæ°ãåå¾ããAPIã使ã£ã¦ã«ã¹ã¿ã ã¡ããªã¯ã¹ãä½æãDatadogã«éä¿¡ãã¾ãã
å ·ä½çã«ã¯ä¸è¨ã®ãããªã¹ã¯ãªãããLambdaã§å®æå®è¡ããã¤ã¡ã¼ã¸ã§ãã
from datadog import initialize, api import time import requests options = { 'api_key': '<DATADOG_API_KEY>' } initialize(**options) # Solrã«ãªã¯ã¨ã¹ã r = requests.get('<Solr Endpoint>') # Indexæ°åå¾ index_count = r.json()['index_count'] now = time.time() # Solrã®indexæ°ãã«ã¹ã¿ã ã¡ããªã¯ã¹ã«ãã¦ãDatadogã«éä¿¡ api.Metric.send(metric="solr.index.count", points=(now, index_count), type="count")
ã«ã¹ã¿ã ã¡ããªã¯ã¹ãä½æã§ããã°ãDatadogä¸ã§ããã·ã¥ãã¼ãã¨ã¢ã©ã¼ããè¨å®ã§ãã¾ãã
Datadog Log Management ããåå¾ã§ããªãããç£è¦ãããé ç®ã«ã¤ãã¦ã¯ ã«ã¹ã¿ã ã¡ããªã¯ã¹ãä½ãã®ãã¢ãªã ã¨æãã¾ãã
graph_snapshot API ã使ã£ã¦ããã¤ãªã¼ã¬ãã¼ã
ãã ãåç´ã«
- ããã·ã¥ãã¼ãä½ãã¾ãã
- ã¢ã©ã¼ãä½ãã¾ãã
ã ãã ã¨ããã£ããä½ã£ãããã·ã¥ãã¼ããã¢ã©ã¼ããã¨ã³ã¸ãã¢ããå¿ãå»ããããã¨ããæ¸å¿µãããã¾ããã
ãªã®ã§ããã¢ããªã±ã¼ã·ã§ã³ã¡ããã¨åãã¦ãããï¼ã¨ã©ã¼ã¡ãã£ã¨å¤ããï¼ãã¨ããã®ãä¼ããæå³ãè¾¼ãã¦ããã¤ãªã¼ã¬ãã¼ããslackã«æ稿ããããã«ãã¾ããã
ä¸è¨ã®ãããªã¤ã¡ã¼ã¸ã§ãã
ãã¤ãªã¼ã¬ãã¼ãããããã¨ã§ããã¨ã©ã¼ã¡ãã£ã¨å¤ããã確èªããæ¹ããããªãï¼ãã¿ãããªãã¨ã«ãªãã調æ»&対å¿ããã¨ããæ¹åã§ã¨ã³ã¸ãã¢ãåãã¦ããã¾ãã
ãã㯠graph_snapshot API ã使ã£ã¦ããã£ããã£ãä½ããSlackã«æ稿ããã¹ã¯ãªãããLambdaã§æ¥æã§åããã¦ãã¾ãã
graph_snapshot API ã«ã¤ãã¦ã¯ä¸è¨ãã覧ãã ããã
graph_snapshot API ã«ã¤ãã¦ã¯ç´°ããã¨ãããå«ãã¦ãããã¤ã注æç¹ãããã®ã§æ¸ãã¨ãã¾ãã
1.ããã©ã«ãã® Rate Limitiing ããã£ããå³ãã
https://docs.datadoghq.com/ja/api/?lang=bash#rate-limiting ã«è¨è¼ãããéãã
graph_snapshot API å¼ã³åºãã®ã¬ã¼ãå¶éå¤ã¯ã60/æé/Organization ã§ããããã¯ããªã³ããã³ãã§å¢ãããã¨ãã§ãã¾ãã
ã¨ããã®ã§ãç¡éªæ°ã«APIãå©ãã¦ããã¨ãããã«å¼ã£ãããã¾ãã
2. graph_snapshot API ã®ã¿ã¤ã ã¾ã¼ã³ãUTCåºå®
graph_snapshot API ã®ã¿ã¤ã ã¾ã¼ã³ã¯UTCã«ãªã£ã¦ãã¦ãä»»æã®ã¿ã¤ã ã¾ã¼ã³ã«å¤æ´ã§ãã¾ããã
3. API ãªã¯ã¨ã¹ãã§æ¸¡ããã©ã¡ã¼ã¿ãã¡ãã£ã¨è¤é
graph_snapshot API ã§ã°ã©ããä½æããå ´åã®APIãªã¯ã¨ã¹ãã§JSONãæ±ãå ´åãããã®ã§ãã¡ãã£ã¨é¢åã§ãã
DashBoardã¨åæ§ã®ã°ã©ããä½ãããå ´åã¯ã該å½ããã°ã©ãã®JSONããªã¯ã¨ã¹ãã«ã¤ããå¿ è¦ãããã¾ãã
GitHub - DataDog/datadogpy: The Datadog Python library ã使ã£ããµã³ãã«ä¾ã以ä¸ã«ãªãã¾ãããJSONãé·ããªã£ã¦ãã¾ãã®ãå°ãç ©ãããæããããããã¾ããã
from datadog import initialize, api import time options = { 'api_key': '<DATADOG_API_KEY>', 'app_key': '<DATADOG_APPLICATION_KEY>' } initialize(**options) # Take a graph snapshot end = int(time.time()) start = end - (60 * 60) resp = api.Graph.create( graph_def='{\ "viz": "timeseries", \ "requests": [ \ { \ "q": "xxxxxxxxxxx", \ "type": "bars", \ "style": { \ "palette": "dog_classic", \ "type": "solid", \ "width": "normal" \ } \ } \ ], \ "yaxis": { \ "scale": "linear", \ "min": "auto", \ "max": "auto", \ "includeZero": true, \ "label": "" \ }, \ "markers": [] \ }', start=start, end=end ) print(resp["snapshot_url"])
ã¾ã¨ã
ä»åã¯ãDatadog Log Management ã使ã£ã¦ãã¢ããªã±ã¼ã·ã§ã³ç¨¼åã¢ãã¿ãªã³ã°ãå®ç¾ãã話ããã¾ããã
åç´ãªãã°ç®¡çãã¼ã«ã¨ãã¦ä½¿ãã ãã§ããDatadog Log Management ã¯ä¾¿å©ã§ããã ããã·ã¥ãã¼ããã¢ã©ã¼ããªã©ãçµã¿åããããã¨ã§ãã¢ããªã±ã¼ã·ã§ã³ã®ç¶æ ãä¸ç®ã§ãããã¨ããã®ã¯ããã¨æãã¾ããã
æå¾ã«
Datadogã®ãµãã¼ãã®çæ§ã«ã¯ãã¤ãå©ãããã¦ãã¾ãã ã©ããªåãåããã«å¯¾ãã¦ãããã¤ãä¸å¯§ã«ãµãã¼ãé ãã¦ããDatadogã®çæ§ã«å¾¡ç¤¼ç³ãä¸ãã¾ãã