Skip to content

Commit

Permalink
[extension/sumologic] Add new products to auto discovery (#35622)
Browse files Browse the repository at this point in the history
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
- Added new products to auto discovery for the otel collector to detect
the new processes running in the background.
```
[x] jmx
[x] activemq
[x] docker ce
[x] haproxy
[x] memcached
[x] mongodb
[x] cassandra
[x] microsoft sql server (linux)
[] oracledb (not including in this iteration)
```

<!-- Issue number (e.g. #1234) or full URL to issue, if applicable. -->
#### Link to tracking issue
- https://sumologic.atlassian.net/browse/OSC-838

<!--Describe what testing was performed and which tests were added.-->
#### Testing
- ran in staging/long env
- Screenshots of the products showing up in COLLECTOR TAGS is in the
jira.

<!--Describe the documentation added.-->
#### Documentation
-
https://help.sumologic.com/docs/send-data/opentelemetry-collector/auto-discovery/#view-discovered-services

<!--Please delete paragraphs that you did not use before submitting.-->
  • Loading branch information
chan-tim-sumo authored Nov 20, 2024
1 parent 9fbf26d commit 909c107
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 @@ -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
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 @@ -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",
Expand All @@ -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
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.114.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 909c107

Please sign in to comment.