Datadog
A cloud monitoring and security platform
A cloud monitoring and security platform
Datadog is a SaaS platform that provides integrated monitoring of cloud-scale infrastructure, applications, and logs. Founded in 2010, it is one of the most widely used commercial monitoring solutions today, offering the three pillars of observability โ metrics, logs, and traces โ in a single platform.
# /etc/datadog-agent/datadog.yaml
api_key: "your-api-key-here"
site: "datadoghq.com" # EU๋ datadoghq.eu
# ํธ์คํธ ํ๊ทธ ์ค์
tags:
- env:production
- service:api-server
- team:platform
# APM ์ค์
apm_config:
enabled: true
apm_dd_url: https://trace.agent.datadoghq.com
# ๋ก๊ทธ ์์ง ํ์ฑํ
logs_enabled: true
logs_config:
container_collect_all: true
processing_rules:
- type: exclude_at_match
name: exclude_healthchecks
pattern: "GET /health"
# ํ๋ก์ธ์ค ๋ชจ๋ํฐ๋ง
process_config:
enabled: true
container_collection:
enabled: true
# DogStatsD ์ค์
dogstatsd_port: 8125
dogstatsd_non_local_traffic: true
# datadog-values.yaml - Helm Chart ์ค์
datadog:
apiKey: ${DD_API_KEY}
appKey: ${DD_APP_KEY}
site: datadoghq.com
# ํด๋ฌ์คํฐ ์ด๋ฆ
clusterName: production-k8s
# ํ๊ทธ
tags:
- env:production
- region:ap-northeast-2
# APM ํ์ฑํ
apm:
portEnabled: true
socketEnabled: true
# ๋ก๊ทธ ์์ง
logs:
enabled: true
containerCollectAll: true
# ํ๋ก์ธ์ค ๋ชจ๋ํฐ๋ง
processAgent:
enabled: true
processCollection: true
# ํด๋ฌ์คํฐ ์์ด์ ํธ
clusterAgent:
enabled: true
metricsProvider:
enabled: true # HPA ์ฐ๋
# Node Agent
agents:
rbac:
create: true
containers:
agent:
resources:
requests:
memory: "256Mi"
cpu: "200m"
# Flask ์ ํ๋ฆฌ์ผ์ด์
APM ์ฐ๋
from ddtrace import tracer, patch_all
# ์๋ ํจ์น
patch_all()
# ์ปค์คํ
์ค์
tracer.configure(
hostname='localhost',
port=8126,
service='my-flask-app',
env='production',
)
from flask import Flask
from datadog import statsd
app = Flask(__name__)
@app.route('/api/users/')
def get_user(user_id):
# ์ปค์คํ
์คํฌ ์ถ๊ฐ
with tracer.trace('database.query', service='postgresql') as span:
span.set_tag('user.id', user_id)
user = fetch_user_from_db(user_id)
# ์ปค์คํ
๋ฉํธ๋ฆญ ์ ์ก
statsd.increment('api.users.get', tags=['endpoint:get_user'])
return jsonify(user)
# DogStatsD ์ปค์คํ
๋ฉํธ๋ฆญ
from datadog import initialize, statsd
initialize(statsd_host='localhost', statsd_port=8125)
# ์นด์ดํฐ
statsd.increment('page.views', tags=['page:home'])
# ๊ฒ์ด์ง
statsd.gauge('queue.size', queue.size(), tags=['queue:orders'])
# ํ์คํ ๊ทธ๋จ
statsd.histogram('request.latency', response_time, tags=['endpoint:api'])
Datadog incurs costs based on the number of hosts, log volume, and number of custom metrics. Manage log indexing policies and metric cardinality carefully.
If an API key is exposed, malicious data transmission or billing issues can occur. Manage it securely through Secrets Manager.
The Datadog Agent uses a certain amount of CPU/memory. In resource-constrained environments, optimize the Agent configuration.
Using unique IDs (user ID, session ID) directly as tags causes metric cardinality to grow explosively. Use appropriate bucketing.