Azure / azure-linux-extensions

Linux Virtual Machine Extensions for Azure
Apache License 2.0
307 stars 254 forks source link

VM has reported a failure when processing extension 'Microsoft.Insights.VMDiagnosticSettings' for RedHat 7.7 #976

Open sbhoumickgit opened 4 years ago

sbhoumickgit commented 4 years ago

Please find attached the configuration which I've used in my ARM Template to enable Diagnostic in RedHat7.7 VM and I've followed guidelines from :- "https://github.com/Azure/azure-linux-extensions/blob/master/Diagnostic/virtual-machines-linux-diagnostic-extension-v3.md"

Please find below few information that might help


VM - RedHat 7.7 VM Deployment Status - Newly Created using same ARM Template Storage Account Deployment Status - Newly Created using same ARM Template

My ARM Template first create a storage account, then the vm and then execute diagnostic extension.


Now the problem is my ARM Template is executing and all the resources are being created successfully even in the portal I can see Boot Diagnostics & VM Diagnostics is enabled with added parameters/rules for newly created VM but still at the end of ARM Template execution it is throwing me an error as below -

{ "status": "Failed", "error": { "code": "ResourceDeploymentFailure", "message": "The resource operation completed with terminal provisioning state 'Failed'.", "details": [ { "code": "VMExtensionProvisioningError", "message": "VM has reported a failure when processing extension 'Microsoft.Insights.VMDiagnosticSettings'. Error message: \"Extension operation Enable failed:'NoneType' object has no attribute 'get_fluentd_syslog_src_config'\"\r\n\r\nMore information on troubleshooting is available at https://aka.ms/VMExtensionLinuxDiagnosticsTroubleshoot " } ] } }

Please help me to resolve this exception and make the template error free template. Thank you. Diagnostics.txt

SPSamL commented 4 years ago

Same issue using the following. vmName and diagStgName are valid values.

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "vmName": {
            "type": "string"
        },
        "diagStgName": {
            "type": "string"
        }
    },
    "variables": {
    },
    "resources": [
        {
            "type": "Microsoft.Compute/virtualMachines/extensions",
            "apiVersion": "2017-12-01",
            "location": "[resourceGroup().location]",
            "name": "[concat(parameters('vmName'), '/Microsoft.Insights.VMDiagnosticSettings')]",
            "tags": {
                "displayName": "AzureDiagnostics"
            },
            "properties": {
                "publisher": "Microsoft.Azure.Diagnostics",
                "type": "LinuxDiagnostic",
                "autoUpgradeMinorVersion": true,
                "typeHandlerVersion": "3.0",
                "protectedSettings": {
                    "storageAccountName": "[parameters('diagStgName')]",
                    "storageAccountKey": "[listkeys(resourceId('Microsoft.Storage/storageAccounts',parameters('diagStgName')), '2017-06-01').keys[0].value]",
                    "storageAccountEndPoint": "https://core.usgovcloudapi.net"
                },
                "settings": {
                    "StorageAccount": "[parameters('diagStgName')]",
                    "ladCfg": {
                        "diagnosticMonitorConfiguration": {
                            "syslogEvents": {
                                "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"
                                }
                            },
                            "sampleRateInSeconds": 15,
                            "eventVolume": "Medium",
                            "metrics": {
                                "resourceId": "[resourceId('Microsoft.Compute/virtualMachines', parameters('vmName'))]",
                                "metricAggregation": [
                                    {
                                        "scheduledTransferPeriod": "PT1H"
                                    },
                                    {
                                        "scheduledTransferPeriod": "PT1M"
                                    }
                                ]
                            },
                            "performanceCounters": {
                                "performanceCounterConfiguration": [
                                    {
                                        "annotation": [
                                            {
                                                "displayName": "Filesystem % free space",
                                                "locale": "en-us"
                                            }
                                        ],
                                        "class": "filesystem",
                                        "condition": "IsAggregate=TRUE",
                                        "counter": "percentfreespace",
                                        "counterSpecifier": "/builtin/filesystem/percentfreespace",
                                        "type": "builtin",
                                        "unit": "Percent"
                                    },
                                    {
                                        "annotation": [
                                            {
                                                "displayName": "Filesystem % used space",
                                                "locale": "en-us"
                                            }
                                        ],
                                        "class": "filesystem",
                                        "condition": "IsAggregate=TRUE",
                                        "counter": "percentusedspace",
                                        "counterSpecifier": "/builtin/filesystem/percentusedspace",
                                        "type": "builtin",
                                        "unit": "Percent"
                                    },
                                    {
                                        "annotation": [
                                            {
                                                "displayName": "Filesystem used space",
                                                "locale": "en-us"
                                            }
                                        ],
                                        "class": "filesystem",
                                        "condition": "IsAggregate=TRUE",
                                        "counter": "usedspace",
                                        "counterSpecifier": "/builtin/filesystem/usedspace",
                                        "type": "builtin",
                                        "unit": "Bytes"
                                    },
                                    {
                                        "annotation": [
                                            {
                                                "displayName": "Filesystem read bytes/sec",
                                                "locale": "en-us"
                                            }
                                        ],
                                        "class": "filesystem",
                                        "condition": "IsAggregate=TRUE",
                                        "counter": "bytesreadpersecond",
                                        "counterSpecifier": "/builtin/filesystem/bytesreadpersecond",
                                        "type": "builtin",
                                        "unit": "CountPerSecond"
                                    },
                                    {
                                        "annotation": [
                                            {
                                                "displayName": "Filesystem free space",
                                                "locale": "en-us"
                                            }
                                        ],
                                        "class": "filesystem",
                                        "condition": "IsAggregate=TRUE",
                                        "counter": "freespace",
                                        "counterSpecifier": "/builtin/filesystem/freespace",
                                        "type": "builtin",
                                        "unit": "Bytes"
                                    },
                                    {
                                        "annotation": [
                                            {
                                                "displayName": "Filesystem % free inodes",
                                                "locale": "en-us"
                                            }
                                        ],
                                        "class": "filesystem",
                                        "condition": "IsAggregate=TRUE",
                                        "counter": "percentfreeinodes",
                                        "counterSpecifier": "/builtin/filesystem/percentfreeinodes",
                                        "type": "builtin",
                                        "unit": "Percent"
                                    }
                                ]
                            }
                        }
                    }
                }
            }
        }
    ],
    "outputs": {
    }
}
SPSamL commented 4 years ago

It looks like it's possible to add this through the UI using the VM Diagnostic settings pane. As you can see in the images, When I assign a storage account it adds the default metrics, logs, etc and the extension shows it was provisioned successfully. However, when I took the template that the deployment used with minor modifications to pass in my parameters, it fails in the same manner.

What's going on that's different between these deployments? Is there some part of the VM settings that need to be changed prior to deploying the extensions?

Linux VM diag settings Linux VM diag settings configured linux VM extension success

Template generated by Portal UI changes (replaced resource names with placeholders): working-ui-generated-template.txt

My template using the LadCfg from above: failed-custom-template.txt

paulehr commented 4 years ago

I am running into the same issue as well.

kob-aha commented 4 years ago

I had the same problem and managed to solve it.

In my case I logged in to the machine and saw the following error in /var/log/azure/Microsoft.Azure.Diagnostics.LinuxDiagnostic/extension.log:

2020/04/01 09:19:57 [Microsoft.Azure.Diagnostics.LinuxDiagnostic-3.0.127] Deployment ID found: 54dfbc0e-06da-4206-a7ca-16bab7df8909. 2020/04/01 09:19:57 ERROR:[Microsoft.Azure.Diagnostics.LinuxDiagnostic-3.0.127] Failed to create omsagent (fluentd), rsyslog/syslog-ng configs or to update corresponding mdsd config XML. Error: sasURL is not specified for EventHub sink_name=eventHub 2020/04/01 09:19:57 ERROR:Stacktrace: Traceback (most recent call last): 2020/04/01 09:19:57 ERROR: File "/var/lib/waagent/Microsoft.Azure.Diagnostics.LinuxDiagnostic-3.0.127/lad_config_all.py", line 435, in generate_all_configs 2020/04/01 09:19:57 ERROR: mdsd_syslog_config = lad_logging_config_helper.get_mdsd_syslog_config() 2020/04/01 09:19:57 ERROR: File "/var/lib/waagent/Microsoft.Azure.Diagnostics.LinuxDiagnostic-3.0.127/Utils/lad_logging_config.py", line 171, in get_mdsd_syslog_config 2020/04/01 09:19:57 ERROR: self._mdsd_syslog_config = self.generate_mdsd_syslog_config() 2020/04/01 09:19:57 ERROR: File "/var/lib/waagent/Microsoft.Azure.Diagnostics.LinuxDiagnostic-3.0.127/Utils/lad_logging_config.py", line 192, in __generate_mdsd_syslog_config 2020/04/01 09:19:57 ERROR: syslog_src_name) 2020/04/01 09:19:57 ERROR: File "/var/lib/waagent/Microsoft.Azure.Diagnostics.LinuxDiagnostic-3.0.127/Utils/lad_logging_config.py", line 226, in generate_routeevent_and_eh_url_for_extra_sink 2020/04/01 09:19:57 ERROR: raise LadLoggingConfigException('sasURL is not specified for EventHub sink_name={0}'.format(sink_name)) 2020/04/01 09:19:57 ERROR:LadLoggingConfigException: sasURL is not specified for EventHub sink_name=eventHub 2020/04/01 09:19:57 ERROR: 2020/04/01 09:19:57 [Microsoft.Azure.Diagnostics.LinuxDiagnostic-3.0.127] Invalid config settings given: Failed to generate configs for fluentd, syslog, and mdsd (see extension error logs for more details). Can't proceed, although this install/enable operation is reported as successful so the VM can complete successful startup.

(marked the problem in bold)

Turns out my protected settings were incorrect. Seems like an event hub sink should contain "sasURL" and not "sasUrl" as written in the documentation. Changing the value fixed the problem for me.

Not sure if you're using an event hub or not, however the file might help you better understand what is the problem.

paulehr commented 4 years ago

i think i found my issue. It wasnt with the sasURL for eventHub, but it looks like storageAccountKey cant be used anymore?

2020/04/06 16:00:02 [Microsoft.Azure.Diagnostics.LinuxDiagnostic-3.0.127] Invalid config settings given: The storageAccountKey protected setting is not supported and must not be used. Can't proceed, although this install/enable operation is reported as successful so the VM can complete successful startup. 2020/04/06 16:00:02 [Microsoft.Azure.Diagnostics.LinuxDiagnostic-3.0.127] Install,success,0,Invalid config settings given: The storageAccountKey protected setting is not supported and must not be used. Can't proceed, although this install/enable operation is reported as successful so the VM can complete successful startup.

l3ender commented 2 years ago

I received this error when I accidentally used the public settings JSON file for both public and protected config.

In general the error message seems to occur when misconfiguration of extension settings occurs.

loopfish commented 2 years ago

If using v4.0 of the extension, I see from this doc that using storage account key is not supported: https://docs.microsoft.com/en-us/azure/virtual-machines/extensions/diagnostics-linux?toc=%2Fazure%2Fazure-monitor%2Ftoc.json&tabs=azcli#protected-settings

loopfish commented 2 years ago

try this:

"parameters": {

        "accountSasProperties": {
            "type": "object",
            "defaultValue": {
                "signedServices": "b",
                "signedPermission": "rw",
                "signedExpiry": "2122-01-01T00:00:01Z",
                "signedResourceTypes": "o"
            }
        }
)
....

"name": "LinuxDiagnostic",
"type": "extensions",

.... 

"protectedSettings": {
                            "storageAccountName": "[parameters('storageAccountName')]",
                            "storageAccountSasToken": "[listAccountSas([parameters('storageAccountName')], '2018-07-01', parameters('accountSasProperties')).accountSasToken]",
                            "storageAccountEndPoint": "https://core.windows.net"
                        }