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 Oct 23, 2024
1 parent 67e9293 commit d9c1cb1
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 8 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: []
53 changes: 48 additions & 5 deletions extension/sumologicextension/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import (

"github.com/Showmax/go-fqdn"
"github.com/cenkalti/backoff/v4"
ps "github.com/mitchellh/go-ps"

"github.com/shirou/gopsutil/process"
"github.com/shirou/gopsutil/v4/host"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config/confighttp"
Expand Down Expand Up @@ -699,7 +700,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 @@ -710,21 +711,63 @@ 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 {
// Get the process executable name
e, err := v.Name()
if err != nil {
continue
}
e = strings.ToLower(e)

if a, i := sumoAppProcesses[e]; i {
pl = append(pl, a)
}

// handling for Docker Desktop
if e == "com.docker.backend" {
pl = append(pl, "docker-ce")
}

// handling for Java background processes
if e == "java" {
cmdline, err := v.Cmdline()
if err != nil {
continue
}

if strings.Contains(cmdline, "org.apache.cassandra.service.CassandraDaemon") {
pl = append(pl, "cassandra")
}

if strings.Contains(cmdline, "com.sun.management.jmxremote") {
pl = append(pl, "jmx")
}

if strings.Contains(cmdline, "activemq.jar") {
pl = append(pl, "activemq")
}
}

}

return pl, nil
Expand Down
2 changes: 1 addition & 1 deletion extension/sumologicextension/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.21.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 v3.21.11+incompatible
github.com/shirou/gopsutil/v4 v4.24.6
github.com/stretchr/testify v1.9.0
go.opentelemetry.io/collector/component v0.106.1
Expand Down
4 changes: 2 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 d9c1cb1

Please sign in to comment.