- 필수 기능
- 시작하기
- Glossary
- 표준 속성
- Guides
- Agent
- 통합
- 개방형텔레메트리
- 개발자
- API
- Datadog Mobile App
- CoScreen
- Cloudcraft
- 앱 내
- 서비스 관리
- 인프라스트럭처
- 애플리케이션 성능
- APM
- Continuous Profiler
- 스팬 시각화
- 데이터 스트림 모니터링
- 데이터 작업 모니터링
- 디지털 경험
- 소프트웨어 제공
- 보안
- AI Observability
- 로그 관리
- 관리
Supported OS
OpenAI Dashboard Usage Trends
OpenAI Dashboard Samples
OpenAI Dashboard Tokens and Cost
Get cost estimation, prompt and completion sampling, error tracking, performance metrics, and more out of OpenAI account-level, Python, Node.js, and PHP library requests using Datadog metrics, APM, and logs.
Note: This setup method does not collect openai.api.usage.*
metrics. To collect these metrics, also follow the API key setup instructions.
Note: This setup method only collects openai.api.usage*
metrics, and if you enable OpenAI in Cloud Cost Management, you will also get cost metrics, no additional permissions or setup required. Use the agent setup below for additional metrics.
docker run -d
--cgroupns host \
--pid host \
-v /var/run/docker.sock:/var/run/docker.sock:ro \
-v /proc/:/host/proc/:ro \
-v /sys/fs/cgroup/:/host/sys/fs/cgroup:ro \
-e DD_API_KEY=<DATADOG_API_KEY> \
-p 127.0.0.1:8126:8126/tcp \
-p 127.0.0.1:8125:8125/udp \
-e DD_DOGSTATSD_NON_LOCAL_TRAFFIC=true \
-e DD_APM_ENABLED=true \
gcr.io/datadoghq/agent:latest
pip install ddtrace
ddtrace-run
and the following environment variables as shown below:DD_SERVICE="my-service" DD_ENV="staging" ddtrace-run python <your-app>.py
Notes:
DD_SITE
on the application command to the correct Datadog site parameter as specified in the table in the Datadog Site page (for example, datadoghq.eu
for EU1 customers).DD_AGENT_HOST
, DD_TRACE_AGENT_PORT
, or DD_DOGSTATSD_PORT
.See the APM Python library documentation for more advanced usage.
See the APM Python library documentation for all the available configuration options.
To enable log prompt and completion sampling, set the DD_OPENAI_LOGS_ENABLED="true"
environment variable. By default, 10% of traced requests will emit logs containing the prompts and completions.
To adjust the log sample rate, see the APM library documentation.
Note: Logs submission requires DD_API_KEY
to be specified when running ddtrace-run
.
Validate that the APM Python library can communicate with your Agent using:
ddtrace-run --info
You should see the following output:
Agent error: None
Pass the --debug
flag to ddtrace-run
to enable debug logging.
ddtrace-run --debug
This displays any errors sending data:
ERROR:ddtrace.internal.writer.writer:failed to send, dropping 1 traces to intake at http://localhost:8126/v0.5/traces after 3 retries ([Errno 61] Connection refused)
WARNING:ddtrace.vendor.dogstatsd:Error submitting packet: [Errno 61] Connection refused, dropping the packet and closing the socket
DEBUG:ddtrace.contrib.openai._logging.py:sent 2 logs to 'http-intake.logs.datadoghq.com'
Note: This setup method does not collect openai.api.usage.*
metrics. To collect these metrics, also follow the API key setup instructions.
docker run -d
--cgroupns host \
--pid host \
-v /var/run/docker.sock:/var/run/docker.sock:ro \
-v /proc/:/host/proc/:ro \
-v /sys/fs/cgroup/:/host/sys/fs/cgroup:ro \
-e DD_API_KEY=<DATADOG_API_KEY> \
-p 127.0.0.1:8126:8126/tcp \
-p 127.0.0.1:8125:8125/udp \
-e DD_DOGSTATSD_NON_LOCAL_TRAFFIC=true \
-e DD_APM_ENABLED=true \
gcr.io/datadoghq/agent:latest
npm install dd-trace
DD_TRACE_DEBUG=1 DD_TRACE_BEAUTIFUL_LOGS=1 DD_SERVICE="my-service" \
DD_ENV="staging" DD_API_KEY=<DATADOG_API_KEY> \
NODE_OPTIONS='-r dd-trace/init' node app.js
Note: If the Agent is using a non-default hostname or port, you must also set DD_AGENT_HOST
, DD_TRACE_AGENT_PORT
, or DD_DOGSTATSD_PORT
.
See the APM Node.js OpenAI documentation for more advanced usage.
See the APM Node.js library documentation for all the available configuration options.
To enable log prompt and completion sampling, set the DD_OPENAI_LOGS_ENABLED=1
environment variable. By default, 10% of traced requests emit logs containing the prompts and completions.
To adjust the log sample rate, see the APM library documentation.
Note: Logs submission requires DD_API_KEY
to be specified.
Validate that the APM Node.js library can communicate with your Agent by examining the debugging output from the application process. Within the section titled “Encoding payload,” you should see an entry with a name
field and a correlating value of openai.request
. See below for a truncated example of this output:
{
"name": "openai.request",
"resource": "listModels",
"meta": {
"component": "openai",
"span.kind": "client",
"openai.api_base": "https://api.openai.com/v1",
"openai.request.endpoint": "/v1/models",
"openai.request.method": "GET",
"language": "javascript"
},
"metrics": {
"openai.response.count": 106
},
"service": "my-service",
"type": "openai"
}
Note: To collect openai.api.usage.*
metrics, follow the API key setup instructions.
docker run -d
--cgroupns host \
--pid host \
-v /var/run/docker.sock:/var/run/docker.sock:ro \
-v /proc/:/host/proc/:ro \
-v /sys/fs/cgroup/:/host/sys/fs/cgroup:ro \
-e DD_API_KEY=<DATADOG_API_KEY> \
-p 127.0.0.1:8126:8126/tcp \
-p 127.0.0.1:8125:8125/udp \
-e DD_DOGSTATSD_NON_LOCAL_TRAFFIC=true \
-e DD_APM_ENABLED=true \
gcr.io/datadoghq/agent:latest
The library is automatically injected into your OpenAI PHP application.
Notes:
DD_SITE
on the application command to the correct Datadog site parameter as specified in the table in the Datadog Site page (for example, datadoghq.eu
for EU1 customers).DD_AGENT_HOST
, DD_TRACE_AGENT_PORT
, or DD_DOGSTATSD_PORT
.See the APM PHP library documentation for more advanced usage.
See the APM PHP library documentation for all the available configuration options.
To enable log prompt and completion sampling, set the DD_OPENAI_LOGS_ENABLED="true"
environment variable. By default, 10% of traced requests will emit logs containing the prompts and completions.
To adjust the log sample rate, see the APM library documentation.
Note: To ensure logs are correlated with traces, Datadog recommends you enable DD_LOGS_INJECTION
.
To validate that the APM PHP library can communicate with your Agent, examine the phpinfo output of your service. Under the ddtrace
section, Diagnostic checks
should be passed
.
Note: This setup method only collects openai.api.usage.*
metrics. To collect all metrics provided by this integration, also follow the APM setup instructions.
openai.api.usage.n_context_tokens_total (gauge) | Total number of context tokens used (all-time) Shown as token |
openai.api.usage.n_generated_tokens_total (gauge) | Total number of generated response tokens (all-time) Shown as token |
openai.api.usage.n_requests (count) | Total number of requests Shown as request |
openai.organization.ratelimit.requests.remaining (gauge) | Number of requests remaining in the rate limit. Shown as request |
openai.organization.ratelimit.tokens.remaining (gauge) | Number of tokens remaining in the rate limit. Shown as token |
openai.ratelimit.requests (gauge) | Number of requests in the rate limit. Shown as request |
openai.ratelimit.tokens (gauge) | Number of tokens in the rate limit. Shown as token |
openai.request.duration (gauge) | Request duration distribution. Shown as nanosecond |
openai.request.error (count) | Number of errors. Shown as error |
openai.tokens.completion (gauge) | Number of tokens used in the completion of a response from OpenAI. Shown as token |
openai.tokens.prompt (gauge) | Number of tokens used in the prompt of a request to OpenAI. Shown as token |
openai.tokens.total (gauge) | Total number of tokens used in a request to OpenAI. Shown as token |
The OpenAI integration does not include any events.
The OpenAI integration does not include any service checks.
Need help? Contact Datadog support.
Additional helpful documentation, links, and articles:
OpenAI Dashboard Usage Trends
OpenAI Dashboard Samples
OpenAI Dashboard Tokens and Cost