Component(s)
loki.source.file
What's wrong?
When using the following config
loki.source.file "log_scrape_iis" {
targets = [{
__address__ = "localhost",
__path__ = string.format("%s\\inetpub\\logs\\LogFiles\\W3SVC1\\u_ex*.log", sys.env("SystemDrive")),
instance = constants.hostname,
job = "integrations/iis",
site = "Default Web Site",
},
]
file_match {
enabled = true
sync_period = "15m"
}
forward_to = [loki.process.logs_integrations_integrations_iis_process.receiver]
}
to scrape IIS log files from the path C:\inetpub\logs\LogFiles\W3SVC1, it causes a high CPU usage for the Alloy process.
Here's the flame graph from the cpu.pprof profile generated using Invoke-WebRequest -Uri "http://localhost:12345/debug/pprof/profile?seconds=30" -OutFile "cpu.pprof":
This is the flame graph from a server where the C:\inetpub\logs\LogFiles\W3SVC1 directory contains ~1.100 logfiles with a filesize of 5-10MB each.
It shows that significant time is spent tailing the files.
It seems that the tailer code calls createFile, GetFileInformationByHandle and CloseHandle indefinitely in a loop for every file causing the high CPU usage.
Steps to reproduce
- Use a Windows Server with IIS and some traffic (so logs are generated)
- Add the above
loki.source.file module to the Alloy config
- Start alloy
- Watch the process CPU usage
System information
Windows Server 2022 Datacenter
Software version
Grafana Alloy v1.16.1
Configuration
loki.source.file "log_scrape_iis" {
targets = [{
__address__ = "localhost",
__path__ = string.format("%s\\inetpub\\logs\\LogFiles\\W3SVC1\\u_ex*.log", sys.env("SystemDrive")),
instance = constants.hostname,
job = "integrations/iis",
site = "Default Web Site",
},
]
file_match {
enabled = true
sync_period = "15m"
}
forward_to = [loki.process.logs_integrations_integrations_iis_process.receiver]
}
Logs
Tip
React with 👍 if this issue is important to you.
Component(s)
loki.source.file
What's wrong?
When using the following config
to scrape IIS log files from the path
C:\inetpub\logs\LogFiles\W3SVC1, it causes a high CPU usage for the Alloy process.Here's the flame graph from the
cpu.pprofprofile generated usingInvoke-WebRequest -Uri "http://localhost:12345/debug/pprof/profile?seconds=30" -OutFile "cpu.pprof":This is the flame graph from a server where the
C:\inetpub\logs\LogFiles\W3SVC1directory contains ~1.100 logfiles with a filesize of 5-10MB each.It shows that significant time is spent tailing the files.
It seems that the tailer code calls
createFile,GetFileInformationByHandleandCloseHandleindefinitely in a loop for every file causing the high CPU usage.Steps to reproduce
loki.source.filemodule to the Alloy configSystem information
Windows Server 2022 Datacenter
Software version
Grafana Alloy v1.16.1
Configuration
Logs
Tip
React with 👍 if this issue is important to you.