Backport MongoDB hosts array support to 3.x #879
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Backports the MongoDB
hostsarray support frommainbranch (PR #838, commit 9472fc7) to the3.xbranch to fix broken connection strings when using modern MongoDB configuration format.This resolves the issue where users providing modern
hostsarray parameters get malformed MongoDB URIs likemongodb://user:pass@:/admin(missing host:port).Motivation
Problem:
Organizations running the 3.x branch experience broken MongoDB monitoring when using modern configuration format. The template expects legacy
host/portparameters but receiveshostsarray, causing nil values that produce malformed connection strings.Impact:
host/portformat (inconsistent with current Datadog documentation)Why backport:
mainbranch (merged Feb 26, 2025)Additional Notes
Changes included in this backport:
Template (
templates/agent-conf.d/mongo.yaml.erb):hostsparameter existsdbm,database_autodiscovery,reported_database_hostnameManifest (
manifests/integrations/mongo.pp):hosts,dbm,database_autodiscovery,reported_database_hostnamehostandportparameters in favor ofhostsarrayTests (
spec/classes/datadog_agent_integrations_mongo_spec.rb):CHANGELOG (
CHANGELOG.md):Backward Compatibility:
✅ Fully backward compatible - legacy
host/portconfigurations continue to work unchangedOriginal implementation:
Describe your test plan
Automated Testing:
pdk validate --parallel: PASSED (only expected warnings for undocumented classes)Test scenarios covered: