Skip to content

feat: add exclude config option for excluding host log files #152

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

Merged
merged 1 commit into from
Jan 6, 2025
Merged
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
1 change: 1 addition & 0 deletions internal/config/configschema.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
type HostMonitoringLogsConfig struct {
Enabled bool `yaml:"enabled" mapstructure:"enabled"`
Include []string `yaml:"include,omitempty" mapstructure:"include"`
Exclude []string `yaml:"exclude,omitempty" mapstructure:"exclude"`
}

type HostMonitoringHostMetricsConfig struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ receivers:
- /hostfs/var/log/**/*.log
- /hostfs/var/log/syslog
{{- end }}
{{- if .Logs.Exclude }}
exclude:
{{- range .Logs.Exclude }}
- {{ . }}
{{- end }}
{{- end }}
include_file_path: true
storage: file_storage
retry_on_failure:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ receivers:
- /var/log/**/*.log
- /var/log/syslog
{{- end }}
{{- if .Logs.Exclude }}
exclude:
{{- range .Logs.Exclude }}
- {{ . }}
{{- end }}
{{- end }}
include_file_path: true
storage: file_storage
retry_on_failure:
Expand Down
15 changes: 14 additions & 1 deletion packaging/macos/connections/host_monitoring/logs.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
receivers:
filelog/host_monitoring:
include: [/var/log/**/*.log]
include:
{{- if .Logs.Include }}
{{- range .Logs.Include }}
- {{ . }}
{{- end }}
{{- else }}
- /var/log/**/*.log
{{- end }}
{{- if .Logs.Exclude }}
exclude:
{{- range .Logs.Exclude }}
- {{ . }}
{{- end }}
{{- end }}
include_file_path: true
storage: file_storage
retry_on_failure:
Expand Down
17 changes: 11 additions & 6 deletions scripts/install_mac.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ while [ $# -gt 0 ]; do
--metrics_enabled)
METRICS_ENABLED="$arg"
;;
--setup_launch_daemon)
SETUP_LAUNCH_DAEMON="$arg"
;;
*)
echo "Unknown option: $opt"
exit 1
Expand Down Expand Up @@ -114,12 +117,14 @@ sudo ln -sf $observeagent_install_dir/observe-agent /usr/local/bin

echo "Observe agent successfully installed to $observeagent_install_dir"

# Install the launchd agent
echo "Installing $service_name as a LaunchDaemon. This may ask for your password..."
sudo cp -f $tmp_dir/observe-agent.plist /Library/LaunchDaemons/$service_name.plist
sudo chown root:wheel /Library/LaunchDaemons/$service_name.plist
sudo launchctl load -w /Library/LaunchDaemons/$service_name.plist
sudo launchctl kickstart "system/$service_name"
# Install the launchd agent unless the variable is specified to false
if [ -z "$SETUP_LAUNCH_DAEMON" ] || [[ "$(echo "$SETUP_LAUNCH_DAEMON" | tr '[:upper:]' '[:lower:]')" == "true" ]]; then
echo "Installing $service_name as a LaunchDaemon. This may ask for your password..."
sudo cp -f $tmp_dir/observe-agent.plist /Library/LaunchDaemons/$service_name.plist
sudo chown root:wheel /Library/LaunchDaemons/$service_name.plist
sudo launchctl load -w /Library/LaunchDaemons/$service_name.plist
sudo launchctl kickstart "system/$service_name"
fi

echo
echo "---"
Expand Down
Loading