This document contains references to the OpenAIĀ® documentation. AppDynamics does not own any rights and assumes no responsibility for the accuracy or completeness of such third-party documentation.


AppDynamics Java Agent helps you monitor the OpenAI API usage and related metrics. It monitors the Completion, ChatCompletion and Moderation APIs called using the TheoKanning OpenAI Java framework to the OpenAI backend.

The following metrics are reported at the application, tier, and node levels:

  • Calls per minute
  • Cost
  • Errors per minute
  • Tokens

The following are the example metric paths:

  • Per model metric path - Application Infrastructure Performance|OpenAI_Tier|OpenAI|ada|Cost
  • All model cumulative metrics path - Application Infrastructure Performance|OpenAI_Tier|OpenAI|Cost - All Models
  • Net application level metrics path - Overall Application Summary|OpenAI - Cost - ada


These metrics are reported even if the exit call is outside the business transaction. However, the Average Response Time(ms) metric is not reported when the exit call is outside the business transaction.

OpenAI Moderation API

From version 24.1.0, Java Agent supports OpenAI Moderation API. The moderation API will prompt the users if the queried statement is policy compliant or not. The Java Agent captures the following metrics:

  • Calls to moderations API: OpenAI|moderations|Calls per minute
  • Flagged category metrics: OpenAI|moderations|Flagged Calls by category|hate
  • Flagged queries count: OpenAI|moderations|Flagged queries
  • Total queries count: OpenAI|moderations|Total queries

Prerequisites

Ensure that you meet the following prerequisites to monitor the OpenAI API exit calls with AppDynamics:

Create a Custom Dashboard

  1. Download Custom_dashboard_script_v24.1.zip. It contains:

    DirectoryDescription
    templatesContains json templates to create the dashboard files.
    dashboardDashboard json files are created here. It contains the sample json files.
    main.pyPython script to create the dashboards.
    readme.mdDescription of the solution.


  2. Run the following command:

    cd Custom_dashboard_script
    python3 main.py
    CODE

    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 details.

    VariableDescriptionDefaultPossible ValuesRequired
    Dashboard NameThe dashboard name to be displayed on Dashboard & Reports in the Controller UI.
    OpenAI_App_dashboard
    app_dashboardOptional
    Application NameName of the Application with OpenAI backend calls.noneopenai_app_1Yes
    OpenAI Endpoints Host NameThe hostname of the OpenAI endpoint.
    api.openai.com
    api.openai.com
    Optional
    OpenAI Endpoints PortThe port of the OpenAI endpoint.443443Optional
    VariableDescriptionDefaultPossible ValuesRequired
    Dashboard NameThe dashboard name to be displayed on Dashboard & Reports in the Controller UI.tier_dashboardtier_dashboardOptional
    Application NameName of the Application with OpenAI backend calls.noneopenai_app_1Yes
    Tier NameName of the Tier exposed to OpenAI backend calls.noneopenai_tier_1Yes
    Business Transaction NameThe name of the business transaction reported to the host. This is to capture API Response time metric.noneopenai_btYes
    OpenAI Endpoints Host NameThe hostname of the OpenAI endpoint.
    api.openai.com
    api.openai.com
    Optional
    OpenAI Endpoints PortThe port of the OpenAI endpoint.443443Optional
    VariableDescriptionDefaultPossible ValuesRequired
    Dashboard NameThe dashboard name to be displayed on Dashboard & Reports in the Controller UI.
    OpenAI_Moderation_App
    moderation_app_dashboardOptional
    Application NameName of the Application with OpenAI backend calls.noneopenai_app_1Yes
    VariableDescriptionDefaultPossible ValuesRequired
    Dashboard NameThe dashboard name to be displayed on Dashboard & Reports in the Controller UI.
    OpenAI_Moderation_Tier
    moderation_tier_dashboard
    Optional
    Application NameName of the Application with OpenAI backend calls.noneopenai_app_1Yes
    Tier NameName of the Tier exposed to OpenAI backend calls.noneopenai_tier_1Yes


  4. Import the dashboard in the Controller UI. See Create and Manage Custom Dashboards and Templates.