LangChain アプリケーションの監視

Splunk AppDynamics Python エージェントは、LangChain フレームワークを使用して構築された GenAI アプリケーションをモニターするのに役立ちます。Python エージェントでアプリケーションをインストゥルメント化すると、ベクトルストアの次のメトリックがキャプチャされます。

  • ベクトルデータベース(pgvector および chroma)へのコールを終了します。
  • exit コールでのプロンプトと応答。
  • 取得されたドキュメントの数、類似性検索スコア、ベクトルデータベースのエラー
  • 1分あたりのコール数

LangChain を使用して Ollama などの LLM をモニターするために、Python エージェントは次のメトリックを記録します。

  • トークン
  • プロンプト数
  • 組み込みクエリ数

前提条件

Python エージェントの /path/to/appdynamics.cfg ファイルで enable-langchain フラグを必ず true に設定してください。[instrumentation] を参照してください。

Python エージェントは、Splunk AppDynamics で次のバージョンの LangChain LLM をサポートします。

コンポーネント Version
langchain 0.2.11 以前
langchain-ollama 0.2.0 以前
langchain-chroma 0.1.1!
langchain-postgres 0.0.12
chromadb 0.5.20 以前
pgvector 0.2.5

LangChain Ollama API のモニタリング

Ollama コールをモニターするために、Python エージェントは次のメトリックをレポートします。

  • 入力トークン = 0.5$
  • 出力トークン
  • 最初のトークンメトリックまでの時間(ミリ秒)
  • 出力トークンあたりの時間(ミリ秒)
  • 平均応答時間(ms)
  • プロンプト数
  • 組み込みクエリ数
  • エラー
注:

トークンメトリックを取得するには、transformers Python ライブラリをインストールしてください。「Transformers」を参照してください。

CODE
pip install transformers

メトリックパスの例Agent|Langchain|LLM|llama3.2_latest|Average Response Time (ms))

Create a Custom Dashboard to Monitor Ollama APIs

  1. Download Custom_dashboard_script.zip It contains:
    Directory Description
    templates Contains json templates to create the dashboard files.
    dashboard Dashboard json files are created here. It contains the sample json files.
    main.py Python script to create the dashboards.
    readme.md Description of the solution.
  2. Run the following command:
    CODE
    cd Custom_dashboard_script
    python3 main.py

    The preceding command prompts you to specify the dashboard type (application or tier) that you want to create.

  3. Based on your selected dashboard type, you will be prompted to specify the following dashboard detail.
  4. Import the dashboard in the Controller UI. See カスタムダッシュボードおよびテンプレートの作成と管理
    ヒント: Navigate to Tiers & Nodes > My Dashboards and create a dashboard for the selected application by copying and pasting widgets from the existing dashboard for easier navigation.
Example DashboardCustom Dashboard to Monitor Ollama APIs

LangChain ベクトルストアのモニタリング

Python エージェントでアプリケーションをインストゥルメント化すると、ベクトルストアの次のメトリックがキャプチャされます。

  • langchain_community および langchain_{vendor} ベクトルストアの場合、Python エージェントでは次のメトリックがキャプチャされます。
    • 検索スコア
    • 平均応答時間(ms)
    • エラー
    • コール
    • ベクトル挿入数
    • ベクトル削除数
    注:

    デフォルトでは、Splunk AppDynamics SaaS langchain_{vendor} ベクトルストアの次のメトリックをキャプチャします。

    • langchain_milvus
    • langchain_chroma
    • langchain_postgres

    ただし、 langchain-vectorstores-instrumented-modules フラグを設定して、 /path/to/appdynamics.cfg の特定の LangChain ベンダーからメトリックをキャプチャすることができます。詳細については、「インストゥルメンテーション」を参照してください。

  • ベクトルデータベース(pgvector および chroma)へのコールを終了します。

スナップショット exit コールの詳細で、PGVector およびChroma ベクトルストアの要求と応答をキャプチャするには、Python エージェントの /path/to/appdynamics.cfg ファイルで enable-genai-data-capture フラグを true に設定します。「[instrumentation]」を参照してください。