diff --git a/app/controllers/api/apps_controller.rb b/app/controllers/api/apps_controller.rb index 7c5c9201..fe940ba9 100644 --- a/app/controllers/api/apps_controller.rb +++ b/app/controllers/api/apps_controller.rb @@ -82,50 +82,9 @@ def profile_by_app_group end def increase_log_count - # Metrics are sent in batch - app_group_metrics = metric_params[:application_groups] - errors = [] - log_count_data = [] - - if not app_group_metrics.blank? - app_group_metrics.each do |app_metric| - # Find app based on secret - app_secret = app_metric[:token] || "" - app = BaritoApp.find_by_secret_key(app_secret) - if app.blank? - errors << "#{app_secret} : is not a valid App Secret" - next - end - - # Increase log count on both app_group and app - app_group = app.app_group - app_group.increase_log_count(app_metric[:new_log_count]) - app.increase_log_count(app_metric[:new_log_count]) - - app.reload - log_count_data << { - token: app_metric[:token], - log_count: app.log_count - } - - broadcast(:log_count_changed, - app.id, - app_metric[:new_log_count].to_i - ) - end - end - - if errors.empty? && !app_group_metrics.blank? - render json: { - data: log_count_data - }, status: :ok - else - render json: { - success: false, - errors: errors, - code: 404 - }, status: :not_found - end + render json: { + data: [] + }, status: :ok end private diff --git a/app/controllers/api/v2/apps_controller.rb b/app/controllers/api/v2/apps_controller.rb index 95e69f06..985a524d 100644 --- a/app/controllers/api/v2/apps_controller.rb +++ b/app/controllers/api/v2/apps_controller.rb @@ -80,50 +80,9 @@ def profile_by_app_group end def increase_log_count - # Metrics are sent in batch - app_group_metrics = metric_params[:application_groups] - errors = [] - log_count_data = [] - - if not app_group_metrics.blank? - app_group_metrics.each do |app_metric| - # Find app based on secret - app_secret = app_metric[:token] || "" - app = BaritoApp.find_by_secret_key(app_secret) - if app.blank? - errors << "#{app_secret} : is not a valid App Secret" - next - end - - # Increase log count on both app_group and app - app_group = app.app_group - app_group.increase_log_count(app_metric[:new_log_count]) - app.increase_log_count(app_metric[:new_log_count]) - - app.reload - log_count_data << { - token: app_metric[:token], - log_count: app.log_count - } - - broadcast(:log_count_changed, - app.id, - app_metric[:new_log_count].to_i - ) - end - end - - if errors.empty? && !app_group_metrics.blank? - render json: { - data: log_count_data - }, status: :ok - else - render json: { - success: false, - errors: errors, - code: 404 - }, status: :not_found - end + render json: { + data: [] + }, status: :ok end private diff --git a/app/controllers/app_groups_controller.rb b/app/controllers/app_groups_controller.rb index a209836c..b9075bcd 100644 --- a/app/controllers/app_groups_controller.rb +++ b/app/controllers/app_groups_controller.rb @@ -38,7 +38,7 @@ def show @barito_router_url = "#{Figaro.env.router_protocol}://#{Figaro.env.router_domain}/produce_batch" @open_kibana_url = "#{Figaro.env.viewer_protocol}://#{Figaro.env.viewer_domain}/" + @app_group.helm_infrastructure.cluster_name.to_s + "/" - + @open_katulampa_url = sprintf(Figaro.env.MONITORING_LINK_FORMAT, @app_group.helm_infrastructure.cluster_name.to_s) @allow_set_status = policy(@new_app).toggle_status? @allow_manage_access = policy(@app_group).manage_access? @allow_see_infrastructure = policy(Infrastructure).show? diff --git a/app/views/app_groups/_applications.html.slim b/app/views/app_groups/_applications.html.slim index 5a719326..dcbd647f 100644 --- a/app/views/app_groups/_applications.html.slim +++ b/app/views/app_groups/_applications.html.slim @@ -10,8 +10,7 @@ h4.mb-3 All Applications th.col-1 Retention Days th.col-1 Max TPS th.col-1 Status - th.col-1 Log Count - th.col-1 Created At (UTC) + th.col-2 Created At (UTC) th.col-1 Actions tbody - apps.each do |app| @@ -49,8 +48,7 @@ h4.mb-3 All Applications = hidden_field_tag :toggle_status - else = app.status - td.col-1= app.log_count - td.col-1= app.created_at.strftime('%d %B %Y, %T') + td.col-2= app.created_at.strftime('%d %B %Y, %T') td.col-1 - if allow_delete .btn.btn-danger.btn-sm diff --git a/app/views/app_groups/show.html.slim b/app/views/app_groups/show.html.slim index 7c24fa5a..0ab94372 100644 --- a/app/views/app_groups/show.html.slim +++ b/app/views/app_groups/show.html.slim @@ -70,6 +70,9 @@ .btn.btn-primary.btn-sm.mr-2 i.fas.fa-search.mr-1 = link_to 'Open Kibana', @open_kibana_url, target: '_blank', rel: 'noopener noreferrer', class: 'text-light', style: 'text-decoration: none' + .btn.btn-primary.btn-sm.mr-2 + i.fas.fa-tachometer-alt.mr-1 + = link_to 'Monitoring', @open_katulampa_url, target: '_blank', rel: 'noopener noreferrer', class: 'text-light', style: 'text-decoration: none' - if @allow_manage_access .btn.btn-primary.btn-sm.mr-2 diff --git a/spec/requests/api/apps_spec.rb b/spec/requests/api/apps_spec.rb index 5a4b7d11..6b4a6271 100644 --- a/spec/requests/api/apps_spec.rb +++ b/spec/requests/api/apps_spec.rb @@ -209,7 +209,7 @@ class Datadog::Statsd describe 'Increase Log count API' do context 'when empty application_groups metrics' do - it 'should return 404' do + it 'should return 404', :skip do post api_increase_log_count_path, params: { access_token: @access_token, application_groups: []}, headers: headers expect(response.status).to eq 404 end @@ -224,12 +224,12 @@ class Datadog::Statsd json_response = JSON.parse(response.body) expect(response.status).to eq 200 - expect(json_response['data'][0]['log_count']).to eq(10) + expect(json_response['data']).to be_empty end end context 'when invalid token' do - it 'should return 404' do + it 'should return 404', :skip do secret_key = SecureRandom.uuid.gsub(/\-/, '') error_msg = "#{secret_key} : is not a valid App Secret" diff --git a/spec/requests/api/v2/apps_spec.rb b/spec/requests/api/v2/apps_spec.rb index d9222f4b..028a3cd4 100644 --- a/spec/requests/api/v2/apps_spec.rb +++ b/spec/requests/api/v2/apps_spec.rb @@ -236,7 +236,7 @@ class Datadog::Statsd describe 'Increase Log count API' do context 'when empty application_groups metrics' do - it 'should return 404' do + it 'should return 404', :skip do post api_v2_increase_log_count_path, params: {access_token: @access_token, application_groups: []}, headers: headers expect(response.status).to eq 404 @@ -252,12 +252,12 @@ class Datadog::Statsd json_response = JSON.parse(response.body) expect(response.status).to eq 200 - expect(json_response['data'][0]['log_count']).to eq(10) + expect(json_response['data']).to be_empty end end context 'when invalid token' do - it 'should return 404' do + it 'should return 404', :skip do secret_key = SecureRandom.uuid.gsub(/\-/, '') error_msg = "#{secret_key} : is not a valid App Secret"