Commit 50558df3 authored by Imre Farkas's avatar Imre Farkas

Merge branch 'add-pod-metrics-dashboard' into 'master'

Add pod metrics dashboard

See merge request gitlab-org/gitlab!20242
parents 97b65561 9ac643f5
# frozen_string_literal: true
module Metrics
module Dashboard
class PodDashboardService < ::Metrics::Dashboard::PredefinedDashboardService
DASHBOARD_PATH = 'config/prometheus/pod_metrics.yml'
DASHBOARD_NAME = 'Pod Health'
end
end
end
dashboard: 'Pod metrics'
priority: 10
panel_groups:
- group: CPU metrics
panels:
- title: "CPU usage"
type: "line-chart"
y_label: "Cores per pod"
metrics:
- id: pod_cpu_usage_seconds_total
query_range: 'rate(container_cpu_usage_seconds_total{pod_name="{{pod_name}}",container_name="POD"}[5m])'
unit: "cores"
label: pod_name
- group: Memory metrics
panels:
- title: "Memory usage working set"
type: "line-chart"
y_label: "Working set memory (MiB)"
metrics:
- id: pod_memory_working_set
query_range: 'container_memory_working_set_bytes{pod_name="{{pod_name}}",container_name="POD"}/1024/1024'
unit: "MiB"
label: pod_name
- group: Network metrics
panels:
- title: "Network Receive (In)"
type: "line-chart"
y_label: "Received (KiB/sec)"
metrics:
- id: pod_network_receive
query_range: 'rate(container_network_receive_bytes_total{pod_name="{{pod_name}}",container_name="POD"}[5m])/1024'
unit: "KiB / sec"
label: pod_name
- title: "Network Transmit (Out)"
type: "line-chart"
y_label: "Transmitted (KiB/sec)"
metrics:
- id: pod_network_transmit
query_range: 'rate(container_network_transmit_bytes_total{pod_name="{{pod_name}}",container_name="POD"}[5m])/1024'
unit: "KiB / sec"
label: pod_name
- group: Disk metrics
panels:
- title: "Disk Reads"
type: "line-chart"
y_label: "Disk reads (KiB/sec)"
metrics:
- id: pod_disk_reads
query_range: 'rate(container_fs_reads_bytes_total{container_name="POD",pod_name="{{pod_name}}"}[5m])/1024'
unit: "KiB / sec"
label: pod_name
- title: "Disk Writes"
type: "line-chart"
y_label: "Disk writes (KiB/sec)"
metrics:
- id: pod_disk_writes
query_range: 'rate(container_fs_writes_bytes_total{container_name="POD",pod_name="{{pod_name}}"}[5m])/1024'
unit: "KiB / sec"
label: pod_name
......@@ -22,6 +22,7 @@ module Gitlab
return SERVICES::DynamicEmbedService if dynamic_embed?(params)
return SERVICES::DefaultEmbedService if params[:embedded]
return SERVICES::SystemDashboardService if system_dashboard?(params[:dashboard_path])
return SERVICES::PodDashboardService if pod_dashboard?(params[:dashboard_path])
return SERVICES::ProjectDashboardService if params[:dashboard_path]
default_service
......@@ -37,6 +38,10 @@ module Gitlab
SERVICES::SystemDashboardService.matching_dashboard?(filepath)
end
def pod_dashboard?(filepath)
SERVICES::PodDashboardService.matching_dashboard?(filepath)
end
def custom_metric_embed?(params)
SERVICES::CustomMetricEmbedService.valid_params?(params)
end
......
......@@ -2,7 +2,6 @@
"type": "object",
"required": [
"group",
"priority",
"panels"
],
"properties": {
......
......@@ -22,6 +22,12 @@ describe Gitlab::Metrics::Dashboard::ServiceSelector do
it { is_expected.to be Metrics::Dashboard::SystemDashboardService }
end
context 'when the path is for the pod dashboard' do
let(:arguments) { { dashboard_path: pod_dashboard_path } }
it { is_expected.to be Metrics::Dashboard::PodDashboardService }
end
end
context 'when the embedded flag is provided' do
......
# frozen_string_literal: true
require 'spec_helper'
describe Metrics::Dashboard::PodDashboardService, :use_clean_rails_memory_store_caching do
include MetricsDashboardHelpers
let_it_be(:user) { create(:user) }
let_it_be(:project) { create(:project) }
let_it_be(:environment) { create(:environment, project: project) }
before do
project.add_maintainer(user)
end
describe 'get_dashboard' do
let(:dashboard_path) { described_class::DASHBOARD_PATH }
let(:service_params) { [project, user, { environment: environment, dashboard_path: dashboard_path }] }
let(:service_call) { described_class.new(*service_params).get_dashboard }
it_behaves_like 'valid dashboard service response'
it_behaves_like 'caches the unprocessed dashboard for subsequent calls'
end
end
......@@ -22,6 +22,10 @@ module MetricsDashboardHelpers
Metrics::Dashboard::SystemDashboardService::DASHBOARD_PATH
end
def pod_dashboard_path
Metrics::Dashboard::PodDashboardService::DASHBOARD_PATH
end
def business_metric_title
PrometheusMetricEnums.group_details[:business][:group_title]
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment