diff --git a/elastic/changelog.d/23824.fixed b/elastic/changelog.d/23824.fixed new file mode 100644 index 0000000000000..12e35fa73aaeb --- /dev/null +++ b/elastic/changelog.d/23824.fixed @@ -0,0 +1 @@ +Handle closed indices in search stats endpoint query diff --git a/elastic/datadog_checks/elastic/elastic.py b/elastic/datadog_checks/elastic/elastic.py index f4eb44ff0fa30..d46c1c3f7a502 100644 --- a/elastic/datadog_checks/elastic/elastic.py +++ b/elastic/datadog_checks/elastic/elastic.py @@ -292,7 +292,9 @@ def _get_index_search_stats(self, admin_forwarder, base_tags): # This endpoint can return more data, all of what the /_cat/indices endpoint returns except index health. # The health we can get from /_cluster/health if we pass level=indices query param. Reference: # https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-health.html#cluster-health-api-query-params # noqa: E501 - indices = self._get_data(self._join_url('/_stats/search', admin_forwarder))['indices'] + indices = self._get_data(self._join_url('/_stats/search?forbid_closed_indices=false', admin_forwarder))[ + 'indices' + ] for (idx_name, data), (m_name, path) in product(indices.items(), INDEX_SEARCH_STATS): tags = base_tags + ['index_name:' + idx_name] self._process_metric(data, m_name, 'gauge', path, tags=tags)