我浏览了Azure门户并搜索了网络,但我一直无法找到答案。有没有办法(也许通过 api 或 powershell)来获取 webjobs 的指标?例如每个工作的平均运行时间?我还想找出网络作业触发的消息的平均排队时间(尽管这可能是存储指标而不是网络作业指标)。任何指示将不胜感激。
最佳答案
正如 Igorek 所说,我认为这也是不可能的。有很多工具可以监控应用程序。其中两个具有 Azure 集成:
我已使用 Application Insights 从 Web 作业发送指标。您可以按照本教程在您的网络作业中设置应用程序洞察:
如果你想计算处理队列中消息的时间,你可以这样做:
public async Task ProcessAsync([ServiceBusTrigger("queueName")] BrokeredMessage incommingMessage)
{
var stopwatch = Stopwatch.StartNew();
// Process your message
...
stopwatch.Stop();
// You should only instantiate the TelemetryClient once in your application.
var telemetryClient = new TelemetryClient() { InstrumentationKey = "MyInstrumentationKey"};
//Send your metric
telemetryClient.TrackMetric("ProcessQueueMessageElapsedTime", stopwatch.ElapsedMilliseconds);
}
关于Azure WebJobs 和队列相关指标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36140174/