Collect metrics and traces from OpenAI services

Learn how to configure and activate the component for OpenAI services.

You can collect metrics and traces from OpenAI services by instrumenting your Python application using the Splunk Distribution of OpenTelemetry Python with the OpenTelemetry OpenAI instrumentation. The OpenAI instrumentation pushes metrics and traces to the OTLP receiver.

Complete the following steps to collect metrics and traces from OpenAI services.

  1. Deploy the Splunk Distribution of the OpenTelemetry Collector to your host or container platform:
  2. Start the Splunk Distribution of the OpenTelemetry Collector.
  3. Deploy the Python agent in your OpenAI service:
    1. Install the Splunk Distribution of OpenTelemetry Python using the guided setup or manual method.
    2. Install the Generative AI/LLM instrumentation by following the steps on OpenTelemetry OpenAI Instrumentation in the OpenTelemetry Python Contrib GitHub repository. You can use zero-code instrumentation or manual instrumentation.
  4. Run the service.

メトリクスと属性

OpenAI サービスで利用可能なモニタリングメトリクスを確認します。

OpenAI サービスでは以下のメトリクス、リソース属性が利用できます。詳しくは OpenTelemetry ドキュメントの「Metrics」をご確認ください。
メトリクス名ヒストグラム機能インストルメントタイプユニット(Units)説明リソース属性
gen_ai.client.token.usageinputヒストグラムcount処理済みの入力トークン数。
  • server.port
  • server.address
  • gen_ai.application_name
  • gen_ai.system
  • gen_ai.environment
  • gen_ai.operation.name
  • gen_ai.request.model
  • gen_ai.response.model error.type
gen_ai.client.token.usage出力 ヒストグラムcount処理済みの出力トークン数。
  • server.port
  • server.address
  • gen_ai.application_name
  • gen_ai.system
  • gen_ai.environment
  • gen_ai.operation.name
  • gen_ai.request.model
  • gen_ai.response.model
  • error.type
gen_ai.client.token.usagesumヒストグラムcount処理済みトークンの合計。
  • server.port
  • server.address
  • gen_ai.application_name
  • gen_ai.system
  • gen_ai.environment
  • gen_ai.operation.name
  • gen_ai.request.model
  • gen_ai.response.model
  • error.type
gen_ai.client.token.usage最大ヒストグラムcount処理済み合計トークンの最大数。
  • server.port
  • server.address
  • gen_ai.application_name
  • gen_ai.system
  • gen_ai.environment
  • gen_ai.operation.name
  • gen_ai.request.model
  • gen_ai.response.model
  • error.type
gen_ai.client.token.usageヒストグラムcount処理済み合計トークンの最小数。
  • server.port
  • server.address
  • gen_ai.application_name
  • gen_ai.system
  • gen_ai.environment
  • gen_ai.operation.name
  • gen_ai.request.model
  • gen_ai.response.model
  • error.type
gen_ai.client.operation.durationsumヒストグラムいる期間の合計。
  • server.port
  • server.address
  • gen_ai.application_name
  • gen_ai.system
  • gen_ai.environment
  • gen_ai.operation.name
  • gen_ai.request.model
  • gen_ai.response.model
  • error.type
gen_ai.client.operation.duration最大ヒストグラムいる最大期間。
  • server.port
  • server.address
  • gen_ai.application_name
  • gen_ai.system
  • gen_ai.environment
  • gen_ai.operation.name
  • gen_ai.request.model
  • gen_ai.response.model
  • error.type
gen_ai.client.operation.durationヒストグラムいる最小期間。
  • server.port
  • server.address
  • gen_ai.application_name
  • gen_ai.system
  • gen_ai.environment
  • gen_ai.operation.name
  • gen_ai.request.model
  • gen_ai.response.model
  • error.type
gen_ai.client.operation.durationcountヒストグラムcount期間のカウント。
  • server.port
  • server.address
  • gen_ai.application_name
  • gen_ai.system
  • gen_ai.environment
  • gen_ai.operation.name
  • gen_ai.request.model
  • gen_ai.response.model
  • error.type

Next steps

How to monitor your AI components after you set up Observability for AI.

After you set up data collection from supported AI components to Splunk Observability Cloud, the data populates built-in experiences that you can use to monitor and troubleshoot your AI components.

The following table describes the tools you can use to monitor and troubleshoot your AI components.
Monitoring toolUse this tool toLink to documentation
Built-in navigatorsOrient and explore different layers of your AI tech stack.
Built-in dashboardsAssess service, endpoint, and system health at a glance.
Splunk Application Performance Monitoring (APM) service map and trace viewView all of your LLM service dependency graphs and user interactions in the service map or trace view.

Splunk APM を使用して LLM サービスをモニタリングする