Alloy consumes a lot of CPU on Windows

We have installed Grafana Alloy on a large number of servers. It’s working OK overall but on some servers with lots of users logged in and lots of processes running the Agent consumes 25% of CPU, independent of which collectors that are activated in the prometheus.exporter.windows components. No information found in logs.
Is there any configuration that can cause this behaviour?

config.alloy below:

// This reads prometheus files from C:\Program Files\GrafanaLabs\Alloy\textfile_inputs

prometheus.exporter.windows "userpromfiles" {
  enabled_collectors = ["textfile"]
}

// This section initiates scraping of the winserver textfile collector
prometheus.scrape "userpromfiles" {
  scrape_interval = "60s"
  targets    = prometheus.exporter.windows.userpromfiles.targets
  forward_to = [prometheus.relabel.userfiles.receiver]
}

// This section sets the correct "instance" in lowercase (for windows server, the hostname)
prometheus.relabel "userfiles" {
  forward_to = [prometheus.remote_write.testtenant.receiver]
  rule {
    source_labels = ["instance"]
    regex = "(.*?)($|:.*)"
    action = "replace"
    replacement = "$1"
    target_label  = "instance"
  }
  rule {
    source_labels = (["instance"])
    action = "lowercase"
    target_label = "instance"
  } 
}

// ---------------------------- Remote Write section ----------------------------------------
// Testtenant destination, used for testing of metric datastructure
// ALWAYS USE THIS DESTINATION WHEN TESTING
prometheus.remote_write "testtenant" {
  endpoint {
    url = "https://XXXXXX/api/v1/push"
    headers =  {
      "tenantid" = "testtenant",
    }
    tls_config {
       insecure_skip_verify = true
    }
  }
  external_labels = {
    "company"= to_lower(json_path(local.file.env.content,"Company")[0]),
    "envgroup"= to_lower(json_path(local.file.env.content,"envgroup")[0]),
    "env"= to_lower(json_path(local.file.env.content,"env")[0]),
    "system"= to_lower(json_path(local.file.env.content,"system")[0]),
    "dmz"= to_lower(json_path(local.file.env.content,"dmz")[0]),
    "domain"= to_lower(json_path(local.file.env.content,"Domain")[0]),
  }
}

// ----- Consume extra labels from OS (registry) exported by scheduled task -----
local.file "env" {
  filename = "C:\\Program Files\\GrafanaLabs\\Alloy\\env.facts"
  poll_frequency = "60m"
}

Thanks!
Jan

Maybe an alloy config parameter to force it to use limited resources?

Or

Can you ship these text files to a dedicated log server and have alloy installed on only one server?

Everything works fine and looking in the debug log there are no errors. The text file importer is just a way to help users getting their metrics collected in a simple way but this is not used on this server. It’s only used for the basic cpu, memory and os metrics. The same configuration is used on hundered of other servers but there are only on a few this problem shows. Unfortunally it gets Alloy questionable for use by the windows server operators.

1 Like