Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add directory attribute in file.count metric (filestats receiver) #36274

Open
josepcorrea opened this issue Nov 8, 2024 · 3 comments
Open

add directory attribute in file.count metric (filestats receiver) #36274

josepcorrea opened this issue Nov 8, 2024 · 3 comments
Labels
enhancement New feature or request receiver/filestats

Comments

@josepcorrea
Copy link

josepcorrea commented Nov 8, 2024

Component(s)

receiver/filestats

Is your feature request related to a problem? Please describe.

when you want to count the files in a directory, the metric does not show the directory name, so you cannot distinguish different receivers.

 filestats/1:
   include: /tmp/test1/test*
   metrics:
     file.count:
       enabled: true
   resource_attributes:
     file.path:
       enabled: true

 filestats/2:
   include: /tmp/test2/*
   metrics:
     file.count:
       enabled: true
   resource_attributes:
     file.path:
       enabled: true

Only one metric is generated, so you cannot distinguish between the two:

file_count{host_name="localhost", os_type="linux"}

Describe the solution you'd like

Add the directory attribute to be able to distinguish the different file_count metrics:

file_count{directory="/tmp/test1", host_name="localhost", os_type="linux"}
file_count{directory="/tmp/test2", host_name="localhost", os_type="linux"}

In this way the metrics of both directories can be distinguished.

Describe alternatives you've considered

No response

Additional context

No response

@josepcorrea josepcorrea added enhancement New feature or request needs triage New item requiring triage labels Nov 8, 2024
Copy link
Contributor

github-actions bot commented Nov 8, 2024

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

@atoulme atoulme removed the needs triage New item requiring triage label Nov 10, 2024
@atoulme
Copy link
Contributor

atoulme commented Nov 10, 2024

The file path should be present as a resource attribute. The filestatsreceiver doesn't set the host_name and os_type attributes.

Please see this file for what the receiver generates: https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/receiver/filestatsreceiver/testdata/integration/expected.yaml

@josepcorrea
Copy link
Author

Thanks @atoulme :

Is there a way to display the path directory?

The attributes host_name and os_type are added with processing resourcedetection component like this:

resourcedetection/system:
detectors: ["system"]
system:
hostname_sources: ["os"]
resource_attributes:
host.name:
enabled: true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request receiver/filestats
Projects
None yet
Development

No branches or pull requests

2 participants