cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Dynatrace OneAgent Azure VM extension installation with Terraform

slelann
Newcomer

Hi,

I suceeded in installing Dynatrace OneAgent to monitor a Kubernetes cluster deployed in Azure Container Service and I would like to do the same on Azure Compute VMs.

It was also successful through Azure Portal UI to set the OneAgent extension to VM but I tried to use Hashicorp Terraform for the same purpose and then I encountered an issue.

My terraform resource file looks like this :

resource "azurerm_virtual_machine_extension" "instance" {
name = "vmname_oneAgentLinux"
location = "westeurope"
resource_group_name = "my_resource_group_name"
virtual_machine_name = "vm_name"
publisher = "dynatrace_publisher"
type = "oneAgentLinux"
type_handler_version = "2.3.0.1"
settings = "{ \"tenantId\" : \"mytenant\" , \"token\" : \"mytoken\" }"
}

Firstly I thought type and type_handler_version were not mandatory (as it was not in azure portal) but I found values indicated in https://www.dynatrace.com/support/help/cloud-platf...

So I've got supposed valid values by requesting azure cli:

az vm extension image list --location westeurope -p dynatrace.ruxit -o table

Name Publisher Version
---------------------- --------------- ---------
oneAgentLinux dynatrace.ruxit 1.150.0.0
oneAgentLinux dynatrace.ruxit 1.151.0.0
oneAgentLinux dynatrace.ruxit 1.151.0.1
oneAgentLinux dynatrace.ruxit 1.99.1.1
oneAgentLinux dynatrace.ruxit 1.99.1.2
oneAgentLinux dynatrace.ruxit 1.99.2.0
oneAgentLinux dynatrace.ruxit 1.99.2.1
oneAgentLinux dynatrace.ruxit 2.2.0.0
oneAgentLinux dynatrace.ruxit 2.2.0.1
oneAgentLinux dynatrace.ruxit 2.2.0.2
oneAgentLinux dynatrace.ruxit 2.3.0.0
oneAgentLinux dynatrace.ruxit 2.3.0.1

But whatever value I use, I get the same error when I apply my terraform :

* azurerm_virtual_machine_extension.instance: compute.VirtualMachineExtensionsClient#CreateOrUpdate: Failure sending request: StatusCode=400 -- Original Error: autorest/azure: Service returned an error. Status=400 Code="InvalidParameter" Message="The value of parameter typeHandlerVersion is invalid." * azurerm_virtual_machine_extension.instance: 1 error(s) occurred:

Did someone here already have same issue with the installation of oneAgent on Azure VMs (not forcibly with terraform but arm or powershell, azure cli... ) ?

Thanks

Sylvain

PS: additional informations : Azure Datacenter Westeurope

Terraform 0.10

terraform provider.azurerm 1.1.2

15 REPLIES 15

slelann
Newcomer

uh uh, just 5 minutes later, I found the trick : type_handler_version parameter value seems to be limited to 2 digits.

So with the value "2.3" my terraform plan goes on... but failed with a new more comprehensible message 🙂

Long running operation terminated with status 'Failed': Code="VMExtensionProvisioningError" Message="VM has reported a failure when processing extension 'oneAgentLinux'. Error message: \"Installation failed: ERROR: Downloading agent installer failed!\"."

Probably a problem of availability of this version of agent in my datacenter location

slelann
Newcomer

Still struggling with versions...

I'm confused with the actual OneAgent version (1.139) and the list of versions provided by Azure extensions (1.99.*, 1.150.*, 1.151.*, 2.2.*, 2.3.*)

Is it resolved ?


nmommaerts
Newcomer

I got the same problem, but I had entered my Azure TenantID in the tenantid field, while it should be the Dynatrace environment id.


S_Wilhelm
Observer

 

Just in case someone else is looking for a way to set additional properties, like host tags, etc.

You can provide even more properties by using the installerArguments property:

\"installerArguments\":\"--set-host-tag=stage=dev --set-host-tag=application=example_application --set-monitoring-mode=fullstack\"

 

Kind regards

Sebastian

Hi @S_Wilhelm ,

 

I tried your suggestion for installerArguments, but it is not working for me

This is my code:

resource "azurerm_virtual_machine_extension" "dynatrace_extension" {
  name                      = "DynatraceOneAgent"
  virtual_machine_id        = data.azurerm_virtual_machine.example.id
  publisher                 = "dynatrace.ruxit"
  type                      = "oneAgentLinux"
  type_handler_version      = "2.3"
  settings                  = "{ \"tenantId\" : \"tenantId\" , \"token\" : \"token\", \"installerArguments\": \"--set-host-tag=stage=DacaDev --set-monitoring-mode=discovery --set-app-log-content-access=true INSTALL_PATH=/mnt/dynatrace/agent\" }"

}

This is the implementation, that is still running on my side. Good luck:

resource "azurerm_virtual_machine_extension" "dynatrace_oneagent" {
name = "dynatrace_oneAgentLinux"
virtual_machine_id = azurerm_linux_virtual_machine.cloud-init-azdevops.id
publisher = "dynatrace.ruxit"
type = "oneAgentLinux"
type_handler_version = "2.3"
settings = "{ \"tenantId\" : \"${var.environment_id}\" , \"token\" : \"${var.environment_api_token}\", \"server\":\"https://${var.environment_ag_url}/e/${var.environment_id}/api\", \"enableLogAnalytics\":\"yes\", \"installerArguments\":\"--set-host-group=MYPROJECT-${var.environment_name} --set-monitoring-mode=infra-only --set-host-tag=application=MYPROJECT --set-host-tag=stage=${var.environment_name} --set-host-tag=datacenter=AZURE\" }"
tags = local.tags
auto_upgrade_minor_version = true
depends_on = [
azurerm_linux_virtual_machine.cloud-init-azdevops
]
}

Thanks.

I am not sure why installerArguments are not working for me 

Hmmm strange. Is your INSTALL_PATH accessible for the installation?

Is it possible to get more logs from the installation to get more insights, why it failed?

Kind regards, Sebastian

I am not sure, but the thing is that it is not taking any setup from installerArguments.
It's not just install path, it's not setting host group, host tags, nothing

this is my code and for me it looks like yours:

resource "azurerm_virtual_machine_extension" "dynatrace_extension" {
  name                 = "DynatraceOneAgentLinux"
  virtual_machine_id   = data.azurerm_virtual_machine.example.id
  publisher            = "dynatrace.ruxit"
  type                 = "oneAgentLinux"
  type_handler_version = "2.3"
  settings             = "{ \"tenantId\" : \"${var.environment_id}\" , \"token\" : \"${var.access_token}\",\"enableLogAnalytics\":\"yes\", \"installerArguments\":\"--set-host-group=sre-test --set-monitoring-mode=discovery --set-host-tag=tool=terraform --set-host-tag=stage=TEST\" }"
  tags = {
    environment = "test"
    tool        = "terraform"
  }
}

I also don't see any relevant difference in the code.And without the logs, it's hard to debug anything.

Seems like you need to raise a support ticket for Dynatrace. Afaik Terraform isn't supported by Dynatrace. But it's worth a try.

danijela
Participant

Guys,

Did you resolve this problem?

I am trying the same but I am getting an error:
API Response:

│ ----[start]----
│ {
│ "startTime": "2024-07-02T15:00:42.6313686+00:00",
│ "endTime": "2024-07-02T15:01:13.2250994+00:00",
│ "status": "Failed",
│ "error": {
│ "code": "VMExtensionProvisioningError",
│ "message": "VM has reported a failure when processing extension 'vmdacatest01' (publisher 'dynatrace.ruxit' and type 'oneAgentLinux'). Error message: 'Installation failed: ERROR: Agent installer failed'. More information on troubleshooting is available at https://aka.ms/vmextensionlinuxtroubleshoot. "
│ },
│ "name": "5970bb69-741d-455c-b39d-3ec85bb6c31e"
│ }
│ -----[end]-----


│ with azurerm_virtual_machine_extension.dynatrace_extension,

danijela
Participant

I resolved the issue that I had, here is the code that is working for me:

resource "azurerm_virtual_machine_extension" "dynatrace_extension" {
  name                       = "DynatraceOneAgentLinux"
  virtual_machine_id         = data.azurerm_virtual_machine.example.id
  publisher                  = "dynatrace.ruxit"
  type                       = "oneAgentLinux"
  type_handler_version       = "2.3"
  settings                   = <<SETTINGS
    {
        "tenantId": "${var.environment_id}",
        "token": "${var.access_token}",
        "installerArguments": "--set-monitoring-mode=infra-only --set-watchdog-portrange=60000:60100 INSTALL_PATH=/dynatrace/opt/dynatrace/oneagent LOG_PATH=/dynatrace/var/log/dynatrace/oneagent DATA_STORAGE=/dynatrace/var/lib/dynatrace/oneagent/datastorage",
        "enableLogAnalytics": "true"
    }
SETTINGS
  auto_upgrade_minor_version = true
  tags = {
    environment = "test"
    tool        = "terraform"
  }
}

Featured Posts