grafana / alloy

OpenTelemetry Collector distribution with programmable pipelines
https://grafana.com/oss/alloy
Apache License 2.0
1.45k stars 214 forks source link

Error reading directory: C:\Program Files\GrafanaLabs\Alloy\textfile_inputs #1488

Open fluidum opened 3 months ago

fluidum commented 3 months ago

What's wrong?

After installing Grafana Alloy on Windows I noticed once a minute logged errors.

When I created directory C:\Program Files\GrafanaLabs\Alloy\textfile_inputs the error dissapeared.

Steps to reproduce

cd "%TEMP%" && powershell -c Invoke-WebRequest "https://storage.googleapis.com/cloud-onboarding/alloy/scripts/install-windows.ps1" -OutFile "install-windows.ps1" && powershell -executionpolicy Bypass -File ".\install-windows.ps1" -GCLOUD_HOSTED_METRICS_URL "https://<GCLOUD_HOSTED_METRICS_URL>.grafana.net/api/prom/push" -GCLOUD_HOSTED_METRICS_ID ">GCLOUD_HOSTED_METRICS_ID>" -GCLOUD_SCRAPE_INTERVAL "60s" -GCLOUD_HOSTED_LOGS_URL "https://<GCLOUD_HOSTED_LOGS_ID>/loki/api/v1/push" -GCLOUD_HOSTED_LOGS_ID "<GCLOUD_HOSTED_LOGS_ID>" -GCLOUD_RW_API_KEY "<GCLOUD_RW_API_KEY>"

System information

Windows 10 Enterprise 22H2 x64

Software version

Grafana Alloy v1.3.0

Configuration

prometheus.exporter.self "alloy_check" { }

discovery.relabel "alloy_check" {
  targets = prometheus.exporter.self.alloy_check.targets

  rule {
    target_label = "instance"
    replacement  = constants.hostname
  }

  rule {
    target_label = "alloy_hostname"
    replacement  = constants.hostname
  }

  rule {
    target_label = "job"
    replacement  = "integrations/alloy-check"
  }
}

prometheus.scrape "alloy_check" {
  targets    = discovery.relabel.alloy_check.output
  forward_to = [prometheus.relabel.alloy_check.receiver]  

  scrape_interval = "60s"
}

prometheus.relabel "alloy_check" {
  forward_to = [prometheus.remote_write.metrics_service.receiver]

  rule {
    source_labels = ["__name__"]
    regex         = "(prometheus_target_sync_length_seconds_sum|prometheus_target_scrapes_.*|prometheus_target_interval.*|prometheus_sd_discovered_targets|alloy_build.*|prometheus_remote_write_wal_samples_appended_total|process_start_time_seconds)"
    action        = "keep"
  }
}

prometheus.remote_write "metrics_service" {
  endpoint {
    url = "https://<url>.grafana.net/api/prom/push"

    basic_auth {
      username = "<username>"
      password = "<password>"
    }
  }
}

loki.write "grafana_cloud_loki" {
  endpoint {
    url = "https://<url>.grafana.net/loki/api/v1/push"

    basic_auth {
      username = "<username>"
      password = "<password>"
    }
  }
}
prometheus.exporter.windows "integrations_windows_exporter" {
  enabled_collectors = ["cpu", "cs", "logical_disk", "net", "os", "service", "system", "textfile", "time", "diskdrive"]
}
discovery.relabel "integrations_windows_exporter" {
  targets = prometheus.exporter.windows.integrations_windows_exporter.targets

  rule {
    target_label = "job"
    replacement  = "integrations/windows_exporter"
  }

  rule {
    target_label = "instance"
    replacement  = constants.hostname
  }
}
prometheus.scrape "integrations_windows_exporter" {
  targets    = discovery.relabel.integrations_windows_exporter.output
  forward_to = [prometheus.relabel.integrations_windows_exporter.receiver]
  job_name   = "integrations/windows_exporter"
}
prometheus.relabel "integrations_windows_exporter" {
  forward_to = [prometheus.remote_write.metrics_service.receiver]

  rule {
    source_labels = ["volume"]
    regex         = "HarddiskVolume.*"
    action        = "drop"
  }

  rule {
    action = "keep"
    regex = "up|windows_cpu_interrupts_total|windows_cpu_time_total|windows_cs_hostname|windows_cs_logical_processors|windows_cs_physical_memory_bytes|windows_disk_drive_status|windows_logical_disk_avg_read_requests_queued|windows_logical_disk_avg_write_requests_queued|windows_logical_disk_free_bytes|windows_logical_disk_idle_seconds_total|windows_logical_disk_read_bytes_total|windows_logical_disk_read_seconds_total|windows_logical_disk_reads_total|windows_logical_disk_size_bytes|windows_logical_disk_write_bytes_total|windows_logical_disk_write_seconds_total|windows_logical_disk_writes_total|windows_net_bytes_received_total|windows_net_bytes_sent_total|windows_net_packets_outbound_discarded_total|windows_net_packets_outbound_errors_total|windows_net_packets_received_discarded_total|windows_net_packets_received_errors_total|windows_net_packets_received_unknown_total|windows_os_info|windows_os_paging_limit_bytes|windows_os_physical_memory_free_bytes|windows_os_timezone|windows_service_status|windows_system_context_switches_total|windows_system_processor_queue_length|windows_system_system_up_time|windows_time_computed_time_offset_seconds|windows_time_ntp_round_trip_delay_seconds"
    source_labels = ["__name__"]
  }
}

loki.process "logs_integrations_windows_exporter_application" {
  forward_to = [loki.write.grafana_cloud_loki.receiver]

  stage.json {
    expressions = {
      level  = "levelText",
      source = "source",
    }
  }

  stage.labels {
    values = {
      level  = "",
      source = "",
    }
  }
}
loki.relabel "logs_integrations_windows_exporter_application" {
  forward_to = [loki.process.logs_integrations_windows_exporter_application.receiver]

  rule {
    source_labels = ["computer"]
    target_label  = "agent_hostname"
  }
}
loki.source.windowsevent "logs_integrations_windows_exporter_application" {
  locale                 = 1033
  eventlog_name          = "Application"
  bookmark_path          = "./bookmarks-app.xml"
  poll_interval          = "0s"
  use_incoming_timestamp = true
  forward_to             = [loki.relabel.logs_integrations_windows_exporter_application.receiver]
  labels                 = {
    instance = constants.hostname,
    job      = "integrations/windows_exporter",
  }
}
loki.process "logs_integrations_windows_exporter_system" {
  forward_to = [loki.write.grafana_cloud_loki.receiver]

  stage.json {
    expressions = {
      level  = "levelText",
      source = "source",
    }
  }

  stage.labels {
    values = {
      level  = "",
      source = "",
    }
  }
}
loki.relabel "logs_integrations_windows_exporter_system" {
  forward_to = [loki.process.logs_integrations_windows_exporter_system.receiver]

  rule {
    source_labels = ["computer"]
    target_label  = "agent_hostname"
  }
}
loki.source.windowsevent "logs_integrations_windows_exporter_system" {
  locale                 = 1033
  eventlog_name          = "System"
  bookmark_path          = "./bookmarks-sys.xml"
  poll_interval          = "0s"
  use_incoming_timestamp = true
  forward_to             = [loki.relabel.logs_integrations_windows_exporter_system.receiver]
  labels                 = {
    instance = constants.hostname,
    job      = "integrations/windows_exporter",
  }
}

loki.source.windowsevent "applocker_logs" {
  eventlog_name = "Microsoft-Windows-AppLocker/EXE and DLL"
  xpath_query = "*"
  forward_to             = [loki.relabel.logs_integrations_windows_exporter_system.receiver]
  bookmark_path          = "./bookmarks-applocker-exe.xml"
  poll_interval          = "0s"
  use_incoming_timestamp = true
  labels                 = {
    instance = constants.hostname,
    job      = "integrations/windows_exporter",
  }
}

Logs

<Data>ts=2024-08-19T10:23:27.2323548Z level=error msg="Error reading directory: C:\\Program Files\\GrafanaLabs\\Alloy\\textfile_inputs" component_path=/ component_id=prometheus.exporter.windows.integrations_windows_exporter collector=textfile err="CreateFile C:\\Program Files\\GrafanaLabs\\Alloy\\textfile_inputs: The system cannot find the file specified." </Data>
Kherm13 commented 3 months ago

you have the textfile collector enabled in your integrations_windows_exporter. If you aren't using it, you can remove it and the errors should go away. Or, create the directory on the hosts that are throwing the error. It basically is trying to read that dir and if it can't find it, will throw the error.

prometheus.exporter.windows "integrations_windows_exporter" { enabled_collectors = ["cpu", "cs", "logical_disk", "net", "os", "service", "system", "**textfile**", "time", "diskdrive"] }

fluidum commented 3 months ago

Interesting detail, yesterday I installed default Alloy and appended it with config parts that were required from Grafana Cloud, but if I check now into Cloud then currently there is no clue of textfile key in that config array, except that applocker_logs part.

github-actions[bot] commented 2 months ago

This issue has not had any activity in the past 30 days, so the needs-attention label has been added to it. If the opened issue is a bug, check to see if a newer release fixed your issue. If it is no longer relevant, please feel free to close this issue. The needs-attention label signals to maintainers that something has fallen through the cracks. No action is needed by you; your issue will be kept open and you do not have to respond to this comment. The label will be removed the next time this job runs if there is new activity. Thank you for your contributions!