LoginSignup
0
1

More than 1 year has passed since last update.

Azure Monitorで使用されているKQLの書き方をちょっとだけ調べた

Last updated at Posted at 2021-08-22

業務でAzure Database for PostgreSQLのログを調査する機会が時々発生していたのですが、その際普通のSQLのようにあクエリを書こうと思ったものの、うまく動作せず、毎回Limitをかけたほぼ全文検索のような形で対応していて、「スマートじゃないなぁ....」っと思っていたので、脱出するべく調べたことを書き記したいと思います。

Azure Monitor使用されているクエリはKQL

Azure Database for PostgreSQLのAzure Monitor使用されているクエリはKQL(Kustoクエリ言語)というものが使われているようです
以下はサンプルクエリになります。
以下のコードを説明すると、AzureActivityテーブルのTimeGeneratedの日付が2020年10月01日以降かつ、TimeGeneratedが2020年10月07日以前のもかつ、LevelがCriticalに一致するレコードのみを表示するという文になります。


AzureActivity
| where TimeGenerated > datetime(10-01-2020) and TimeGenerated < datetime(10-07-2020)
| where Level == 'Critical'

参考資料
https://docs.microsoft.com/ja-jp/azure/azure-monitor/logs/log-query-overview
https://docs.microsoft.com/ja-jp/azure/data-explorer/kusto/query/samples?pivots=azuremonitor
https://docs.microsoft.com/ja-jp/azure/data-explorer/kusto/query/tutorial?pivots=azuremonitor

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1