All Products
Search
Document Center

Application Real-Time Monitoring Service:Batch enable monitoring for dify LLM applications

Last Updated:Sep 21, 2026

The Dify console lets you configure monitoring for individual applications and integrate them with Cloud Monitor for observability, but does not support batch configuration. You can call APIs to batch-configure Alibaba Cloud observability monitoring for Dify applications.

Background

The process simulates Dify console operations through HTTP APIs to batch-configure monitoring:

  1. Obtain logon status: Call the logon API to obtain an authentication token.

  2. Retrieve the application list: Get information about all applications under the tenant.

  3. Check the application monitoring configuration: Query the current monitoring configuration status of an application.

  4. Configure Alibaba Cloud monitoring: Create an Alibaba Cloud observability configuration for an application.

  5. Enable the monitoring switch: Turn on application monitoring.

If you deploy Dify from source code, you can also implement batch configuration by following the process above and using the O&M commands in Dify's ext_commands.py file with Click Command.

API batch configuration flow

Step 1: Log on and authenticate

Call the Dify logon API to authenticate and obtain the tenant's logon token.

API: POST {base_url}/console/api/login

Request parameters

{
  "email": "your_account@example.com",
  "password": "your_password",
  "remember_me": false
}

Response

{
  "result": "success"
}
Set-Cookie: access_token=<JWT>; HttpOnly; Max-Age=3600
Set-Cookie: refresh_token=<random>; HttpOnly; Max-Age=2592000
Set-Cookie: csrf_token=<JWT>; Max-Age=3600

Key information in the response

Cookie

Purpose

access_token

API authentication credential

refresh_token

Credential to renew the access_token

csrf_token

Cross-Site Request Forgery (CSRF) credential

Subsequent requests

In the request header, set:

Cookie: access_token=xxx; refresh_token=xxx; csrf_token=xxx
X-CSRF-Token: <csrf_token>
Note

If you use a library that has session features, the library usually manages cookies automatically. In this case, you only need to add X-CSRF-Token to the header.

Step 2: Get the application list

Retrieve all applications under the current tenant.

API: GET {base_url}/console/api/apps

Request parameters

Parameter

Type

Default value

Description

page

int

1

Page number, starting from 1.

limit

int

20

Number of items per page. Valid values: 1 to 100.

mode

string

"all"

Filter by application type.

name

string

-

Search by application name.

Paging instructions:

  • Use the returned has_more field to determine whether a next page exists.

  • To retrieve all applications, loop the requests until the has_more field in the response is false.

Response

{
  "page": 1,
  "limit": 20,
  "total": 100,
  "has_more": true,
  "data": [
    {
      "id": "app-uuid",
      "name": "Application Name",
      "mode": "workflow",
      "description": "Application Description",
      "icon": "",
      "icon_type": "emoji",
      "created_at": 1234567890,
      "updated_at": 1234567890,
      "model_config": { /* Model Configuration */ },
      "workflow": { /* workflow configuration */ },
      "tags": []
    }
  ]
}

Key field descriptions:

  • id: The application ID, required for subsequent monitoring configuration steps.

  • name: The application name, required for the app_name parameter when configuring monitoring.

Step 3: Check the application monitoring configuration

Query the current monitoring configuration status of an application. Proceed to the next steps only if monitoring is not yet configured.

API: GET {base_url}/console/api/apps/{app_id}/trace

Request parameters

Response

{
  "enabled": false,
  "tracing_provider": null
}
{
  "enabled": true,
  "tracing_provider": "aliyun"
}

Field descriptions:

  • enabled: Indicates whether monitoring is enabled (boolean).

  • tracing_provider: The name of the monitoring provider (string).

Step 4: Configure Alibaba Cloud monitoring

Create an Alibaba Cloud observability monitoring configuration for an application.

API: POST {base_url}/console/api/apps/{app_id}/trace-config

Request parameters

{
  "tracing_provider": "aliyun",
  "tracing_config": {
    "app_name": "xxx",
    "license_key": "your_aliyun_license_key",
    "endpoint": "http://tracing-analysis-dc-bj.aliyuncs.com"
  }
}

Field descriptions

Field

Description

tracing_provider

Fixed as "aliyun"

tracing_config.app_name

The Alibaba Cloud application name. Each application must have a unique name; identical names are treated as the same observability application. Use the format Dify workspace name-Dify application name.

tracing_config.license_key

The Alibaba Cloud License Key. For more information, see DescribeTraceLicenseKey - List LicenseKey.

tracing_config.endpoint

The Alibaba Cloud reporting endpoint. For more information, see Endpoints.

Response

{
  "result": "success"
}
Note

In some Dify versions, monitoring metrics in the console may appear abnormal if you create a configuration without enabling it. The metrics return to normal after you enable the monitoring switch.

Step 5: Enable the monitoring switch

After you configure monitoring, enable the monitoring switch for the settings to take effect.

API: POST {base_url}/console/api/apps/{app_id}/trace

Request parameters

{
  "enabled": true,
  "tracing_provider": "aliyun"
}

Field

Type

Description

enabled

boolean

Whether to enable monitoring (true/false).

tracing_provider

string

The name of the monitoring provider (aliyun).

Response

{
  "result": "success"
}