vector icon indicating copy to clipboard operation
vector copied to clipboard

Vector unable to keep number of open files within reasonable limit when processing large amount of small files

Open seaworld008 opened this issue 3 years ago • 3 comments

A note for the community

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Problem

Vector unable to keep number of open files within reasonable limit when processing large amount of small files

I am using Vector to ingest a log directory containing a large number of small files. I have set the operating system's open file limit to 131072, but Vector seems to not properly close the files it has finished processing. I have attempted to add an ignore_older parameter in the Vector configuration file to disregard some older files, but the issue persists.

I noticed that when a log file reaches 100M, my system automatically renames it and creates a new log file. This means that at any given time, there is a large number of small files to be processed. I suspect this might be the root of the issue.

Here is the relevant part of my Vector configuration file:

# Set global options
data_dir = "/var/lib/vector"

# Define data source 1
[sources.gxlndx_php_runtime]
  type = "file" # Use file source
  read_from = "beginning"  # First-time configuration to read from the beginning, can also be configured as 'end' to read from the end
  multiline.start_pattern = "^-"
  multiline.mode = "halt_before"  # In multiline mode, if the model encounters an incomplete line, it will stop reading and return the incomplete line as separate input for line-by-line processing or specific operations.
  multiline.condition_pattern = "^-"
  multiline.timeout_ms = 1000
  include = [
            "/data/k8s/gxjwxt-prod-gxlndx-runtimedir-pvc-pvc-4c571e52-1ec0-4d25-9457-407d61a8dc37/log/*/*.log"
            ]   # Include all .log files
  ignore_older = 604800   # Do not read the file if it has not been updated within 7 days

  [sources.gxlndx_php_runtime.fingerprinting]
  strategy = "device_and_inode"
  ignore_not_found = true  # When Vector cannot find a file (perhaps because the file has been deleted or renamed), it will ignore this error and continue processing other files.

# Define data source 2
[sources.gxlndx_php_runtime_wxpay]
  type = "file" # Use file source
  read_from = "beginning"  # First-time configuration to read from the beginning, can also be configured as 'end' to read from the end
  multiline.start_pattern = "^array \\("
  multiline.mode = "halt_before"  # In multiline mode, if the model encounters an incomplete line, it will stop reading and return the incomplete line as separate input for line-by-line processing or specific operations.
  multiline.condition_pattern = "^array \\("
  multiline.timeout_ms = 1000
  include = [
            "/data/k8s/gxjwxt-prod-gxlndx-runtimedir-pvc-pvc-4c571e52-1ec0-4d25-9457-407d61a8dc37/log/wxpay/*/*/*.log",
            "/data/k8s/gxjwxt-prod-gxlndx-runtimedir-pvc-pvc-4c571e52-1ec0-4d25-9457-407d61a8dc37/log/invoice/*/*/*.log"
            ]   # Include all .log files
  ignore_older = 604800   # Do not read the file if it has not been updated within 7 days

  [sources.gxlndx_php_runtime_wxpay.fingerprinting]
  strategy = "device_and_inode"
  ignore_not_found = true  # When Vector cannot find a file (perhaps because the file has been deleted or renamed), it will ignore this error and continue processing other files.

# Define data transformation (there is no transformation here, so it's an empty transformation)
[transforms.my_transform]
  type = "remap" # Use remap transformation
  inputs = ["gxlndx_php_runtime","gxlndx_php_runtime_wxpay"] # Input from the source defined above
  source = ""

Here is the error message I am encountering when running Vector:

Jul 21 15:10:50 k8s-master3 vector[17832]: 2023-07-21T07:10:50.512832Z  INFO source{component_kind="source" component_id=gxlndx_php_runtime component_type=file component_name=gxlndx_php_runtime}:file_server: vector::internal_events::file::source: Resuming to watch file. file=/data/k8s/gxjwxt-prod-gxlndx-runtimedir-pvc-pvc-4c571e52-1ec0-4d25-9457-407d61a8dc37/log/202307/1689640152-18.log file_position=79802896
Jul 21 15:10:50 k8s-master3 vector[17832]: 2023-07-21T07:10:50.512861Z ERROR source{component_kind="source" component_id=gxlndx_php_runtime component_type=file component_name=gxlndx_php_runtime}:file_server: vector::internal_events::file::source: Internal log [Failed reading file for fingerprinting.] has been suppressed 4744 times.
Jul 21 15:10:50 k8s-master3 vector[17832]: 2023-07-21T07:10:50.512864Z ERROR source{component_kind="source" component_id=gxlndx_php_runtime component_type=file component_name=gxlndx_php_runtime}:file_server: vector::internal_events::file::source: Failed reading file for fingerprinting. file=/data/k8s/gxjwxt-prod-gxlndx-runtimedir-pvc-pvc-4c571e52-1ec0-4d25-9457-407d61a8dc37/log/202307/1689640195-18.log error=Too many open files (os error 24) error_code="reading_fingerprint" error_type="reader_failed" stage="receiving" internal_log_rate_limit=true
Jul 21 15:10:50 k8s-master3 vector[17832]: 2023-07-21T07:10:50.512880Z ERROR source{component_kind="source" component_id=gxlndx_php_runtime component_type=file component_name=gxlndx_php_runtime}:file_server: vector::internal_events::file::source: Internal log [Failed reading file for fingerprinting.] is being suppressed to avoid flooding.
Jul 21 15:10:51 k8s-master3 vector[17832]: 2023-07-21T07:10:51.043427Z ERROR vector::internal_events::file::source: Internal log [Failed writing checkpoints.] has been suppressed 5 times.
Jul 21 15:10:51 k8s-master3 vector[17832]: 2023-07-21T07:10:51.043444Z ERROR vector::internal_events::file::source: Failed writing checkpoints. error=Too many open files (os error 24) error_code="writing_checkpoints" error_type="writer_failed" stage="receiving" internal_log_rate_limit=true
Jul 21 15:10:51 k8s-master3 vector[17832]: 2023-07-21T07:10:51.506900Z ERROR source{component_kind="source" component_id=gxlndx_php_runtime component_type=file component_name=gxlndx_php_runtime}:file_server: vector::internal_events::file::source: Internal log [Failed to glob path.] is being suppressed to avoid flooding.
Jul 21 15:10:51 k8s-master3 vector[17832]: 2023-07-21T07:10:51.507265Z  INFO source{component_kind="source" component_id=gxlndx_php_runtime component_type=file component_name=gxlndx_php_runtime}:file_server: vector::internal_events::file::source: Stopped watching file. file=/data/k8s/gxjwxt-prod-gxlndx-runtimedir-pvc-pvc-4c571e52-1ec0-4d25-9457-407d61a8dc37/log/202307/1689640152-18.log
Jul 21 15:10:51 k8s-master3 vector[17832]: 2023-07-21T07:10:51.606989Z  INFO source{component_kind="source" component_id=gxlndx_php_runtime_wxpay component_type=file component_name=gxlndx_php_runtime_wxpay}:file_server: vector::internal_events::file::source: Found new file to watch. file=/data/k8s/gxjwxt-prod-gxlndx-runtimedir-pvc-pvc-4c571e52-1ec0-4d25-9457-407d61a8dc37/log/wxpay/2023/202301/03.log
Jul 21 15:10:51 k8s-master3 vector[17832]: 2023-07-21T07:10:51.607032Z ERROR source{component_kind="source" component_id=gxlndx_php_runtime_wxpay component_type=file component_name=gxlndx_php_runtime_wxpay}:file_server: vector::internal_events::file::source: Internal log [Failed reading file for fingerprinting.] has been suppressed 53 times.
Jul 21 15:10:51 k8s-master3 vector[17832]: 2023-07-21T07:10:51.607036Z ERROR source{component_kind="source" component_id=gxlndx_php_runtime_wxpay component_type=file component_name=gxlndx_php_runtime_wxpay}:file_server: vector::internal_events::file::source: Failed reading file for fingerprinting. file=/data/k8s/gxjwxt-prod-gxlndx-runtimedir-pvc-pvc-4c571e52-1ec0-4d25-9457-407d61a8dc37/log/wxpay/2023/202303/16.log error=Too many open files (os error 24) error_code="reading_fingerprint" error_type="reader_failed" stage="receiving" internal_log_rate_limit=true
Jul 21 15:10:51 k8s-master3 vector[17832]: 2023-07-21T07:10:51.607052Z ERROR source{component_kind="source" component_id=gxlndx_php_runtime_wxpay component_type=file component_name=gxlndx_php_runtime_wxpay}:file_server: vector::internal_events::file::source: Internal log [Failed reading file for fingerprinting.] is being suppressed to avoid flooding.
Jul 21 15:10:52 k8s-master3 vector[17832]: 2023-07-21T07:10:52.044160Z ERROR vector::internal_events::file::source: Internal log [Failed writing checkpoints.] is being suppressed to avoid flooding.
Jul 21 15:10:52 k8s-master3 vector[17832]: 2023-07-21T07:10:52.232820Z  INFO source{component_kind="source" component_id=gxlndx_php_runtime component_type=file component_name=gxlndx_php_runtime}:file_server: vector::internal_events::file::source: Stopped watching file. file=/data/k8s/gxjwxt-prod-gxlndx-runtimedir-pvc-pvc-4c571e52-1ec0-4d25-9457-407d61a8dc37/log/202307/1689639921-18.log
Jul 21 15:10:52 k8s-master3 vector[17832]: 2023-07-21T07:10:52.261672Z  INFO source{component_kind="source" component_id=gxlndx_php_runtime component_type=file component_name=gxlndx_php_runtime}:file_server: vector::internal_events::file::source: Stopped watching file. file=/data/k8s/gxjwxt-prod-gxlndx-runtimedir-pvc-pvc-4c571e52-1ec0-4d25-9457-407d61a8dc37/log/202307/1689639227-18.log

I hope you can help me solve this problem. Thank you!

Configuration

# Set global options
data_dir = "/var/lib/vector"

# Define data source 1
[sources.gxlndx_php_runtime]
  type = "file" # Use file source
  read_from = "beginning"  # First-time configuration to read from the beginning, can also be configured as 'end' to read from the end
  multiline.start_pattern = "^-"
  multiline.mode = "halt_before"  # In multiline mode, if the model encounters an incomplete line, it will stop reading and return the incomplete line as separate input for line-by-line processing or specific operations.
  multiline.condition_pattern = "^-"
  multiline.timeout_ms = 1000
  include = [
            "/data/k8s/gxjwxt-prod-gxlndx-runtimedir-pvc-pvc-4c571e52-1ec0-4d25-9457-407d61a8dc37/log/*/*.log"
            ]   # Include all .log files
  ignore_older = 604800   # Do not read the file if it has not been updated within 7 days

  [sources.gxlndx_php_runtime.fingerprinting]
  strategy = "device_and_inode"
  ignore_not_found = true  # When Vector cannot find a file (perhaps because the file has been deleted or renamed), it will ignore this error and continue processing other files.

# Define data source 2
[sources.gxlndx_php_runtime_wxpay]
  type = "file" # Use file source
  read_from = "beginning"  # First-time configuration to read from the beginning, can also be configured as 'end' to read from the end
  multiline.start_pattern = "^array \\("
  multiline.mode = "halt_before"  # In multiline mode, if the model encounters an incomplete line, it will stop reading and return the incomplete line as separate input for line-by-line processing or specific operations.
  multiline.condition_pattern = "^array \\("
  multiline.timeout_ms = 1000
  include = [
            "/data/k8s/gxjwxt-prod-gxlndx-runtimedir-pvc-pvc-4c571e52-1ec0-4d25-9457-407d61a8dc37/log/wxpay/*/*/*.log",
            "/data/k8s/gxjwxt-prod-gxlndx-runtimedir-pvc-pvc-4c571e52-1ec0-4d25-9457-407d61a8dc37/log/invoice/*/*/*.log"
            ]   # Include all .log files
  ignore_older = 604800   # Do not read the file if it has not been updated within 7 days

  [sources.gxlndx_php_runtime_wxpay.fingerprinting]
  strategy = "device_and_inode"
  ignore_not_found = true  # When Vector cannot find a file (perhaps because the file has been deleted or renamed), it will ignore this error and continue processing other files.

# Define data transformation (there is no transformation here, so it's an empty transformation)
[transforms.my_transform]
  type = "remap" # Use remap transformation
  inputs = ["gxlndx_php_runtime","gxlndx_php_runtime_wxpay"] # Input from the source defined above
  source = ""

Version

vector 0.31.0 (x86_64-unknown-linux-gnu 0f13b22 2023-07-06 13:52:34.591204470)

Debug Output

No response

Example Data

No response

Additional Context

No response

References

No response

seaworld008 avatar Jul 21 '23 07:07 seaworld008

Thanks for opening this @Haiyang008 ! I think it is the same as https://github.com/vectordotdev/vector/issues/14818. Would you agree?

jszwedko avatar Jul 21 '23 15:07 jszwedko

Closing since this seems to be a duplicate of https://github.com/vectordotdev/vector/issues/14818 but appreciate all of the additional context you included here!

jszwedko avatar Jul 21 '23 19:07 jszwedko

Yes, I encountered the same problems as him; But currently, I haven't solved this problem by debugging the vector; I tested using filebeat to collect data without this issue at all. Perhaps we can take a look at how filebeat solves this problem; Thank you very much for your reply. Your reply has been very useful to me, and I look forward to a more perfect vector!

seaworld008 avatar Jul 28 '23 07:07 seaworld008