Monitor OpenAI APIs
AppDynamics Python Agent helps you monitor the OpenAI and Azure OpenAI usage and related metrics. It monitors the ChatCompletion, Completion, Moderation, and Embeddings API type requests created using the openai-python library to the OpenAI backend. The agent also captures the prompts and responses used by the OpenAI API models.
The following metrics are reported at the application, tier, and node levels:
- Calls per minute
- Errors per minute
- Tokens
- Input Tokens
- Completion Tokens
The following are the example metric paths:
- Per model metric path -
Application Infrastructure Performance|OpenAI_Tier|Agent|OpenAI|ada|Tokens - All model cumulative metrics path -
Application Infrastructure Performance|Agent|OpenAI_Tier|OpenAI|Tokens - All Models - Net application level metrics path -
Overall Application Summary|Agent|OpenAI - Tokens - ada
OpenAI Moderation API
From version 24.2.0, Python Agent supports OpenAI Moderation API. The moderation API will prompt the users if the queried statement is policy compliant or not. The Python Agent captures the following metrics:
- Calls to moderations API: The number of times moderation API is used every minute. (
OpenAI|moderations|Calls per minute) - Flagged category metrics: The number of times specific types of content, like hate speech, are flagged. (
OpenAI|moderations|Flagged Calls by category|hate) - Flagged queries count: The total amount of flagged content. (
OpenAI|moderations|Flagged queries) - Total queries count: The overall number of queries processed. (
OpenAI|moderations|Total queries)
前提条件
AppDynamics を使用して OpenAI API exit コールをモニターするには、次の前提条件を満たしていることを確認します。
- Python エージェント 23.8.0 以降をインストールします。Pythonエージェントのインストール を参照してください。
- カスタムダッシュボードおよびテンプレートをインポートします。
- Python エージェントの ファイルで
enable-openaiフラグを必ず/path/to/appdynamics.cfgに設定してください。[instrumentation]を参照してください。 - スナップショット exit コールの詳細で OpenAI 要求および応答をキャプチャするには、Python エージェントの
/path/to/appdynamics.cfgファイルでenable-genai-data-captureフラグを true に設定します。「[instrumentation]」を参照してください。
Create a Custom Dashboard
Example Dashboard
カスタムコストメトリック式の作成
入力トークンメトリックと完了トークンメトリックにそれぞれのコストを乗算することで、カスタムコストメトリック式を作成できます。
たとえば、gpt-3.5-turbo-0125 の 100 万トークンあたりのコストは次のとおりです。
- 入力トークン = 0.5$
- 完了トークン = 1.5$
gpt-3.5-turbo-0125 のカスタム式を作成して、次のようにコストを計算できます。({input Tokens}*0.5 + {Completion Tokens}*1.5)/1000000このカスタム式を使用して、さまざまなモデル間のコスト分散の円グラフ、またはすべてのモデルのコスト関数を含む総コストウィジェットを作成します。次の手順を実行して、既存の OpenAI ダッシュボードにモデルごとのコストウィジェットを作成します。
このメトリック式には、両方のタイプに対する 100 万トークンあたりのコスト乗数が含まれます。