[DAY29] 用 Application Insights 来监视部署的模型

DAY29 用 Application Insights 来监视部署的模型

我们已经把大部份的 Azure Machine Learning SDK 讲完了,我们先来讲怎麽来监控我们的部署吧!模型在部署上去之後,我们要持续监控这个服务的状况。在微软 Azure 上提供的解决方案是 Application Insights。Application Insights 是一款 APM(Application Performance Management),可以来监控应用程序的效能,并且提供分析工具。一般我们在 Web 服务上,都会安装这类的 APM 工具。

启用 Application Insights

还记得我们在第 8 天,第一次谈部署时,有个选项要叫大家勾起来吗?下面这张图片,我们当时请大家点开 Advance,然後把那个 Enable Application Insights 选项给勾起来。如果有勾起来,就有安装成功 Application Insights 罗!

Deploy Model with Design in Azure machine learning

  1. 确认是否有启用 Application Insights,可以参考下面程序码:
from azureml.core import Workspace

ws = Workspace.from_config()
ws.get_details()['applicationInsights']

如果有印出像下图一样的资讯,就是有安装成功了。
monitor in Azure machine learning

  1. 如果已经建好的服务,要启用 Application Insights 的话,可以用 SDK 这样子启用。
from azureml.core import Workspace
from azureml.core.webservice import Webservice

ws = Workspace.from_config()
aks_service= Webservice(ws, "titanic") # 你的 service 的名称
aks_service.update(enable_app_insights=True)
  1. 接着我们可以去以前在 AutoML 建立的 Endpoints 里,进到 Test 分页,来直接打几笔资料。
    Deploy AutoML in Azure machine learning

  2. 接着我们进到刚刚建立的 Application Insights 资源里,在 Overview 的页面,就可以看到我们刚刚打的纪录呢!可以参考下图。
    monitor in Azure machine learning

  3. 接首我们来发几笔有问题的资料,故意让程序出错。再进到 Application Insights 的页面里,可以看到在 Failed requests 的 panel,看到好几笔错误讯息了。
    monitor in Azure machine learning

  4. 我们可以点进去 Failed requests 的 panel 里,可以更进一步看错误的资讯是什麽。
    monitor in Azure machine learning

客制化 Application Insights 资讯

  1. 当然纪录的资讯也是可以客制化的,不过我们就要自己写在 score.py 里面了。忘记这是什麽东西的话可以去参考 DAY25 的内容。我们只要简单使用 print() 加上要纪录下来的内容就可以罗!我这里就把 DAY25 的score.py,单纯 print 出模型的路径。

  2. 接着我们再回到 Application Insights 里,在 Blade 选单里,找到 Logs。这个是我们可以用类似 SQL 的语法查询 Log 的地方。我们输入下面的语句来搜寻。

traces
|where message == "STDOUT" // print 的资料会出现在 STDOUT
  and customDimensions.["Service Name"] == "mnist-classification-insight" //这里放这个 web service 的名称
| project  timestamp, customDimensions.Content // 出现时间和印出来的内容
  1. 搜寻到的结果会如下图。我们可以看到模型的路径就被纪录起来罗!
    monitor in Azure machine learning

今天我们就学完监控部署模型的操作啦!需注意在实务上,我们在score.py里会纪录更多的东西,例如该次 inference 的 confidence 等等的资料哦!明天最後一天,我们就来谈 MLOps 吧!


<<:  Day30:今天来聊一下CEH中讲的Mail Cryptography

>>:  [DAY-30 ] 再怎样潇洒总要有个结尾,你也知道潇洒美少男没有甩头的结尾是行不通的。

[第十天]从0开始的UnityAR手机游戏开发-Vuforia多张图卡辨识

到Vuforia官网点击Develop→Target Manager→Add Target 新增其他...

【课程推荐】2021/3/6~3/7、3/13~3/14 软件架构师技能培训班

课程目标 了解软件架构师所应具备的技能与素养,分析与规划软件架构模型,撰写符合国际标准的SAD (S...

[Day17]Love Calculator

上一篇介绍了Basically Speaking,这题有用到比较常见的写法,Integer.pars...

【Day8】:ADC电压采集

类比输入 自然界当中的讯号几乎为连续的,也就是我们常说的类比讯号,而对於单晶片或着电脑来说,我们能够...

TailwindCSS 从零开始 - 增加 Base 样式

什麽是 Base 样式 概念有点像是 CSSreset,现在网页基本上都会使用 CSS reset...