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

New check for indices that have too many nested fields #106

Open
majormoses opened this issue Jan 26, 2018 · 1 comment
Open

New check for indices that have too many nested fields #106

majormoses opened this issue Jan 26, 2018 · 1 comment

Comments

@majormoses
Copy link
Member

In ES5 there are new limits, see: elastic/elasticsearch#14983

@jgough
Copy link

jgough commented Jun 28, 2022

I believe this patch fixes the issue

diff --git a/bin/check-es-indices-field-count.rb b/bin/check-es-indices-field-count.rb
index 55deea8..2e17a3a 100755
--- a/bin/check-es-indices-field-count.rb
+++ b/bin/check-es-indices-field-count.rb
@@ -127,7 +127,7 @@ class ESIndicesFieldCount < Sensu::Plugin::Check::CLI
           fieldcount = if type_mapping['properties'].nil?
                          0
                        else
-                         type_mapping['properties'].length
+                         countnestedfields(type_mapping['properties'])
                        end
           type_field_count[type] = fieldcount
         end
@@ -139,6 +139,19 @@ class ESIndicesFieldCount < Sensu::Plugin::Check::CLI
     index_field_count
   end

+  def countnestedfields(fields)
+    fieldcount = 0
+    fields.each do |field, value|
+      fieldcount += if value.key?('properties')
+                      countnestedfields(value['properties'])
+                    else
+                      1
+                    end
+      end
+
+      fieldcount
+  end
+
   def fieldlimitsetting
     field_limit_setting = {}
     settings = client.indices.get_settings index: config[:index]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants