# HG changeset patch
# User Jason Young <jyoung@gitlab.com>
# Date 1659670566 0
#      Fri Aug 05 03:36:06 2022 +0000
# Node ID 478e5fe526ca166049ed921efa35201337709326
# Parent  7263ff173ec769a68871949cc3c97eadbd4f255f
Remove svlogd filter from consul configuration

Consul changed the log line format in version 1.7.0 - and at the same
time added in thresholds that made the logging less noisy. This
removes the svlogd filter that we added in !1946 as it is no longer
matching the log line, and is no longer necessary to suppress repeated
log entries.

Closes https://gitlab.com/gitlab-org/omnibus-gitlab/-/issues/6589

Changelog: changed

diff --git a/files/gitlab-cookbooks/consul/attributes/default.rb b/files/gitlab-cookbooks/consul/attributes/default.rb
--- a/files/gitlab-cookbooks/consul/attributes/default.rb
+++ b/files/gitlab-cookbooks/consul/attributes/default.rb
@@ -15,12 +15,8 @@
   'SSL_CERT_DIR' => '/opt/gitlab/embedded/ssl/certs/'
 }
 
-# Critical state of service:postgresql indicates a node is not a master
-# It does not need to be logged. Health status should be checked from
-# the consul cluster.
-default['consul']['logging_filters'] = {
-  postgresql_warning: "-*agent: Check 'service:postgresql' is now critical"
-}
+default['consul']['logging_filters'] = {}
+
 default['consul']['monitoring_service_discovery'] = false
 
 default['consul']['encryption_key'] = nil
diff --git a/spec/chef/cookbooks/consul/recipes/consul_spec.rb b/spec/chef/cookbooks/consul/recipes/consul_spec.rb
--- a/spec/chef/cookbooks/consul/recipes/consul_spec.rb
+++ b/spec/chef/cookbooks/consul/recipes/consul_spec.rb
@@ -118,6 +118,9 @@
             group: 'bar',
             configuration: {
               log_json: true
+            },
+            logging_filters: {
+              label: 'filter'
             }
           }
         )
@@ -137,6 +140,12 @@
         }
       end
 
+      it 'renders log config with logging_filters keys/values as comments/values' do
+        expect(chef_run).to render_file('/opt/gitlab/sv/consul/log/config').with_content { |content|
+          expect(content).to match(%r{# label\nfilter})
+        }
+      end
+
       it_behaves_like 'enabled runit service', 'consul', 'foo', 'bar', 'foo', 'bar'
     end