Skip to content

Commit

Permalink
feat: add exclude config option for excluding host log files
Browse files Browse the repository at this point in the history
  • Loading branch information
obs-gh-mattcotter committed Jan 6, 2025
1 parent 12b4b0b commit a2de44d
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 7 deletions.
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

0 comments on commit a2de44d

Please sign in to comment.