Azure CLIでLogAnalyticsを作成してみた

Azure AzureMonitor

Log AnalyticsをAzure CLIで作成してみました。

広告

ログアナリティクスを作成する

LogAnayticsを作成するにあたり、リソースグループの作成が必要なのでそれも合わせて作成します。

 #任意のパラメータを定義
$rg_name = "RG-test-la"
$location = "japaneast"
$la_name = "Test-la"
$retention_time = 60

 #リソースグループ作成
az group create `
 --name $rg_name `
 --location $location

 #ログアナリティクス作成
az monitor log-analytics workspace create `
 --name $la_name `
 --resource-group $rg_name `
 --location $location `
 --retention-time $retention_time

今回はワークスペース データの保持期間はデフォルトの30日ではなく、60日を指定しています。

広告

作成後の確認

AzureCLIで確認します。

az monitor log-analytics workspace show -g $rg_name -n $la_name

・実行結果

PS C:\> az monitor log-analytics workspace show -g $rg_name -n $la_name
{
  "createdDate": "2023-02-27T04:24:26.2995166Z",
  "customerId": "xxxxxxxx-0b1b-4f7c-b4bc-xxxxxxxxadf1",
  "features": {
    "enableLogAccessUsingOnlyResourcePermissions": true
  },
  "id": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/RG-test-la/providers/Microsoft.OperationalInsights/workspaces/Test-la",
  "location": "japaneast",
  "modifiedDate": "2023-02-27T04:24:26.2995166Z",
  "name": "Test-la",
  "provisioningState": "Succeeded",
  "publicNetworkAccessForIngestion": "Enabled",
  "publicNetworkAccessForQuery": "Enabled",
  "resourceGroup": "RG-test-la",
  "retentionInDays": 60,
  "sku": {
    "lastSkuUpdate": "2023-02-27T04:24:26.2995166Z",
    "name": "PerGB2018"
  },
  "type": "Microsoft.OperationalInsights/workspaces",
  "workspaceCapping": {
    "dailyQuotaGb": -1.0,
    "dataIngestionStatus": "RespectQuota",
    "quotaNextResetTime": "2023-02-27T10:00:00Z"
  }
}
PS C:\>

[retentionInDays] が 60 となっていることも確認できます。

次にAzureポータルでも確認してみます。
作成したログアナリティクスから、[使用量と推定コスト] → [データ保有期間] をクリックするとデータの保持期間を確認できます。

Azureポータル上で作成したログアナリティクスを確認

こちらでも 60日 となっていることが確認できます。

コメント

タイトルとURLをコピーしました