diff --git a/.chloggen/chan-tim_autoDiscovery.yaml b/.chloggen/chan-tim_autoDiscovery.yaml new file mode 100644 index 000000000000..36ef5884fa18 --- /dev/null +++ b/.chloggen/chan-tim_autoDiscovery.yaml @@ -0,0 +1,27 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: enhancement + +# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) +component: sumologicexporter + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: adding new products for auto discovery + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +issues: [35622] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: + +# If your change doesn't affect end users or the exported elements of any package, +# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. +# Optional: The change log or logs in which this entry should be included. +# e.g. '[user]' or '[user, api]' +# Include 'user' if the change is relevant to end users. +# Include 'api' if there is a change to a library API. +# Default: '[user]' +change_logs: [] diff --git a/exporter/sumologicexporter/go.mod b/exporter/sumologicexporter/go.mod index 32c88091dd6a..97d3afab5d47 100644 --- a/exporter/sumologicexporter/go.mod +++ b/exporter/sumologicexporter/go.mod @@ -50,7 +50,6 @@ require ( github.com/knadh/koanf/v2 v2.1.2 // indirect github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect - github.com/mitchellh/go-ps v1.0.0 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect diff --git a/exporter/sumologicexporter/go.sum b/exporter/sumologicexporter/go.sum index feba1903dbfb..0048acd5d90f 100644 --- a/exporter/sumologicexporter/go.sum +++ b/exporter/sumologicexporter/go.sum @@ -52,8 +52,6 @@ github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I= github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= -github.com/mitchellh/go-ps v1.0.0 h1:i6ampVEEF4wQFF+bkYfwYgY+F/uYJDktmvLPf7qIgjc= -github.com/mitchellh/go-ps v1.0.0/go.mod h1:J4lOc8z8yJs6vUwklHw2XEIiT4z4C40KtWVN3nvg8Pg= github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= diff --git a/extension/sumologicextension/extension.go b/extension/sumologicextension/extension.go index c0548299a050..1fd27cc04499 100644 --- a/extension/sumologicextension/extension.go +++ b/extension/sumologicextension/extension.go @@ -21,8 +21,8 @@ import ( "github.com/Showmax/go-fqdn" "github.com/cenkalti/backoff/v4" - ps "github.com/mitchellh/go-ps" "github.com/shirou/gopsutil/v4/host" + "github.com/shirou/gopsutil/v4/process" "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/component/componenttest" "go.opentelemetry.io/collector/config/confighttp" @@ -76,6 +76,11 @@ const ( collectorCredentialIDField = "collector_credential_id" stickySessionKey = "AWSALB" + + activeMQJavaProcess = "activemq.jar" + cassandraJavaProcess = "org.apache.cassandra.service.CassandraDaemon" + dockerDesktopJavaProcess = "com.docker.backend" + jmxJavaProcess = "com.sun.management.jmxremote" ) const ( @@ -700,7 +705,7 @@ var sumoAppProcesses = map[string]string{ "apache": "apache", "apache2": "apache", "httpd": "apache", - "docker": "docker", + "docker": "docker", // docker cli "elasticsearch": "elasticsearch", "mysql-server": "mysql", "mysqld": "mysql", @@ -711,21 +716,58 @@ var sumoAppProcesses = map[string]string{ "redis": "redis", "tomcat": "tomcat", "kafka-server-start.sh": "kafka", // Need to test this, most common shell wrapper. + "redis-server": "redis", + "mongod": "mongodb", + "cassandra": "cassandra", + "jmx": "jmx", + "activemq": "activemq", + "memcached": "memcached", + "haproxy": "haproxy", + "dockerd": "docker-ce", // docker engine, for when process runs natively + "com.docker.backend": "docker-ce", // docker daemon runs on a VM in Docker Desktop, process doesn't show on mac + "sqlservr": "mssql", // linux SQL Server process } func filteredProcessList() ([]string, error) { var pl []string - p, err := ps.Processes() + processes, err := process.Processes() if err != nil { return pl, err } - for _, v := range p { - e := strings.ToLower(v.Executable()) + for _, v := range processes { + e, err := v.Name() + if err != nil { + return nil, fmt.Errorf("Error getting executable name: %w", err) + } + e = strings.ToLower(e) + if a, i := sumoAppProcesses[e]; i { pl = append(pl, a) } + + // handling for Docker Desktop + if e == dockerDesktopJavaProcess { + pl = append(pl, "docker-ce") + } + + // handling Java background processes + if e == "java" { + cmdline, err := v.Cmdline() + if err != nil { + return nil, fmt.Errorf("error getting executable name for PID %d: %w", v.Pid, err) + } + + switch { + case strings.Contains(cmdline, cassandraJavaProcess): + pl = append(pl, "cassandra") + case strings.Contains(cmdline, jmxJavaProcess): + pl = append(pl, "jmx") + case strings.Contains(cmdline, activeMQJavaProcess): + pl = append(pl, "activemq") + } + } } return pl, nil diff --git a/extension/sumologicextension/go.mod b/extension/sumologicextension/go.mod index bc9ce9e882cd..300fe2a5a439 100644 --- a/extension/sumologicextension/go.mod +++ b/extension/sumologicextension/go.mod @@ -5,7 +5,6 @@ go 1.22.0 require ( github.com/Showmax/go-fqdn v1.0.0 github.com/cenkalti/backoff/v4 v4.3.0 - github.com/mitchellh/go-ps v1.0.0 github.com/shirou/gopsutil/v4 v4.24.10 github.com/stretchr/testify v1.9.0 go.opentelemetry.io/collector/component v0.114.0 diff --git a/extension/sumologicextension/go.sum b/extension/sumologicextension/go.sum index f6aa46f26d9e..d201bf8d4028 100644 --- a/extension/sumologicextension/go.sum +++ b/extension/sumologicextension/go.sum @@ -40,8 +40,6 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4= github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I= -github.com/mitchellh/go-ps v1.0.0 h1:i6ampVEEF4wQFF+bkYfwYgY+F/uYJDktmvLPf7qIgjc= -github.com/mitchellh/go-ps v1.0.0/go.mod h1:J4lOc8z8yJs6vUwklHw2XEIiT4z4C40KtWVN3nvg8Pg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=