azure - 为 VMSS 添加 Azure 诊断设置
问题描述
我目前正在运行带有使用 terraform 创建的 Ubuntu 20.04 VM 的 Linux VMSS。我希望添加 Linux Azure 诊断 (LAD) 扩展以启用 VM 的诊断日志。这是我目前用于此目的的 terraform 资源
resource "time_offset" "linux_oms_sas_start" {
offset_days = -1
}
resource "time_offset" "linux_oms_sas_expiry" {
offset_years = 5
}
data "azurerm_storage_account_sas" "linux_oms" {
connection_string = var.storage_account_primary_connection_string
https_only = true
resource_types {
service = true
container = true
object = true
}
services {
blob = true
table = true
queue = false
file = false
}
start = time_offset.linux_oms_sas_start.rfc3339
expiry = time_offset.linux_oms_sas_expiry.rfc3339
permissions {
read = true
write = true
delete = true
list = true
add = true
create = true
update = true
process = true
}
depends_on = [time_offset.linux_oms_sas_start,time_offset.linux_oms_sas_expiry]
}
resource "azurerm_virtual_machine_scale_set_extension" "da_extension" {
name = "DAExtension"
virtual_machine_scale_set_id = var.vmss_id
publisher = "Microsoft.Azure.Monitoring.DependencyAgent"
type = "DependencyAgentLinux"
type_handler_version = "9.5"
auto_upgrade_minor_version = false
}
resource "azurerm_virtual_machine_scale_set_extension" "diagnostics_extension" {
name = "StorageExtension"
virtual_machine_scale_set_id = var.vmss_id
publisher = "Microsoft.Azure.Diagnostics"
type = "LinuxDiagnostic"
type_handler_version = "4.0"
auto_upgrade_minor_version = false
settings = <<SETTINGS
{
"StorageAccount": "${var.storage_account_name}",
"ladCfg": {
"diagnosticMonitorConfiguration": {
"eventVolume": "Medium",
"metrics": {
"metricAggregation": [
{
"scheduledTransferPeriod": "PT1H"
},
{
"scheduledTransferPeriod": "PT1M"
}
],
"resourceId": "${var.vmss_id}"
},
"performanceCounters": ${file("${path.module}/azure_extension_diagnostics_linux_performancecounters.json")},
"syslogEvents": ${file("${path.module}/azure_extension_diagnostics_linux_syslogevents.json")}
},
"sampleRateInSeconds": 15
}
}
SETTINGS
protected_settings = <<SETTINGS
{
"storageAccountName": "${var.storage_account_name}",
"storageAccountSasToken": "${data.azurerm_storage_account_sas.linux_oms.sas}",
"storageAccountEndPoint": "https://core.windows.net",
"sinksConfig": {
"sink": [
{
"name": "SyslogJsonBlob",
"type": "JsonBlob"
},
{
"name": "LinuxCpuJsonBlob",
"type": "JsonBlob"
}
]
}
}
SETTINGS
}
但是,在应用上述 terraform 代码时,我从门户网站收到错误消息,如下所示
Enable failed:'NoneType' object has no attribute 'get_fluentd_syslog_src_config'
任何有关问题的帮助将不胜感激。
PS 如果需要,我已附上代码中使用的azure_extension_diagnostics_linux_performancecounters.json
文件和azure_extension_diagnostics_linux_syslogevents.json
文件以供进一步参考。
azure_extension_diagnostics_linux_performancecounters.json
文件
{
"performanceCounterConfiguration": []
}
和azure_extension_diagnostics_linux_syslogevents.json
文件
{
"syslogEventConfiguration": {
"LOG_AUTH": "LOG_DEBUG",
"LOG_AUTHPRIV": "LOG_DEBUG",
"LOG_CRON": "LOG_DEBUG",
"LOG_DAEMON": "LOG_DEBUG",
"LOG_FTP": "LOG_DEBUG",
"LOG_KERN": "LOG_DEBUG",
"LOG_LOCAL0": "LOG_DEBUG",
"LOG_LOCAL1": "LOG_DEBUG",
"LOG_LOCAL2": "LOG_DEBUG",
"LOG_LOCAL3": "LOG_DEBUG",
"LOG_LOCAL4": "LOG_DEBUG",
"LOG_LOCAL5": "LOG_DEBUG",
"LOG_LOCAL6": "LOG_DEBUG",
"LOG_LOCAL7": "LOG_DEBUG",
"LOG_LPR": "LOG_DEBUG",
"LOG_MAIL": "LOG_DEBUG",
"LOG_NEWS": "LOG_DEBUG",
"LOG_SYSLOG": "LOG_DEBUG",
"LOG_USER": "LOG_DEBUG",
"LOG_UUCP": "LOG_DEBUG"
}
}
解决方案
不支持为 Ubuntu 20.04 安装诊断代理。只有 Azure Monitor Agent 或 Log Analytics Agent and Dependency Agent 是可能的。
参考:
推荐阅读
- wordpress - 如何在本地设置由 Gitlab 上的其他人开发的 WordPress 站点
- c - 解析 CSV 文件问题
- c++ - 为什么在类型转换的 nullptr 上不会发生隐式转换
- android - React Native Android 在 dev 中运行,但在 release 中不运行
- haskell - 哈斯克尔。给出了两个相同长度的列表。编写一个构建差异的“diff”函数,如下所示
- r - 如何从 URL 列表中读取 json 数据并将其整理到数据框中?
- python - Python通过另一个列表解析字符串列表并返回匹配项
- python - Pandas 对具有可变子数组长度的列求和并在结果中添加更多列
- r - 缺少编码为 NA 和“NA”的数据
- linux - 从 Wordlist 中删除用户的 Bash 脚本