You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

隔离式Azure Function应用发布触发服务器错误警报,如何获取对应指标日志

排查隔离式Azure Function服务器错误指标日志的方法
  • 检查Application Insights的requests表
    服务器错误(多为5xx状态码)会记录在requests表中,筛选success为false或resultCode以5开头的条目,就能定位对应警报的请求。用Kusto查询快速筛选:

    requests
    | where success == false
    | where resultCode startswith "5"
    | order by timestamp desc
    

    这里能看到请求的响应状态、持续时间、操作名称等关键信息,对应发布时的异常请求。

  • 查看performanceCounters表
    隔离式函数的服务器错误可能和宿主资源瓶颈有关,比如内存不足、CPU过载。查询性能计数器数据:

    performanceCounters
    | where name in ("% Processor Time", "Available Bytes", "Private Bytes")
    | order by timestamp desc
    

    对比警报触发时间点的性能数据,判断是否是资源问题导致的错误。

  • 启用Azure Function宿主日志
    隔离式函数的宿主日志默认可能未开启,先确保函数应用已配置APPINSIGHTS_INSTRUMENTATIONKEY,再开启宿主日志:
    在Azure门户的函数应用→监控→日志→日志查询界面,切换到AppServiceConsole,执行命令:

    az functionapp config appsettings set --name <你的函数名> --resource-group <资源组名> --settings "FUNCTIONS_LOGGING_LEVEL=Information"
    

    之后宿主的启动、发布相关日志会被收集到traces表,筛选logger为Host.Triggers.*或Host.Startup的条目即可查看。

  • 检查Azure资源日志
    启用函数应用的平台级资源日志:
    在Azure门户→函数应用→监控→诊断设置→添加诊断设置,勾选AppServicePlatformLogs并发送到Application Insights。这些日志会进入AppServicePlatformLogs表,包含发布时的部署错误、进程启动失败等平台级问题。

  • 关联警报时间点的全量日志
    聚焦警报触发的时间窗口(比如前后5分钟),用Kusto查询关联所有相关表,全面排查:

    let alertTime = datetime(2024-05-20T12:00:00Z); // 替换为你的警报触发时间
    union requests, traces, exceptions, performanceCounters, AppServicePlatformLogs
    | where timestamp between (alertTime - 5m .. alertTime + 5m)
    | order by timestamp desc
    

内容的提问来源于stack exchange,提问作者DxG

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.31 20:25:15