-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for configuring Tables (basic logs, retention time) in Log Analytics #15858
Comments
Like you mentioned, currently you can set retention per table with the Azure CLI.
|
Is there any update about this? |
I Achieved table creation using azapi provider. Sharing to help others. main.tf
versions.tf
partial vars.json
|
Based on @cgraf-spiria anwser. If you want to change it for all application insight tables and also support for resources in multiple subscriptions:
|
Just a question community folks. Has anyone tried updating the table plan to basic logs. I have been trying the following and keep getting the error from api. This is the list of tables and these are allowed to be modified as per azure documentation here log_analytics_workspace_tables_with_basic_logs = ["StorageBlobLogs", "StorageFileLogs", "StorageQueueLogs", "StorageTableLogs", "AKSAuditAdmin", "AKSControlPlane"]
|
I'm trying to use azapi provider to update AzureDiagnostics table, changing the properties retentionInDays and totalRetentionInDays, but I receive a Bad Request error `resource "azapi_update_resource" "table_retention" { body = jsonencode( │ RESPONSE 400: 400 Bad Request Using Azure CLI command I can set retention withuout problems. |
Seems like you are using new log ingestion API and you have not converted your tables or done migration. https://learn.microsoft.com/en-us/azure/azure-monitor/logs/custom-logs-migrate#migration-procedure I used the old datacollector api |
I think that this is due to how the azapi_update_resource works. Sending a PUT with the schema populated (even if the schema is unchanged) causes this kind of error. So by setting the schema property to null you will solve the issue and keep the schema unchanged. Example:
EDIT: Seems that this would alter the schema, need more investigation. |
Thank you @mgattei ! |
@mattedavi @mgattei i have tried that approach with azapi, however my terraform plan always shows that its going to change the schema, is it the same for you? |
@gcbikram did you found something I am getting the change in schema. |
Does the 'AzureDiagnostics' table exist in your Log Analytics Workspace? |
@mgattei yes 'AzureDiagnostics' table exist in my workspace, how did you solve yours? |
I just tried running a new plan on the sample used before and noticed that the behavior is the same as yours. I need to investigate it more.. |
Hi everyone, Did you successfully to find a solution ? I've got the same error as you, schema of the table is altered.. 😔 |
The functionality requested in the original request is becoming more important due to #23051 |
Yes please, since the issue with the retention policy in diagnostic settings seems to not only be deprecated for storage accounts, but also for log analytics workspaces. |
I use azapi v.1.9.0 and azurerm v.3.42.0. After series of experiments, I ended with the following solution:
|
Any news on this? |
Just for reference: I could not get the workarounds based on the |
Hi all, I'd like to share another workaround by data "azapi_resource_id" "table" {
type = "Microsoft.OperationalInsights/workspaces/tables@2022-10-01"
name = "StorageBlobLogs"
parent_id = azurerm_log_analytics_workspace.main_log.id
}
resource "azapi_resource_action" "log_analytics_workspace_audit_table" {
type = "Microsoft.OperationalInsights/workspaces/tables@2022-10-01"
resource_id = data.azapi_resource_id.table.id
method = "PUT"
// the PUT request body only contains the content in the config, and there'll be no plan-diff for the action resource.
body = jsonencode({
properties = {
schema = null
retentionInDays = 730
totalRetentionInDays = 1826
}
})
} But above config won't monitor the |
Using this initial method, I am trying to update the retention but being faced with, "A resource with the ID "/subscriptions/XXX/... already exists - to be managed via Terraform this resource needs to be imported into the State. Please see the resource documentation for "azapi_resource" for more information. in order to import the tables into state file, I have hundreds of tables across many tenants. Is there a better way to support this, or any advancements on official documents for this please? |
I think this should be closed as addressed by this other ticket: #6199 |
Close this issue for, as vanny96 suggested, the expected resource has been supported in AzureRM provider. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Community Note
Description
Basic logs is now in preview and supports greatly reduced ingest cost for things like raw container output which doesn't need to be frequently queried.
Azure CLI also shows there is a retention time setting you can manage
Details
New or Affected Resource(s)
Potential Terraform Configuration
References
The text was updated successfully, but these errors were encountered: