Skip to content

Commit

Permalink
Added new products to auto discovery for sumo otel collector
Browse files Browse the repository at this point in the history
  • Loading branch information
chan-tim-sumo committed Nov 19, 2024
1 parent 40dbf0b commit 0a5954b
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 11 deletions.
27 changes: 27 additions & 0 deletions .chloggen/chan-tim_autoDiscovery.yaml
Original file line number Diff line number Diff line change
@@ -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: []
1 change: 0 additions & 1 deletion exporter/sumologicexporter/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ require (
github.com/knadh/koanf/v2 v2.1.1 // 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
Expand Down
2 changes: 0 additions & 2 deletions exporter/sumologicexporter/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 47 additions & 5 deletions extension/sumologicextension/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 (
Expand Down Expand Up @@ -698,7 +703,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",
Expand All @@ -709,21 +714,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
Expand Down
1 change: 0 additions & 1 deletion extension/sumologicextension/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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.113.0
Expand Down
2 changes: 0 additions & 2 deletions extension/sumologicextension/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0a5954b

Please sign in to comment.