主要内容

本页采用了机器翻译。点击此处可查看英文原文。

MATLAB Web App Server 捕获可观测性度量

您可以从MATLAB® Web App Server™捕获、查看和导出可观测性度量。这些度量可以提供有关服务器状态、应用程序性能、历史使用情况和工作单元可用性的见解。

遥测数据可以使用 OTLP 导出,并与 Prometheus® 或 Grafana® 等监控工具集成,以进行实时可视化和分析。

可观测性度量

如果在服务器上启用度量捕获功能,则会记录以下度量:

度量描述类型标签
matlabwebappserver_app_launched_total

已启动的 Web App 总数

计数器

  • user

  • appName

matlabwebappserver_app_launched_succeed_total

成功启动的 Web App 总数

计数器

  • user

  • appName

matlabwebappserver_idle_sessions

服务器实例上可用的预热工作单元总数

仪表

  • type

matlabwebappserver_sessions_in_use

分配给服务器实例上 Web App 的工作单元数

仪表

  • type

matlabwebappserver_app_start_duration_seconds

启动 Web App 所用的秒数

直方图

  • appName

matlabwebappserver_authentication_failed_total

失败的身份验证请求总数

计数器

  • user

启用度量捕获

默认情况下,MATLAB Web App Server 不捕获任何度量。使用 webapps-config 系统命令设置以下键,启用度量捕获:

  • metrics_type

    • off(默认):不捕获度量。

    • debug:将度量输出到命令控制台窗口。

    • otlp:使用 OpenTelemetry 协议将度量导出到 OTLP HTTP 端点(例如 Grafana)。此选项需要指定目标端点。

  • metrics_destination

    • 度量接收器的 HTTP 端点 URL。只有当度量类型配置为 otlp,才需要此参数。

例如,启用 OTLP 输出到 HTTP 端点 https://opentelemetry-collector.observability.svc.cluster.local:4318/v1/metrics

webapps-config metrics_type otlp
webapps-config metrics_destination "https://opentelemetry-collector.observability.svc.cluster.local:4318/v1/metrics"

查看度量数据

您可以在控制台窗口中查看遥测数据,或使用 OTLP 端点将其导出到数据仪表板。

在控制台中查看度量

如果将度量类型配置为 debug,度量将显示在服务器控制台窗口中。

以下是控制台中显示的会话度量示例。

{
  scope name    : mw_webappserver
  schema url    :
  version       :
  start time    : 10/7/2025 7:24:01 PM
  end time      : 10/7/2025 7:24:31 PM
  instrument name       : matlabwebappserver_sessions_in_use
  description   : Current Active Sessions
  unit          :
  type     : LastValuePointData
  timestamp     : 1759865071308301700
  valid     : true
  value     : 0
  attributes            :
  resources     :
        service.name: MATLAB WebApp Server
        telemetry.sdk.language: cpp
        telemetry.sdk.name: opentelemetry
        telemetry.sdk.version: 1.19.0
  start time    : 10/7/2025 7:24:01 PM
  end time      : 10/7/2025 7:24:31 PM
  instrument name       : matlabwebappserver_idle_sessions
  description   : Current Prewarmed Idle Sessions
  unit          :
  type     : LastValuePointData
  timestamp     : 1759865071308294900
  valid     : true
  value     : 11
  attributes            :
  resources     :
        service.name: MATLAB WebApp Server
        telemetry.sdk.language: cpp
        telemetry.sdk.name: opentelemetry
        telemetry.sdk.version: 1.19.0
}

将度量数据导出到仪表板

您可以将遥测数据导出到 Grafana 等数据仪表板,以设置警报和分析趋势。要导出数据,请确保您的服务已配置 OTLP 端点以接收遥测数据。

如果将度量类型配置为 otlp 并指定目标 OTLP 端点,MATLAB Web App Server会将度量导出到提供的端点。接收到的数据整合完成后,您的仪表盘将显示来自服务器的实时度量。

下面是一个 Grafana 面板可视化服务器度量示例。

A Grafana metrics dashboard displaying telemetry data.

另请参阅

主题