Ресурсная группа, виртуальная машина и все необходимые ресурсы для этих виртуальных машин < /li>
Рабочая пространство Loganalytics < /li>
loganalytics Рабочая сфера /> datacollectionRuleAssociation < /li>
virtualMachineExtension (azuremonitorlinuxagent) < /li>
userAssignedIdentity < /li>
< /ul>
Все ресурсы связаны вместе, и настройки для расширения записываются внутри настройки в LAN «azurerm_virtual_machine_extension». Но: ни одна машина не подключена к рабочему пространству Loganalytics. Агент - «счетчик» для серверов Linux остается на уровне 0.
, чтобы выяснить, где проблема, мы создали простой пример развертывания и тестируют различные настройки. Но это было невозможно найти решение для этого.
Теперь есть три вопроса: < /p>
-правильный путь развертывания, построенный в правильном пути. Так, например: все ли необходимы ресурсы перечислены там (см. Пример кода ниже)? Например, что означает параметр «gcs_auto_config» (без него, установка для расширения будет столкнуться с сбоем)? Есть ли что-то не так в блоке? required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~> 4.25.0"
}
}
}
provider "azurerm" {
features {}
subscription_id = "..."
}
#Remote-State configuration
terraform {
backend "azurerm" {
resource_group_name = "MonitoringTest2StateStore"
storage_account_name = "montststatestore2"
container_name = "opentofustate"
key = "tofu.tfstate"
}
}
resource "azurerm_resource_group" "monitorsimple" {
name = "monitorsimple"
location = "West Europe"
}
resource "azurerm_virtual_network" "monitorsimple" {
name = "monitorsimple-vnet"
address_space = ["10.0.0.0/16"]
location = azurerm_resource_group.monitorsimple.location
resource_group_name = azurerm_resource_group.monitorsimple.name
}
resource "azurerm_subnet" "monitorsimple" {
name = "monitorsimple-subnet"
resource_group_name = azurerm_resource_group.monitorsimple.name
virtual_network_name = azurerm_virtual_network.monitorsimple.name
address_prefixes = ["10.0.1.0/24"]
}
resource "azurerm_network_interface" "monitorsimple" {
name = "monitorsimple-nic"
location = azurerm_resource_group.monitorsimple.location
resource_group_name = azurerm_resource_group.monitorsimple.name
ip_configuration {
name = "monitorsimple-ip-config"
subnet_id = azurerm_subnet.monitorsimple.id
private_ip_address_allocation = "Dynamic"
}
}
resource "azurerm_linux_virtual_machine" "monitorsimple" {
name = "monitorsimple-vm"
resource_group_name = azurerm_resource_group.monitorsimple.name
location = azurerm_resource_group.monitorsimple.location
size = "Standard_DS1_v2"
disable_password_authentication = false
admin_username = "adminuser"
admin_password = "

network_interface_ids = [azurerm_network_interface.monitorsimple.id]
os_disk {
caching = "ReadWrite"
storage_account_type = "Standard_LRS"
}
source_image_reference {
publisher = "Canonical"
offer = "UbuntuServer"
sku = "18.04-LTS"
version = "latest"
}
identity {
type = "UserAssigned"
identity_ids = [azurerm_user_assigned_identity.monitorsimple.id]
}
}
resource "azurerm_eventhub_namespace" "monitorsimple" {
name = "monitorsimpleehns"
location = azurerm_resource_group.monitorsimple.location
resource_group_name = azurerm_resource_group.monitorsimple.name
sku = "Standard"
capacity = 1
}
resource "azurerm_eventhub" "monitorsimple" {
name = "monitorsimple-eventhub"
namespace_id = azurerm_eventhub_namespace.monitorsimple.id
partition_count = 2
message_retention = 1
}
resource "azurerm_log_analytics_workspace" "monitorsimple" {
name = "monitorsimple-law"
location = azurerm_resource_group.monitorsimple.location
resource_group_name = azurerm_resource_group.monitorsimple.name
sku = "PerGB2018"
retention_in_days = 30
}
resource "azurerm_log_analytics_solution" "vminsights" {
solution_name = "VMInsights"
resource_group_name = azurerm_resource_group.monitorsimple.name
location = azurerm_resource_group.monitorsimple.location
workspace_resource_id = azurerm_log_analytics_workspace.monitorsimple.id
workspace_name = azurerm_log_analytics_workspace.monitorsimple.name
plan {
publisher = "Microsoft"
product = "OMSGallery/VMInsights"
}
}
resource "azurerm_monitor_data_collection_rule" "monitorsimple" {
name = "monitorsimpledcr"
location = azurerm_resource_group.monitorsimple.location
resource_group_name = azurerm_resource_group.monitorsimple.name
destinations {
log_analytics {
workspace_resource_id = azurerm_log_analytics_workspace.monitorsimple.id
name = "laws-store"
}
}
data_flow {
streams = ["Microsoft-InsightsMetrics", "Microsoft-Syslog", "Microsoft-Perf"]
destinations = ["laws-store"]
}
data_sources {
syslog {
facility_names = ["*"]
log_levels = ["*"]
name = "example-datasource-syslog"
streams = ["Microsoft-Syslog"]
}
performance_counter {
streams = ["Microsoft-Perf", "Microsoft-InsightsMetrics"]
sampling_frequency_in_seconds = 60
counter_specifiers = ["Processor(*)\\% Processor Time"]
name = "example-datasource-perfcounter"
}
}
depends_on = [
azurerm_log_analytics_solution.vminsights
]
}
resource "azurerm_monitor_data_collection_rule_association" "monitorsimple" {
name = "monitorsimpledcra"
target_resource_id = azurerm_linux_virtual_machine.monitorsimple.id
data_collection_rule_id = azurerm_monitor_data_collection_rule.monitorsimple.id
description = "assoc between vm and dcr"
}
resource "azurerm_user_assigned_identity" "monitorsimple" {
location = azurerm_resource_group.monitorsimple.location
name = "monitorsimpleusid"
resource_group_name = azurerm_resource_group.monitorsimple.name
}
resource "azurerm_virtual_machine_extension" "monitor_agent" {
name = "AzureMonitorLinuxAgent"
virtual_machine_id = azurerm_linux_virtual_machine.monitorsimple.id
publisher = "Microsoft.Azure.Monitor"
type = "AzureMonitorLinuxAgent"
type_handler_version = "1.33"
auto_upgrade_minor_version = true
settings = jsonencode({
GCS_AUTO_CONFIG = true
workspaceId = azurerm_log_analytics_workspace.monitorsimple.id
azureResourceId = azurerm_linux_virtual_machine.monitorsimple.id
stopOnMultipleConnections = false
authentication = {
managedIdentity = {
identifier-name = "mi_res_id"
identifier-value = azurerm_user_assigned_identity.monitorsimple.id
}
}
})
protected_settings = jsonencode({
"workspaceKey" = azurerm_log_analytics_workspace.monitorsimple.primary_shared_key
})
}
< /code>
Наше ожидание состоит в том, что рабочая область Loganalytics показывает подключенные машины Linux и считает эти машины, которые запускают агент мониторинга Azure и которые связаны с помощью DCR.
В настоящее время он ничего не делает:
loganalytics-> settings-> Agents-> Linux Servers. современный подсказки?>
Подробнее здесь: https://stackoverflow.com/questions/795 ... ganalytics