Web Apps のログ監視について
覚書 (=カスみたいな文章)
Application Insight に出力したログでエラーとか Exception が発生した時にメール通知とかできるようにするやつ。 Application Insight の 「アラート」を使用する。
Trace ログとかは、Severity Level でログレベルが出ているので、以下のような感じで検索クエリを書いてあげれば良い。
union (traces), (requests), (customEvents), (exceptions) | where ((itemType == 'trace' or (itemType == 'request' or (itemType == 'customEvent' or (itemType == 'exception' )))) and severityLevel == 2)
条件の書き方がわからない場合は、「メトリックスエクスプローラ」でログを検索して、 「分析」を押せばそれっぽい感じで確認できるので、あとは要らない部分を削除するなりなんなりする。
SeverityLevel については、 SeverityLevel Enum (Microsoft.ApplicationInsights.DataContracts) | Microsoft Docs を確認すれば、値がわかる。