Skip to content

Add Windows Powershell Install Script #18

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 10 commits into from
May 30, 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
41 changes: 33 additions & 8 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,26 @@ before:
- go generate ./...

builds:
- env:
- id: default
env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
ldflags: -s -w -X observe/agent/build.Version={{.Version}}

- id: windows_build
env:
- CGO_ENABLED=0
goos:
- windows
ldflags: -s -w -X observe/agent/build.Version={{.Version}}

archives:
- format: tar.gz
- id: default
format: tar.gz
builds:
- default
# this name template makes the OS and Arch compatible with the results of `uname`.
name_template: >-
{{ .ProjectName }}_
Expand All @@ -34,16 +44,31 @@ archives:
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
# use zip for windows archives
format_overrides:
- goos: windows
format: zip
files:
- src: "packaging/linux/etc/observe-agent/*"
dst: "."
- src: "packaging/linux/config/*"
dst: "."


- id: windows
format: zip
builds:
- windows_build
name_template: >-
{{ .ProjectName }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
files:
- src: "packaging/windows/config/otel-collector.yaml"
dst: "otel-collector.yaml"
- src: "packaging/windows/observe-agent.yaml"
dst: "observe-agent.yaml"
- src: "packaging/windows/connections/**"
dst: "connections/"

changelog:
sort: asc
filters:
Expand Down
16 changes: 16 additions & 0 deletions cmd/config/confighandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"net/url"
"os"
"path"
"path/filepath"
"runtime"

Expand Down Expand Up @@ -43,6 +44,7 @@ func SetEnvVars() error {
// Setting values from the Observe agent config as env vars to fill in the OTEL collector config
os.Setenv("OBSERVE_ENDPOINT", endpoint)
os.Setenv("OBSERVE_TOKEN", "Bearer "+token)
os.Setenv("FILESTORAGE_PATH", GetDefaultFilestoragePath())
return nil
}

Expand Down Expand Up @@ -74,3 +76,17 @@ func GetDefaultConfigFolder() string {
return "/etc/observe-agent"
}
}

func GetDefaultFilestoragePath() string {
switch currOS := runtime.GOOS; currOS {
case "darwin":
return "~/Library/Application Support/Observe/observe-agent/filestorage"
case "windows":
programData := os.Getenv("PROGRAMDATA")
return path.Join(programData, "Observe", "observe-agent", "filestorage")
case "linux":
return "/var/lib/observe-agent/filestorage"
default:
return "/var/lib/observe-agent/filestorage"
}
}
4 changes: 2 additions & 2 deletions packaging/linux/config/observe-agent.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
# Please download the config from Connections Portal

# Observe data token
# token: "XXX"
# token: "${OBSERVE_TOKEN}"

# Target Observe collection url
# observe_url: "YYY"
# observe_url: "${OBSERVE_COLLECTION_ENDPOINT}"

host_monitoring:
enabled: true
Expand Down
2 changes: 1 addition & 1 deletion packaging/linux/etc/observe-agent/otel-collector.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ extensions:
endpoint: 'localhost:13133'
path: '/status'
file_storage:
directory: '/var/lib/observe-agent/file_storage'
directory: ${env:FILESTORAGE_PATH}

connectors:
count:
Expand Down
4 changes: 2 additions & 2 deletions packaging/linux/scripts/preinstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
getent passwd observe-agent >/dev/null || useradd --system --user-group --no-create-home --shell /sbin/nologin observe-agent
sudo adduser observe-agent systemd-journal

sudo mkdir -p /var/lib/observe-agent/file_storage
sudo chown observe-agent /var/lib/observe-agent/file_storage
sudo mkdir -p /var/lib/observe-agent/filestorage
sudo chown observe-agent /var/lib/observe-agent/filestorage
2 changes: 1 addition & 1 deletion packaging/macos/otel-collector.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ extensions:
endpoint: 'localhost:13133'
path: '/status'
file_storage:
directory: '$HOME/.observe-agent'
directory: ${env:FILESTORAGE_PATH}

connectors:
count:
Expand Down
117 changes: 117 additions & 0 deletions packaging/windows/config/otel-collector.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
extensions:
health_check:
endpoint: 'localhost:13133'
path: '/status'
file_storage:
directory: ${env:FILESTORAGE_PATH}

connectors:
count:

receivers:
otlp:
protocols:
grpc:
endpoint: localhost:4317
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


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
transform/truncate:
log_statements:
- context: log
statements:
- truncate_all(attributes, 4095)
- truncate_all(resource.attributes, 4095)
trace_statements:
- context: span
statements:
- truncate_all(attributes, 4095)
- truncate_all(resource.attributes, 4095)

memory_limiter:
check_interval: 1s
limit_percentage: 20
spike_limit_percentage: 5

batch:

resourcedetection:
detectors: [gcp, ecs, ec2, azure, system]
override: true

exporters:
otlphttp/observe:
endpoint: ${env:OBSERVE_ENDPOINT}
headers:
authorization: ${env:OBSERVE_TOKEN}
sending_queue:
num_consumers: 4
queue_size: 100
retry_on_failure:
enabled: true

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

metrics/agent-internal:
receivers: [prometheus/agent, count]
processors: [memory_limiter, transform/truncate, resourcedetection, batch]
exporters: [otlphttp/observe]

metrics/forward:
receivers: [otlp]
processors: []
exporters: [otlphttp/observe]

logs/agent-config:
receivers: [filelog/agent-config]
processors: [memory_limiter, transform/truncate, resourcedetection, batch]
exporters: [otlphttp/observe]

logs/forward:
receivers: [otlp]
processors: []
exporters: [otlphttp/observe, count]

traces/forward:
receivers: [otlp]
processors: []
exporters: [otlphttp/observe]

extensions: [health_check, file_storage]
telemetry:
metrics:
level: detailed
address: ":8888"
18 changes: 18 additions & 0 deletions packaging/windows/connections/host_monitoring/logs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
receivers:
filelog/host_monitoring:
include: [/var/log/**/*.log, /var/log/syslog]
include_file_path: true
storage: file_storage
retry_on_failure:
enabled: true
max_log_size: 4MiB
operators:
- type: filter
expr: 'body matches "otel-contrib"'

service:
pipelines:
logs/host_monitoring-file:
receivers: [filelog/host_monitoring]
processors: [memory_limiter, transform/truncate, resourcedetection, batch]
exporters: [otlphttp/observe, count]
66 changes: 66 additions & 0 deletions packaging/windows/connections/host_monitoring/metrics.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
receivers:
hostmetrics/host-monitoring:
collection_interval: 20s
scrapers:
cpu:
metrics:
system.cpu.utilization:
enabled: true
system.cpu.frequency:
enabled: true
system.cpu.logical.count:
enabled: true
system.cpu.physical.count:
enabled: true
load:
memory:
metrics:
system.memory.utilization:
enabled: true
system.linux.memory.available:
enabled: true
disk:
filesystem:
metrics:
system.filesystem.utilization:
enabled: true
network:
metrics:
system.network.conntrack.count:
enabled: true
system.network.conntrack.max:
enabled: true
paging:
metrics:
system.paging.utilization:
enabled: true
processes:
process:
metrics:
process.context_switches:
enabled: true
process.cpu.utilization:
enabled: true
process.disk.operations:
enabled: true
process.memory.utilization:
enabled: true
process.open_file_descriptors:
enabled: true
process.paging.faults:
enabled: true
process.signals_pending:
enabled: true
process.threads:
enabled: true
mute_process_name_error: true
mute_process_exe_error: true
mute_process_io_error: true
mute_process_user_error: true

service:
pipelines:
metrics/host_monitoring:
receivers: [hostmetrics/host-monitoring]
processors: [memory_limiter, resourcedetection, batch]
exporters: [otlphttp/observe]
18 changes: 18 additions & 0 deletions packaging/windows/observe-agent.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Observe data token
token: "${OBSERVE_TOKEN}"

# Target Observe collection url
observe_url: "${OBSERVE_COLLECTION_ENDPOINT}"

# otel_config_overrides:
# exporters:
# debug:
# verbosity: detailed
# sampling_initial: 5
# sampling_thereafter: 200
# service:
# pipelines:
# metrics:
# receivers: [hostmetrics, prometheus/internal, count]
# processors: [memory_limiter, resourcedetection, batch]
# exporters: [debug]
Loading