Azure Log Analytics Workspace
This page shows how to write Terraform and Azure Resource Manager for Log Analytics Workspace and write them securely.
azurerm_log_analytics_workspace (Terraform)
The Workspace in Log Analytics can be configured in Terraform with the resource name azurerm_log_analytics_workspace
. The following sections describe 9 examples of how to use the resource and its parameters.
Example Usage from GitHub
resource "azurerm_log_analytics_workspace" "panel" {
name = "panel-workspace"
location = var.resource_group_location
resource_group_name = var.resource_group_name
}
resource "azurerm_log_analytics_workspace" "example" {
name = var.workspace_name
location = var.location
resource_group_name = var.resource_group_name
sku = var.sku
retention_in_days = 30
resource "azurerm_log_analytics_workspace" "law" {
name = var.law_name
location = var.location
resource_group_name = var.resource_group_name
sku = "PerGB2018"
retention_in_days = 30
resource "azurerm_log_analytics_workspace" "loganal01" {
name = "loganal01"
location = azurerm_resource_group.dev-prolab-rg[0].location
resource_group_name = azurerm_resource_group.dev-prolab-rg[0].name
sku = "PerGB2018"
retention_in_days = 30
resource "azurerm_log_analytics_workspace" "workspace" {
name = var.loganalytics.name
location = var.location
resource_group_name = azurerm_resource_group.loganalytics.name
sku = "PerGB2018"
retention_in_days = 30
resource "azurerm_log_analytics_workspace" "log_analytics_workspace" {
name = var.log_analytics_name
location = var.location
resource_group_name = var.resource_group_name
sku = var.log_analytics_sku
retention_in_days = var.retention_in_days
resource "azurerm_log_analytics_workspace" "law_01" {
name = "aks-resources"
location = azurerm_resource_group.monitor.location
resource_group_name = azurerm_resource_group.monitor.name
sku = "Free"
}
resource "azurerm_log_analytics_workspace" "cluster" {
count = var.enable_log_analytics ? 1 : 0
name = var.cluster_name
location = var.location
resource_group_name = var.resource_group_name
sku = "PerGB2018"
resource "azurerm_log_analytics_workspace" "loganalytics_sandbox" {
name = "sandbox-la-1"
location = azurerm_resource_group.loganalytics_rg.location
resource_group_name = azurerm_resource_group.loganalytics_rg.name
sku = "PerGB2018"
retention_in_days = 30
Parameters
-
daily_quota_gb
optional - number -
id
optional computed - string -
internet_ingestion_enabled
optional - bool -
internet_query_enabled
optional - bool -
location
required - string -
name
required - string -
portal_url
optional computed - string -
primary_shared_key
optional computed - string -
reservation_capcity_in_gb_per_day
optional - number -
resource_group_name
required - string -
retention_in_days
optional computed - number -
secondary_shared_key
optional computed - string -
sku
optional - string -
tags
optional - map from string to string -
workspace_id
optional computed - string -
timeouts
single block
Explanation in Terraform Registry
Manages a Log Analytics (formally Operational Insights) Workspace.
Microsoft.OperationalInsights/workspaces (Azure Resource Manager)
The workspaces in Microsoft.OperationalInsights can be configured in Azure Resource Manager with the resource name Microsoft.OperationalInsights/workspaces
. The following sections describe how to use the resource and its parameters.
Example Usage from GitHub
{
"contentVersion": "1.0.0.0",
"parameters": {
"workbookDisplayName": {
"type": "string",
{
"contentVersion": "1.0.0.0",
"parameters": {
"workbookDisplayName": {
"type": "string",
{
"contentVersion": "1.0.0.0",
"parameters": {
"workbookDisplayName": {
"type": "string",
{
"contentVersion": "1.0.0.0",
"parameters": {
"workbookDisplayName": {
"type": "string",
{
"contentVersion": "1.0.0.0",
"parameters": {
"workbookSourceId": {
"type": "string",
{
"contentVersion": "1.0.0.0",
"parameters": {
"workbookDisplayName": {
"type": "string",
{
"contentVersion": "1.0.0.0",
"parameters": {
"workbookDisplayName": {
"type": "string",
{
"contentVersion": "1.0.0.0",
"parameters": {
"workbookDisplayName": {
"type": "string",
{
"contentVersion": "1.0.0.0",
"parameters": {
"workbookDisplayName": {
"type": "string",
{
"contentVersion": "1.0.0.0",
"parameters": {
"workbookDisplayName": {
"type": "string",
Parameters
apiVersion
required - stringeTag
optional - stringThe ETag of the workspace.
location
required - stringThe geo-location where the resource lives
name
required - stringThe name of the workspace.
properties
requiredfeatures
optionaladditionalProperties
optional - objectUnmatched properties from the message are deserialized this collection
clusterResourceId
optional - stringDedicated LA cluster resourceId that is linked to the workspaces.
disableLocalAuth
optional - booleanDisable Non-AAD based Auth.
enableDataExport
optional - booleanFlag that indicate if data should be exported.
enableLogAccessUsingOnlyResourcePermissions
optional - booleanFlag that indicate which permission to use - resource or workspace or both.
immediatePurgeDataOn30Days
optional - booleanFlag that describes if we want to remove the data after 30 days.
forceCmkForQuery
optional - booleanIndicates whether customer managed storage is mandatory for query management.
provisioningState
optional - stringThe provisioning state of the workspace.
publicNetworkAccessForIngestion
optional - stringThe network access type for accessing Log Analytics ingestion.
publicNetworkAccessForQuery
optional - stringThe network access type for accessing Log Analytics query.
retentionInDays
optional - integerThe workspace data retention in days. Allowed values are per pricing plan. See pricing tiers documentation for details.
sku
optionalcapacityReservationLevel
optional - integerThe capacity reservation level in GB for this workspace, when CapacityReservation sku is selected.
name
required - stringThe name of the SKU.
workspaceCapping
optionaldailyQuotaGb
optional - numberThe workspace daily quota for ingestion.
tags
optional - stringResource tags.
type
required - string
Frequently asked questions
What is Azure Log Analytics Workspace?
Azure Log Analytics Workspace is a resource for Log Analytics of Microsoft Azure. Settings can be wrote in Terraform.
Where can I find the example code for the Azure Log Analytics Workspace?
For Terraform, the kashw2/Fleet-of-the-Faithful-Knights, techbunny/hybrid-network-lab and aultt/Azure-Terraform-LabinaBox source code examples are useful. See the Terraform Example section for further details.
For Azure Resource Manager, the pkhabazi/sentineldevops, ObjectivityLtd/jmeter_simple_test and ObjectivityLtd/jmeter_simple_test source code examples are useful. See the Azure Resource Manager Example section for further details.