Skip to content

Conversation

etichy
Copy link

@etichy etichy commented Sep 19, 2025

Description

In SWO we would like to detect databases running inside cluster and create relations between DiscoveredDatabaseInstance enetity and workload if applicable.

Testing

Add receiver configuration with at least one rule.

Copy link

github-actions bot commented Sep 19, 2025

Dependency Review

The following issues were found:

  • ✅ 0 vulnerable package(s)
  • ✅ 0 package(s) with incompatible licenses
  • ✅ 0 package(s) with invalid SPDX license definitions
  • ⚠️ 17 package(s) with unknown licenses.

View full job summary

@etichy etichy changed the title Feature/ add database discovery receiver feature: add database discovery receiver Sep 19, 2025
@etichy etichy changed the title feature: add database discovery receiver feature: #146 add database discovery receiver Sep 19, 2025
@etichy etichy marked this pull request as ready for review September 22, 2025 07:03
@etichy etichy requested a review from a team as a code owner September 22, 2025 07:03
@pstranak-sw pstranak-sw self-assigned this Sep 22, 2025
Copy link
Contributor

@pstranak-sw pstranak-sw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The basic logic is that in regular intervals, we ask the k8s API for all Pods and Services in a k8s cluster, parse them and look for interesting ones. Then, for the ones that match some discovery rule, we ask the k8s API for their owner workloads.

Have you considered subscribing for these k8s objects instead of regularly querying them? That API also allows for fetching the cached objects by their namespace or labels. Or do you think it would actually be less effective that way?

}

// listPods lists all pods across all namespaces using the typed client.
func (c *Config) listPods(ctx context.Context, client k8s.Interface) ([]corev1.Pod, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are listPods and listServices in this file and bound to *Config instead of being in in receiver.go?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just as Client is a part of config, so I placed it here.

lower_name := strings.ToLower(svc.Name)

for _, rule := range matchingRules {
if strings.Contains(lower_external, rule.DatabaseType) ||
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should rule.DatabaseType always be lowercase?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made that as part of Validation

svcPorts = append(svcPorts, p.Port)
}

// service with external endpoint can be detected by other discoveries we mark discovery.id as `external`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is discovery.id used for?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's for deduplication - database running inside cluster will be discovered probably only by our agent, so discovery.id is clusterUid, but database which are running outside, can be detected by someone else and we need to match them.

@gantrior gantrior requested a review from Copilot September 25, 2025 12:29
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request adds a new database discovery receiver (swok8sdiscovery) to the SolarWinds OTel Collector. The receiver performs periodic discovery of databases running in Kubernetes clusters and emits entity events describing discovered database instances and their relationships to Kubernetes workloads.

Key changes:

  • Implements image-based and domain-based database discovery strategies
  • Emits OpenTelemetry log records for database entities and their relationships
  • Includes comprehensive test coverage and documentation

Reviewed Changes

Copilot reviewed 23 out of 24 changed files in this pull request and generated 2 comments.

File Description
receiver/swok8sdiscovery/ New receiver package with complete implementation including factory, configuration, discovery logic, and tests
CHANGELOG.md Updated to document the new receiver feature
.gitattributes Added to normalize line endings across the codebase

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants