Skip to content

fix: move filestats receiver into host_monitoring connection #61

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 2 commits into from
Jul 25, 2024
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# build
agent
output-logs
./observe-agent
/observe-agent
dist/
agent.exe
agent.exe~
Expand Down
2 changes: 2 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ archives:
dst: "observe-agent.yaml"
- src: "packaging/windows/connections/host_monitoring/*"
dst: "connections/host_monitoring"
- src: "packaging/windows/connections/self_monitoring/*"
dst: "connections/self_monitoring"

changelog:
use: github
Expand Down
5 changes: 5 additions & 0 deletions cmd/commands/initconfig/configschema.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@ type HostMonitoringConfig struct {
Metrics HostMonitoringMetricsConfig
}

type SelfMonitoringConfig struct {
Enabled bool `yaml:"enabled"`
}

type AgentConfig struct {
Token string `yaml:"token"`
ObserveURL string `yaml:"observe_url"`
SelfMonitoring SelfMonitoringConfig `yaml:"self_monitoring"`
HostMonitoring HostMonitoringConfig `yaml:"host_monitoring"`
}
5 changes: 5 additions & 0 deletions cmd/commands/initconfig/initconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ var (
config_path string
token string
observe_url string
self_monitoring_enabled bool
host_monitoring_enabled bool
host_monitoring_logs_enabled bool
host_monitoring_metrics_enabled bool
Expand All @@ -30,6 +31,7 @@ const configTemplate = "observe-agent.tmpl"
type FlatAgentConfig struct {
Token string
ObserveURL string
SelfMonitoring_Enabled bool
HostMonitoring_Enabled bool
HostMonitoring_LogsEnabled bool
HostMonitoring_MetricsEnabled bool
Expand All @@ -44,6 +46,7 @@ func NewConfigureCmd() *cobra.Command {
configValues := FlatAgentConfig{
Token: viper.GetString("token"),
ObserveURL: viper.GetString("observe_url"),
SelfMonitoring_Enabled: viper.GetBool("self_monitoring.enabled"),
HostMonitoring_Enabled: viper.GetBool("host_monitoring.enabled"),
HostMonitoring_LogsEnabled: viper.GetBool("host_monitoring.logs.enabled"),
HostMonitoring_MetricsEnabled: viper.GetBool("host_monitoring.metrics.enabled"),
Expand Down Expand Up @@ -79,11 +82,13 @@ func RegisterConfigFlags(cmd *cobra.Command) {
cmd.Flags().StringVarP(&config_path, "config_path", "", "", "Path to write config output file to")
cmd.PersistentFlags().StringVar(&token, "token", "", "Observe token")
cmd.PersistentFlags().StringVar(&observe_url, "observe_url", "", "Observe data collection url")
cmd.PersistentFlags().BoolVar(&self_monitoring_enabled, "self_monitoring.enabled", true, "Enable self monitoring")
cmd.PersistentFlags().BoolVar(&host_monitoring_enabled, "host_monitoring.enabled", true, "Enable host monitoring")
cmd.PersistentFlags().BoolVar(&host_monitoring_logs_enabled, "host_monitoring.logs.enabled", true, "Enable host monitoring logs")
cmd.PersistentFlags().BoolVar(&host_monitoring_metrics_enabled, "host_monitoring.metrics.enabled", true, "Enable host monitoring metrics")
viper.BindPFlag("token", cmd.PersistentFlags().Lookup("token"))
viper.BindPFlag("observe_url", cmd.PersistentFlags().Lookup("observe_url"))
viper.BindPFlag("self_monitoring.enabled", cmd.PersistentFlags().Lookup("self_monitoring.enabled"))
viper.BindPFlag("host_monitoring.enabled", cmd.PersistentFlags().Lookup("host_monitoring.enabled"))
viper.BindPFlag("host_monitoring.logs.enabled", cmd.PersistentFlags().Lookup("host_monitoring.logs.enabled"))
viper.BindPFlag("host_monitoring.metrics.enabled", cmd.PersistentFlags().Lookup("host_monitoring.metrics.enabled"))
Expand Down
5 changes: 4 additions & 1 deletion cmd/commands/initconfig/initconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ func Test_InitConfigCommand(t *testing.T) {
expectedConfig: AgentConfig{
Token: "test-token",
ObserveURL: "test-url",
SelfMonitoring: SelfMonitoringConfig{
Enabled: true,
},
HostMonitoring: HostMonitoringConfig{
Enabled: true,
Logs: HostMonitoringLogsConfig{
Expand All @@ -35,7 +38,7 @@ func Test_InitConfigCommand(t *testing.T) {
expectErr: "",
},
{
args: []string{"--config_path=./test-config.yaml", "--token=test-token", "--observe_url=test-url", "--host_monitoring.enabled=false", "--host_monitoring.logs.enabled=false", "--host_monitoring.metrics.enabled=false"},
args: []string{"--config_path=./test-config.yaml", "--token=test-token", "--observe_url=test-url", "--self_monitoring.enabled=false", "--host_monitoring.enabled=false", "--host_monitoring.logs.enabled=false", "--host_monitoring.metrics.enabled=false"},
expectedConfig: AgentConfig{
Token: "test-token",
ObserveURL: "test-url",
Expand Down
3 changes: 3 additions & 0 deletions cmd/commands/initconfig/observe-agent.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ observe_url: {{ .ObserveURL }}
# Debug mode - Sets agent log level to debug
debug: false

self_monitoring:
enabled: {{ .SelfMonitoring_Enabled }}

host_monitoring:
enabled: {{ .HostMonitoring_Enabled }}
logs:
Expand Down
4 changes: 4 additions & 0 deletions cmd/connections/hostmonitoring.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ type HostMonitoringConfig struct {
var HostMonitoringConnectionType = ConnectionType{
Name: "host_monitoring",
ConfigFields: []CollectorConfigFragment{
{
configYAMLPath: "enabled",
colConfigFilePath: "host.yaml",
},
{
configYAMLPath: "metrics.enabled",
colConfigFilePath: "metrics.yaml",
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
receivers:
filestats/agent:
include: '/etc/observe-agent/otel-collector.yaml'
collection_interval: 240m
initial_delay: 60s

service:
pipelines:
metrics/agent-filestats:
receivers: [filestats/agent]
processors: [resourcedetection, resourcedetection/cloud]
exporters: [otlphttp/observe]
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
receivers:
filestats/agent:
include: '/etc/observe-agent/otel-collector.yaml'
collection_interval: 240m
initial_delay: 60s

filelog/agent-config: # TODO: Add observe-agent.yaml once we can obfuscate sensitive config fields
include: [/etc/observe-agent/otel-collector.yaml]
start_at: beginning
Expand All @@ -30,11 +25,6 @@ receivers:

service:
pipelines:
metrics/agent-filestats:
receivers: [filestats/agent]
processors: [resourcedetection, resourcedetection/cloud]
exporters: [otlphttp/observe]

metrics/agent-internal:
receivers: [prometheus/agent, count]
processors: [memory_limiter, transform/truncate, resourcedetection, resourcedetection/cloud, batch]
Expand Down
29 changes: 0 additions & 29 deletions packaging/docker/observe-agent/otel-collector.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,35 +16,6 @@ receivers:
http:
endpoint: localhost:4318

filestats/agent:
include: '/etc/observe-agent/otel-collector.yaml'
collection_interval: 240m
initial_delay: 60s

filelog/agent-config: # TODO: Add observe-agent.yaml once we can obfuscate sensitive config fields
include: [/etc/observe-agent/otel-collector.yaml]
start_at: beginning
poll_interval: 5m
multiline:
line_end_pattern: ENDOFLINEPATTERN

prometheus/agent:
config:
scrape_configs:
- job_name: 'otelcol'
scrape_interval: 10s
static_configs:
- targets: ['0.0.0.0:8888']
metric_relabel_configs:
- source_labels: [__name__]
regex: '.*grpc_io.*'
action: drop

journald/agent:
units:
- observe-agent
priority: info

processors:
# Snowflake limit for identifiers: Regardless of whether an identifier is unquoted or double-quoted, the maximum number of characters allowed is 255 (including blank spaces).
# https://docs.snowflake.com/en/sql-reference/identifiers-syntax#identifier-requirements
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
receivers:
filestats/agent:
include: '/etc/observe-agent/otel-collector.yaml'
collection_interval: 240m
initial_delay: 60s

service:
pipelines:
metrics/agent-filestats:
receivers: [filestats/agent]
processors: [resourcedetection, resourcedetection/cloud]
exporters: [otlphttp/observe]
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
receivers:
filestats/agent:
include: '/etc/observe-agent/otel-collector.yaml'
collection_interval: 240m
initial_delay: 60s

filelog/agent-config: # TODO: Add observe-agent.yaml once we can obfuscate sensitive config fields
include: [/etc/observe-agent/otel-collector.yaml]
start_at: beginning
Expand All @@ -30,11 +25,6 @@ receivers:

service:
pipelines:
metrics/agent-filestats:
receivers: [filestats/agent]
processors: [resourcedetection, resourcedetection/cloud]
exporters: [otlphttp/observe]

metrics/agent-internal:
receivers: [prometheus/agent, count]
processors: [memory_limiter, transform/truncate, resourcedetection, resourcedetection/cloud, batch]
Expand Down
12 changes: 12 additions & 0 deletions packaging/windows/connections/host_monitoring/host.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
receivers:
filestats/agent:
include: 'C:\Program Files\Observe\observe-agent\config\otel-collector.yaml'
collection_interval: 240m
initial_delay: 60s

service:
pipelines:
metrics/agent-filestats:
receivers: [filestats/agent]
processors: [resourcedetection, resourcedetection/cloud]
exporters: [otlphttp/observe]
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
receivers:
filestats/agent:
include: 'C:\Program Files\Observe\observe-agent\config\otel-collector.yaml'
collection_interval: 240m
initial_delay: 60s

filelog/agent-config: # TODO: Add observe-agent.yaml once we can obfuscate sensitive config fields
include: ['C:\Program Files\Observe\observe-agent\config\otel-collector.yaml']
start_at: beginning
Expand All @@ -25,11 +20,6 @@ receivers:

service:
pipelines:
metrics/agent-filestats:
receivers: [filestats/agent]
processors: [resourcedetection, resourcedetection/cloud]
exporters: [otlphttp/observe]

metrics/agent-internal:
receivers: [prometheus/agent, count]
processors: [memory_limiter, transform/truncate, resourcedetection, resourcedetection/cloud, batch]
Expand Down
Loading