Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mongo] add config option to enable search indexes collection #19396

Merged
merged 3 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions mongo/assets/configuration/spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,13 @@ files:
value:
type: number
example: 5
- name: collect_search_indexes
description: |
Set to `true` to collect search indexes for each collection.
NOTE: This option is only applicable to MongoDB Atlas clusters.
value:
type: boolean
example: false
- name: replica_check
description: |
Whether or not to read from available replicas.
Expand Down
1 change: 1 addition & 0 deletions mongo/changelog.d/19396.added
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Make MongoDB Atlas search indexes collection configurable and disable it by default for improved performance.
1 change: 1 addition & 0 deletions mongo/datadog_checks/mongo/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ def schemas(self):
'sample_size': int(self._schemas_config.get('sample_size', 10)),
'max_collections': int(max_collections) if max_collections else None,
'max_depth': int(self._schemas_config.get('max_depth', 5)), # Default to 5
'collect_search_indexes': is_affirmative(self._schemas_config.get('collect_search_indexes', False)),
}

def _get_database_autodiscovery_config(self, instance):
Expand Down
1 change: 1 addition & 0 deletions mongo/datadog_checks/mongo/config_models/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ class Schemas(BaseModel):
arbitrary_types_allowed=True,
frozen=True,
)
collect_search_indexes: Optional[bool] = None
collection_interval: Optional[float] = None
enabled: Optional[bool] = None
max_collections: Optional[float] = None
Expand Down
6 changes: 6 additions & 0 deletions mongo/datadog_checks/mongo/data/conf.yaml.example
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,12 @@ instances:
#
# max_depth: 5

## @param collect_search_indexes - boolean - optional - default: false
## Set to `true` to collect search indexes for each collection.
## NOTE: This option is only applicable to MongoDB Atlas clusters.
#
# collect_search_indexes: false

## @param replica_check - boolean - optional - default: true
## Whether or not to read from available replicas.
## Disable this if any replicas are inaccessible to the Agent. This option is not supported for sharded clusters.
Expand Down
5 changes: 5 additions & 0 deletions mongo/datadog_checks/mongo/dbm/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def __init__(self, check):
self._max_collections = self._schemas_config["max_collections"]
self._sample_size = self._schemas_config["sample_size"]
self._max_depth = self._schemas_config["max_depth"]
self._collect_search_indexes = self._schemas_config["collect_search_indexes"]
self._max_collections_per_database = check._config.database_autodiscovery_config['max_collections_per_database']

super(MongoSchemas, self).__init__(
Expand Down Expand Up @@ -210,6 +211,10 @@ def _get_index_type(self, index_name, index_details):
return "regular"

def _discover_collection_search_indexes(self, dbname, collname):
if not self._collect_search_indexes:
self._check.log.debug("Search indexes collection is disabled")
return []

if not self._check.deployment_type.hosting_type == HostingType.ATLAS:
self._check.log.debug("Search indexes are only supported for Atlas deployments")
return []
Expand Down
Loading
Loading