Skip to content

Commit 48c0e72

Browse files
feat: add mac support
1 parent 7d0f169 commit 48c0e72

File tree

15 files changed

+395
-844
lines changed

15 files changed

+395
-844
lines changed

.goreleaser.yaml

Lines changed: 21 additions & 625 deletions
Large diffs are not rendered by default.

internal/connections/confighandler.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func GetOverrideConfigFile(sub *viper.Viper) (string, error) {
9090
func GetDefaultConfigFolder() string {
9191
switch currOS := runtime.GOOS; currOS {
9292
case "darwin":
93-
return GetDefaultAgentPath()
93+
return filepath.Join(GetDefaultAgentPath(), "config")
9494
case "windows":
9595
return filepath.Join(GetDefaultAgentPath(), "config")
9696
case "linux":
@@ -100,14 +100,14 @@ func GetDefaultConfigFolder() string {
100100
}
101101
}
102102

103+
func GetConfigFragmentFolderPath() string {
104+
return filepath.Join(GetDefaultAgentPath(), "connections")
105+
}
106+
103107
func GetDefaultAgentPath() string {
104108
switch currOS := runtime.GOOS; currOS {
105109
case "darwin":
106-
homedir, err := os.UserHomeDir()
107-
if err != nil {
108-
return ""
109-
}
110-
return homedir
110+
return "/usr/local/observe-agent"
111111
case "windows":
112112
return os.ExpandEnv("$ProgramFiles\\Observe\\observe-agent")
113113
case "linux":
@@ -120,7 +120,7 @@ func GetDefaultAgentPath() string {
120120
func GetDefaultFilestoragePath() string {
121121
switch currOS := runtime.GOOS; currOS {
122122
case "darwin":
123-
return filepath.Join(os.Getenv("HOME"), "Library", "Application Support", "Observe", "observe-agent", "filestorage")
123+
return "/var/lib/observe-agent/filestorage"
124124
case "windows":
125125
return os.ExpandEnv("$ProgramData\\Observe\\observe-agent\\filestorage")
126126
case "linux":

internal/connections/connections.go

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"fmt"
66
"os"
77
"path/filepath"
8-
"runtime"
98
"text/template"
109

1110
logger "github.com/observeinc/observe-agent/internal/commands/util"
@@ -34,23 +33,6 @@ type ConnectionType struct {
3433
getConfig func() *viper.Viper
3534
}
3635

37-
func GetConfigFolderPath() string {
38-
switch currOS := runtime.GOOS; currOS {
39-
case "darwin":
40-
homedir, err := os.UserHomeDir()
41-
if err != nil {
42-
return ""
43-
}
44-
return filepath.Join(homedir, ".observe-agent/connections")
45-
case "windows":
46-
return os.ExpandEnv("$ProgramFiles\\Observe\\observe-agent\\connections")
47-
case "linux":
48-
return "/etc/observe-agent/connections"
49-
default:
50-
return "/etc/observe-agent/connections"
51-
}
52-
}
53-
5436
func (c *ConnectionType) GetTemplateFilepath(tplFilename string) string {
5537
return filepath.Join(c.configFolderPath, c.Name, tplFilename)
5638
}
@@ -138,7 +120,7 @@ func MakeConnectionType(Name string, ConfigFields []CollectorConfigFragment, Typ
138120
c.getConfig = func() *viper.Viper {
139121
return viper.Sub(c.Name)
140122
}
141-
c.configFolderPath = GetConfigFolderPath()
123+
c.configFolderPath = GetConfigFragmentFolderPath()
142124

143125
// Apply provided options
144126
for _, opt := range opts {

packaging/linux/etc/observe-agent/connections/host_monitoring/process_metrics.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ receivers:
99
process.cpu.utilization:
1010
enabled: true
1111
process.disk.operations:
12-
enabled: true
12+
enabled: true
1313
process.memory.utilization:
14-
enabled: true
14+
enabled: true
1515
process.open_file_descriptors:
16-
enabled: true
16+
enabled: true
1717
process.paging.faults:
18-
enabled: true
18+
enabled: true
1919
process.signals_pending:
20-
enabled: true
20+
enabled: true
2121
process.threads:
2222
enabled: true
2323
mute_process_name_error: true

packaging/linux/etc/observe-agent/connections/self_monitoring/logs_and_metrics.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,3 @@ service:
3939
receivers: [filelog/agent-config]
4040
processors: [memory_limiter, transform/truncate, resourcedetection, resourcedetection/cloud, batch]
4141
exporters: [otlphttp/observe]
42-

packaging/linux/etc/observe-agent/otel-collector.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ processors:
2222
transform/truncate:
2323
log_statements:
2424
- context: log
25-
statements:
25+
statements:
2626
- truncate_all(attributes, 4095)
2727
- truncate_all(resource.attributes, 4095)
2828
trace_statements:
@@ -35,9 +35,9 @@ processors:
3535
check_interval: 1s
3636
limit_percentage: 20
3737
spike_limit_percentage: 5
38-
38+
3939
batch:
40-
40+
4141
resourcedetection:
4242
detectors: [env, system]
4343
system:
@@ -65,7 +65,7 @@ processors:
6565
enabled: true
6666
os.description:
6767
enabled: true
68-
68+
6969
resourcedetection/cloud:
7070
detectors:
7171
{{- if .CloudResourceDetectors }}
@@ -101,8 +101,8 @@ service:
101101
receivers: [otlp]
102102
processors: [resourcedetection, resourcedetection/cloud]
103103
exporters: [otlphttp/observe]
104-
105-
logs/forward:
104+
105+
logs/forward:
106106
receivers: [otlp]
107107
processors: [resourcedetection, resourcedetection/cloud]
108108
exporters: [otlphttp/observe, count]
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
extensions:
2+
health_check:
3+
endpoint: 'localhost:13133'
4+
path: '/status'
5+
file_storage:
6+
directory: ${env:FILESTORAGE_PATH}
7+
8+
connectors:
9+
count:
10+
11+
receivers:
12+
otlp:
13+
protocols:
14+
grpc:
15+
endpoint: localhost:4317
16+
http:
17+
endpoint: localhost:4318
18+
19+
processors:
20+
# 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).
21+
# https://docs.snowflake.com/en/sql-reference/identifiers-syntax#identifier-requirements
22+
transform/truncate:
23+
log_statements:
24+
- context: log
25+
statements:
26+
- truncate_all(attributes, 4095)
27+
- truncate_all(resource.attributes, 4095)
28+
trace_statements:
29+
- context: span
30+
statements:
31+
- truncate_all(attributes, 4095)
32+
- truncate_all(resource.attributes, 4095)
33+
34+
memory_limiter:
35+
check_interval: 1s
36+
limit_percentage: 20
37+
spike_limit_percentage: 5
38+
39+
batch:
40+
41+
resourcedetection:
42+
detectors: [env, system]
43+
system:
44+
hostname_sources: ["dns", "os"]
45+
resource_attributes:
46+
host.id:
47+
enabled: false
48+
os.type:
49+
enabled: true
50+
host.arch:
51+
enabled: true
52+
host.name:
53+
enabled: true
54+
host.cpu.vendor.id:
55+
enabled: true
56+
host.cpu.family:
57+
enabled: true
58+
host.cpu.model.id:
59+
enabled: true
60+
host.cpu.model.name:
61+
enabled: true
62+
host.cpu.stepping:
63+
enabled: true
64+
host.cpu.cache.l2.size:
65+
enabled: true
66+
os.description:
67+
enabled: true
68+
69+
resourcedetection/cloud:
70+
detectors:
71+
{{- if .CloudResourceDetectors }}
72+
{{- inlineArrayStr .CloudResourceDetectors }}
73+
{{- else }} ["gcp", "ecs", "ec2", "azure"]
74+
{{- end }}
75+
timeout: 2s
76+
override: false
77+
78+
filter/count:
79+
error_mode: ignore
80+
metrics:
81+
metric:
82+
- 'IsMatch(name, ".*")'
83+
84+
exporters:
85+
otlphttp/observe:
86+
endpoint: ${env:OBSERVE_ENDPOINT}
87+
headers:
88+
authorization: ${env:OBSERVE_TOKEN}
89+
sending_queue:
90+
num_consumers: 4
91+
queue_size: 100
92+
retry_on_failure:
93+
enabled: true
94+
compression: zstd
95+
96+
debug:
97+
98+
service:
99+
pipelines:
100+
metrics/forward:
101+
receivers: [otlp]
102+
processors: [resourcedetection, resourcedetection/cloud]
103+
exporters: [otlphttp/observe]
104+
105+
logs/forward:
106+
receivers: [otlp]
107+
processors: [resourcedetection, resourcedetection/cloud]
108+
exporters: [otlphttp/observe, count]
109+
110+
traces/forward:
111+
receivers: [otlp]
112+
processors: [resourcedetection, resourcedetection/cloud]
113+
exporters: [otlphttp/observe]
114+
115+
metrics/count-nooop:
116+
receivers: [count]
117+
processors: [filter/count]
118+
exporters: [debug]
119+
120+
extensions: [health_check, file_storage]
121+
telemetry:
122+
metrics:
123+
level: detailed
124+
address: ":8888"
125+
logs:
126+
level: ${env:OTEL_LOG_LEVEL}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
receivers:
2+
filestats/agent:
3+
include: '/etc/observe-agent/otel-collector.yaml'
4+
collection_interval: 5m
5+
initial_delay: 60s
6+
7+
service:
8+
pipelines:
9+
metrics/agent-filestats:
10+
receivers: [filestats/agent]
11+
processors: [resourcedetection, resourcedetection/cloud]
12+
exporters: [otlphttp/observe]
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
receivers:
2+
hostmetrics/host-monitoring-host:
3+
collection_interval: 20s
4+
scrapers:
5+
cpu:
6+
metrics:
7+
system.cpu.utilization:
8+
enabled: true
9+
system.cpu.frequency:
10+
enabled: true
11+
system.cpu.logical.count:
12+
enabled: true
13+
system.cpu.physical.count:
14+
enabled: true
15+
load:
16+
memory:
17+
metrics:
18+
system.memory.utilization:
19+
enabled: true
20+
disk:
21+
filesystem:
22+
metrics:
23+
system.filesystem.utilization:
24+
enabled: true
25+
network:
26+
metrics:
27+
system.network.conntrack.count:
28+
enabled: true
29+
system.network.conntrack.max:
30+
enabled: true
31+
paging:
32+
metrics:
33+
system.paging.utilization:
34+
enabled: true
35+
processes:
36+
37+
service:
38+
pipelines:
39+
metrics/host_monitoring_host:
40+
receivers: [hostmetrics/host-monitoring-host]
41+
processors: [memory_limiter, resourcedetection, resourcedetection/cloud, batch]
42+
exporters: [otlphttp/observe]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
receivers:
2+
filelog/host_monitoring:
3+
include: [/var/log/**/*.log, /var/log/syslog]
4+
include_file_path: true
5+
storage: file_storage
6+
retry_on_failure:
7+
enabled: true
8+
max_log_size: 4MiB
9+
operators:
10+
- type: filter
11+
expr: 'body matches "otel-contrib"'
12+
13+
service:
14+
pipelines:
15+
logs/host_monitoring-file:
16+
receivers: [filelog/host_monitoring]
17+
processors: [memory_limiter, transform/truncate, resourcedetection, resourcedetection/cloud, batch]
18+
exporters: [otlphttp/observe, count]

0 commit comments

Comments
 (0)