filestat_exporter icon indicating copy to clipboard operation
filestat_exporter copied to clipboard

Pattern Order Affects File Counts

Open mmranger opened this issue 3 years ago • 1 comments

This is one of those edge case things that might not affect many instances. By the way this exporter is a lifesaver for a very specific problem I have been dealing with.

Problem: The physical order of the patterns in the config file seems to affect the count.

Example: yaml

...
  files:
  - patterns:
    -  "/main_dir/*"
    -  "/main_dir/Troubled_file*"
...

Result: main_dir count will be accurate, but the specific file pattern within main_dir are grossly under counted. While ls -l /main_dir/Troubled_file* | wc -l would show around 500 of the specific files exporter would show ~0-1 sometimes 10.

Fix: yaml

...
  files:
  - patterns:
    -  "/main_dir/Troubled_file*"
    -  "/main_dir/*"
...

Result fix: main_dir file count and specific file pattern within main_dir seem to be more accurate.

Probably not worth a code change, but maybe a note in the documentation.

mmranger avatar Oct 07 '21 21:10 mmranger

Hello,

Indeed, that is the expacted behavior as two competing patterns will match files in different orders and thus, file matches are counted for one or the other.

The initial idea was to detect when a pattern is unused or redundant. But the variations caused by parallelism, which is an implementation detail, more or less makes it impractical. I guess, I'll make them report the number of files matching the pattern enven if it was already matched by another, it will be more intuitive.

Thanks for the feedbaack and pointing this out.

michael-doubez avatar Oct 10 '21 19:10 michael-doubez

Fixed in v0.3.6

michael-doubez avatar Mar 01 '23 18:03 michael-doubez