Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions config/examples/streaming_file_tail.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Streaming File Input Example
# ============================
# This example demonstrates using streaming_file to tail a log file,
# similar to 'tail -F' but with automatic rotation and truncation handling.
#
# Quick Test:
# 1. Create a test file:
# echo "hello world" > /tmp/test.log
#
# 2. Run bento:
# bento -c config/examples/streaming_file_tail.yaml
#
# 3. In another terminal, append lines:
# echo "new line 1" >> /tmp/test.log
# echo "new line 2" >> /tmp/test.log
#
# Performance Note:
# By default, polling-only mode is used (disable_fsnotify: true) which is
# more CPU-efficient for high-volume log files. For lower latency on
# low-volume files, set disable_fsnotify: false.

input:
streaming_file:
path: /tmp/test.log
poll_interval: 200ms # How often to check for new data
disable_fsnotify: true # true = polling only (CPU efficient)
# false = use fsnotify (lower latency)

pipeline:
processors:
- mapping: |
# Add timestamp to each line
root.timestamp = now()
root.content = content().string()
root.metadata = @

output:
stdout:
codec: lines
13 changes: 13 additions & 0 deletions internal/impl/io/inode_other.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//go:build !unix

package io

import "os"

// inodeOf extracts the inode from a FileInfo on non-Unix systems
// On Windows and other non-Unix systems, inodes are not available
// Returns (0, false) to indicate inode support is not available
// Rotation detection will fall back to size-based heuristics
func inodeOf(_ os.FileInfo) (uint64, bool) {
return 0, false
}
17 changes: 17 additions & 0 deletions internal/impl/io/inode_unix.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//go:build unix

package io

import (
"os"
"syscall"
)

// inodeOf extracts the inode from a FileInfo on Unix-like systems
// Returns (inode, true) if inode is available, (0, false) otherwise
func inodeOf(fi os.FileInfo) (uint64, bool) {
if st, ok := fi.Sys().(*syscall.Stat_t); ok {
return st.Ino, true
}
return 0, false
}
Loading