Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions modules/azure/data_collection_endpoint/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
terraform {
required_version = "~> 1.12"

required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~> 3.117"
}
}

backend "azurerm" {}
}

provider "azurerm" {
features {}
}

resource "azurerm_monitor_data_collection_endpoint" "data_collection_endpoint" {
name = var.name
location = var.location
resource_group_name = var.resource_group_name
kind = var.kind
public_network_access_enabled = var.public_network_access_enabled
description = var.description
tags = var.tags
}
15 changes: 15 additions & 0 deletions modules/azure/data_collection_endpoint/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
output "id" {
value = azurerm_monitor_data_collection_endpoint.data_collection_endpoint.id
}

output "name" {
value = azurerm_monitor_data_collection_endpoint.data_collection_endpoint.name
}

output "logs_ingestion_endpoint" {
value = azurerm_monitor_data_collection_endpoint.data_collection_endpoint.logs_ingestion_endpoint
}

output "configuration_access_endpoint" {
value = azurerm_monitor_data_collection_endpoint.data_collection_endpoint.configuration_access_endpoint
}
38 changes: 38 additions & 0 deletions modules/azure/data_collection_endpoint/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
variable "location" {
type = string
description = "A datacenter location in Azure."
}

variable "resource_group_name" {
type = string
description = "Name of the resource group."
}

variable "name" {
type = string
description = "Specifies the name of the Data Collection Endpoint."
}

variable "kind" {
type = string
description = "The kind of the Data Collection Endpoint. Possible values are Linux and Windows."
default = "Linux"
}

variable "public_network_access_enabled" {
type = bool
description = "Whether network access from public internet to the endpoint is allowed."
default = true
}

variable "description" {
type = string
description = "Specifies a description for the Data Collection Endpoint."
default = null
}

variable "tags" {
type = map(string)
description = "A mapping of tags to assign to the resource."
default = null
}
64 changes: 64 additions & 0 deletions modules/azure/data_collection_rule/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
terraform {
required_version = "~> 1.12"

required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~> 3.117"
}
}

backend "azurerm" {}
}

provider "azurerm" {
features {}
}

locals {
streams = { for stream in var.streams : stream.name => stream }
}

resource "azurerm_monitor_data_collection_rule" "data_collection_rule" {
name = var.name
location = var.location
resource_group_name = var.resource_group_name
data_collection_endpoint_id = var.data_collection_endpoint_id
description = var.description
tags = var.tags

destinations {
log_analytics {
name = var.destination_name
workspace_resource_id = var.log_analytics_workspace_id
}
}

dynamic "stream_declaration" {
for_each = local.streams

content {
stream_name = stream_declaration.value.name

dynamic "column" {
for_each = stream_declaration.value.columns

content {
name = column.value.name
type = column.value.type
}
}
}
}

dynamic "data_flow" {
for_each = local.streams

content {
streams = [data_flow.value.name]
destinations = [var.destination_name]
transform_kql = data_flow.value.transform_kql
output_stream = data_flow.value.output_stream
}
}
}
11 changes: 11 additions & 0 deletions modules/azure/data_collection_rule/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
output "id" {
value = azurerm_monitor_data_collection_rule.data_collection_rule.id
}

output "name" {
value = azurerm_monitor_data_collection_rule.data_collection_rule.name
}

output "immutable_id" {
value = azurerm_monitor_data_collection_rule.data_collection_rule.immutable_id
}
55 changes: 55 additions & 0 deletions modules/azure/data_collection_rule/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
variable "location" {
type = string
description = "A datacenter location in Azure."
}

variable "resource_group_name" {
type = string
description = "Name of the resource group."
}

variable "name" {
type = string
description = "Specifies the name of the Data Collection Rule."
}

variable "log_analytics_workspace_id" {
type = string
description = "Resource id of the Log Analytics Workspace the collected data is sent to."
}

variable "data_collection_endpoint_id" {
type = string
description = "Resource id of the Data Collection Endpoint that receives the data."
}

variable "streams" {
type = list(object({
name = string
output_stream = string
transform_kql = string
columns = list(object({
name = string
type = string
}))
}))
description = "The custom streams accepted by this rule. Every stream gets a stream declaration describing the incoming data and a data flow that transforms it into the output stream. Stream names must start with Custom-, and the output stream must reference a table that already exists in the workspace."
}

variable "destination_name" {
type = string
description = "Name used to reference the Log Analytics destination inside the rule."
default = "logAnalytics"
}

variable "description" {
type = string
description = "Specifies a description for the Data Collection Rule."
default = null
}

variable "tags" {
type = map(string)
description = "A mapping of tags to assign to the resource."
default = null
}
Loading