Skip to content

Commit

Permalink
feat: Add UDT to avm/res/operational-insights/workspace (Azure#3774)
Browse files Browse the repository at this point in the history
## Description

Add User Defined Types to the Log Analytics Workspace module.
Also fixes Azure#3798 

## Pipeline Reference

<!-- Insert your Pipeline Status Badge below -->

| Pipeline |
| -------- |
|
[![avm.res.operational-insights.workspace](https://github.com/krbar/bicep-registry-modules/actions/workflows/avm.res.operational-insights.workspace.yml/badge.svg?branch=users%2Fkrbar%2FlawUDT)](https://github.com/krbar/bicep-registry-modules/actions/workflows/avm.res.operational-insights.workspace.yml)
|

## Type of Change

<!-- Use the checkboxes [x] on the options that are relevant. -->

- [ ] Update to CI Environment or utilities (Non-module affecting
changes)
- [x] Azure Verified Module updates:
- [ ] Bugfix containing backwards-compatible bug fixes, and I have NOT
bumped the MAJOR or MINOR version in `version.json`:
- [ ] Someone has opened a bug report issue, and I have included "Closes
#{bug_report_issue_number}" in the PR description.
- [ ] The bug was found by the module author, and no one has opened an
issue to report it yet.
- [ ] Feature update backwards compatible feature updates, and I have
bumped the MINOR version in `version.json`.
- [x] Breaking changes and I have bumped the MAJOR version in
`version.json`.
  - [ ] Update to documentation

## Checklist

- [x] I'm sure there are no other open Pull Requests for the same
update/change
- [x] I have run `Set-AVMModule` locally to generate the supporting
module files.
- [x] My corresponding pipelines / checks run clean and green without
any errors or warnings

<!-- Please keep up to date with the contribution guide at
https://aka.ms/avm/contribute/bicep -->

---------

Co-authored-by: Alexander Sehr <[email protected]>
  • Loading branch information
krbar and AlexanderSehr authored Nov 18, 2024
1 parent f84c0ad commit 46042e7
Show file tree
Hide file tree
Showing 26 changed files with 2,655 additions and 342 deletions.
884 changes: 818 additions & 66 deletions avm/res/operational-insights/workspace/README.md

Large diffs are not rendered by default.

57 changes: 47 additions & 10 deletions avm/res/operational-insights/workspace/data-export/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ This module deploys a Log Analytics Workspace Data Export.
| Parameter | Type | Description |
| :-- | :-- | :-- |
| [`name`](#parameter-name) | string | The data export rule name. |
| [`tableNames`](#parameter-tablenames) | array | An array of tables to export, for example: ['Heartbeat', 'SecurityEvent']. |

**Conditional parameters**

Expand All @@ -34,7 +35,6 @@ This module deploys a Log Analytics Workspace Data Export.
| :-- | :-- | :-- |
| [`destination`](#parameter-destination) | object | Destination properties. |
| [`enable`](#parameter-enable) | bool | Active when enabled. |
| [`tableNames`](#parameter-tablenames) | array | An array of tables to export, for example: ['Heartbeat', 'SecurityEvent']. |

### Parameter: `name`

Expand All @@ -43,6 +43,13 @@ The data export rule name.
- Required: Yes
- Type: string

### Parameter: `tableNames`

An array of tables to export, for example: ['Heartbeat', 'SecurityEvent'].

- Required: Yes
- Type: array

### Parameter: `workspaceName`

The name of the parent workspaces. Required if the template is used in a standalone deployment.
Expand All @@ -56,23 +63,53 @@ Destination properties.

- Required: No
- Type: object
- Default: `{}`

### Parameter: `enable`
**Required parameters**

Active when enabled.
| Parameter | Type | Description |
| :-- | :-- | :-- |
| [`resourceId`](#parameter-destinationresourceid) | string | The destination resource ID. |

**Optional parameters**

| Parameter | Type | Description |
| :-- | :-- | :-- |
| [`metaData`](#parameter-destinationmetadata) | object | The destination metadata. |

### Parameter: `destination.resourceId`

The destination resource ID.

- Required: Yes
- Type: string

### Parameter: `destination.metaData`

The destination metadata.

- Required: No
- Type: bool
- Default: `False`
- Type: object

### Parameter: `tableNames`
**Optional parameters**

An array of tables to export, for example: ['Heartbeat', 'SecurityEvent'].
| Parameter | Type | Description |
| :-- | :-- | :-- |
| [`eventHubName`](#parameter-destinationmetadataeventhubname) | string | Allows to define an Event Hub name. Not applicable when destination is Storage Account. |

### Parameter: `destination.metaData.eventHubName`

Allows to define an Event Hub name. Not applicable when destination is Storage Account.

- Required: No
- Type: array
- Default: `[]`
- Type: string

### Parameter: `enable`

Active when enabled.

- Required: No
- Type: bool
- Default: `False`

## Outputs

Expand Down
23 changes: 20 additions & 3 deletions avm/res/operational-insights/workspace/data-export/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ param name string
param workspaceName string

@description('Optional. Destination properties.')
param destination object = {}
param destination destinationType?

@description('Optional. Active when enabled.')
param enable bool = false

@description('Optional. An array of tables to export, for example: [\'Heartbeat\', \'SecurityEvent\'].')
param tableNames array = []
@minLength(1)
@description('Required. An array of tables to export, for example: [\'Heartbeat\', \'SecurityEvent\'].')
param tableNames string[]

// =============== //
// Deployments //
Expand Down Expand Up @@ -53,3 +54,19 @@ output resourceId string = dataExport.id

@description('The name of the resource group the data export was created in.')
output resourceGroupName string = resourceGroup().name

// =============== //
// Definitions //
// =============== //

@export()
@description('The data export destination properties.')
type destinationType = {
@description('Required. The destination resource ID.')
resourceId: string
@description('Optional. The destination metadata.')
metaData: {
@description('Optional. Allows to define an Event Hub name. Not applicable when destination is Storage Account.')
eventHubName: string?
}?
}
66 changes: 56 additions & 10 deletions avm/res/operational-insights/workspace/data-export/main.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,50 @@
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"languageVersion": "2.0",
"contentVersion": "1.0.0.0",
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.31.34.60546",
"templateHash": "6471227851268955186"
"version": "0.31.92.45157",
"templateHash": "8392467222383128491"
},
"name": "Log Analytics Workspace Data Exports",
"description": "This module deploys a Log Analytics Workspace Data Export.",
"owner": "Azure/module-maintainers"
},
"definitions": {
"destinationType": {
"type": "object",
"properties": {
"resourceId": {
"type": "string",
"metadata": {
"description": "Required. The destination resource ID."
}
},
"metaData": {
"type": "object",
"properties": {
"eventHubName": {
"type": "string",
"nullable": true,
"metadata": {
"description": "Optional. Allows to define an Event Hub name. Not applicable when destination is Storage Account."
}
}
},
"nullable": true,
"metadata": {
"description": "Optional. The destination metadata."
}
}
},
"metadata": {
"__bicep_export!": true,
"description": "The data export destination properties."
}
}
},
"parameters": {
"name": {
"type": "string",
Expand All @@ -27,8 +61,8 @@
}
},
"destination": {
"type": "object",
"defaultValue": {},
"$ref": "#/definitions/destinationType",
"nullable": true,
"metadata": {
"description": "Optional. Destination properties."
}
Expand All @@ -42,24 +76,36 @@
},
"tableNames": {
"type": "array",
"defaultValue": [],
"items": {
"type": "string"
},
"minLength": 1,
"metadata": {
"description": "Optional. An array of tables to export, for example: ['Heartbeat', 'SecurityEvent']."
"description": "Required. An array of tables to export, for example: ['Heartbeat', 'SecurityEvent']."
}
}
},
"resources": [
{
"resources": {
"workspace": {
"existing": true,
"type": "Microsoft.OperationalInsights/workspaces",
"apiVersion": "2022-10-01",
"name": "[parameters('workspaceName')]"
},
"dataExport": {
"type": "Microsoft.OperationalInsights/workspaces/dataExports",
"apiVersion": "2020-08-01",
"name": "[format('{0}/{1}', parameters('workspaceName'), parameters('name'))]",
"properties": {
"destination": "[parameters('destination')]",
"enable": "[parameters('enable')]",
"tableNames": "[parameters('tableNames')]"
}
},
"dependsOn": [
"workspace"
]
}
],
},
"outputs": {
"name": {
"type": "string",
Expand Down
14 changes: 4 additions & 10 deletions avm/res/operational-insights/workspace/data-source/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ This module deploys a Log Analytics Workspace Data Source.

| Parameter | Type | Description |
| :-- | :-- | :-- |
| [`name`](#parameter-name) | string | Name of the solution. |
| [`name`](#parameter-name) | string | Name of the data source. |

**Conditional parameters**

Expand All @@ -37,7 +37,7 @@ This module deploys a Log Analytics Workspace Data Source.
| [`eventTypes`](#parameter-eventtypes) | array | Windows event types to configure when kind is WindowsEvent. |
| [`instanceName`](#parameter-instancename) | string | Name of the instance to configure when kind is WindowsPerformanceCounter or LinuxPerformanceObject. |
| [`intervalSeconds`](#parameter-intervalseconds) | int | Interval in seconds to configure when kind is WindowsPerformanceCounter or LinuxPerformanceObject. |
| [`kind`](#parameter-kind) | string | The kind of the DataSource. |
| [`kind`](#parameter-kind) | string | The kind of the data source. |
| [`linkedResourceId`](#parameter-linkedresourceid) | string | Resource ID of the resource to be linked. |
| [`objectName`](#parameter-objectname) | string | Name of the object to configure when kind is WindowsPerformanceCounter or LinuxPerformanceObject. |
| [`performanceCounters`](#parameter-performancecounters) | array | List of counters to configure when the kind is LinuxPerformanceObject. |
Expand All @@ -48,7 +48,7 @@ This module deploys a Log Analytics Workspace Data Source.

### Parameter: `name`

Name of the solution.
Name of the data source.

- Required: Yes
- Type: string
Expand All @@ -66,15 +66,13 @@ Counter name to configure when kind is WindowsPerformanceCounter.

- Required: No
- Type: string
- Default: `''`

### Parameter: `eventLogName`

Windows event log name to configure when kind is WindowsEvent.

- Required: No
- Type: string
- Default: `''`

### Parameter: `eventTypes`

Expand Down Expand Up @@ -102,7 +100,7 @@ Interval in seconds to configure when kind is WindowsPerformanceCounter or Linux

### Parameter: `kind`

The kind of the DataSource.
The kind of the data source.

- Required: No
- Type: string
Expand All @@ -127,15 +125,13 @@ Resource ID of the resource to be linked.

- Required: No
- Type: string
- Default: `''`

### Parameter: `objectName`

Name of the object to configure when kind is WindowsPerformanceCounter or LinuxPerformanceObject.

- Required: No
- Type: string
- Default: `''`

### Parameter: `performanceCounters`

Expand All @@ -151,15 +147,13 @@ State to configure when kind is IISLogs or LinuxSyslogCollection or LinuxPerform

- Required: No
- Type: string
- Default: `''`

### Parameter: `syslogName`

System log to configure when kind is LinuxSyslog.

- Required: No
- Type: string
- Default: `''`

### Parameter: `syslogSeverities`

Expand Down
16 changes: 8 additions & 8 deletions avm/res/operational-insights/workspace/data-source/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ metadata owner = 'Azure/module-maintainers'
@description('Conditional. The name of the parent Log Analytics workspace. Required if the template is used in a standalone deployment.')
param logAnalyticsWorkspaceName string

@description('Required. Name of the solution.')
@description('Required. Name of the data source.')
param name string

@description('Optional. The kind of the DataSource.')
@description('Optional. The kind of the data source.')
@allowed([
'AzureActivityLog'
'WindowsEvent'
Expand All @@ -25,16 +25,16 @@ param kind string = 'AzureActivityLog'
param tags object?

@description('Optional. Resource ID of the resource to be linked.')
param linkedResourceId string = ''
param linkedResourceId string?

@description('Optional. Windows event log name to configure when kind is WindowsEvent.')
param eventLogName string = ''
param eventLogName string?

@description('Optional. Windows event types to configure when kind is WindowsEvent.')
param eventTypes array = []

@description('Optional. Name of the object to configure when kind is WindowsPerformanceCounter or LinuxPerformanceObject.')
param objectName string = ''
param objectName string?

@description('Optional. Name of the instance to configure when kind is WindowsPerformanceCounter or LinuxPerformanceObject.')
param instanceName string = '*'
Expand All @@ -46,13 +46,13 @@ param intervalSeconds int = 60
param performanceCounters array = []

@description('Optional. Counter name to configure when kind is WindowsPerformanceCounter.')
param counterName string = ''
param counterName string?

@description('Optional. State to configure when kind is IISLogs or LinuxSyslogCollection or LinuxPerformanceCollection.')
param state string = ''
param state string?

@description('Optional. System log to configure when kind is LinuxSyslog.')
param syslogName string = ''
param syslogName string?

@description('Optional. Severities to configure when kind is LinuxSyslog.')
param syslogSeverities array = []
Expand Down
Loading

0 comments on commit 46042e7

Please sign in to comment.