k8s.io/perf-tests/clusterloader2@v0.0.0-20240304094227-64bdb12da87e/pkg/prometheus/manifests/dashboards/master-comparison.dashboard.py (about)

     1  #!/usr/bin/env python3
     2  
     3  # Copyright 2022 The Kubernetes Authors.
     4  #
     5  # Licensed under the Apache License, Version 2.0 (the "License");
     6  # you may not use this file except in compliance with the License.
     7  # You may obtain a copy of the License at
     8  #
     9  #     http://www.apache.org/licenses/LICENSE-2.0
    10  #
    11  # Unless required by applicable law or agreed to in writing, software
    12  # distributed under the License is distributed on an "AS IS" BASIS,
    13  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14  # See the License for the specific language governing permissions and
    15  # limitations under the License.
    16  
    17  import importlib
    18  from copy import deepcopy
    19  
    20  from grafanalib import core as g
    21  import defaults as d
    22  
    23  from master_panels import API_CALL_LATENCY_PANELS, QUANTILE_API_CALL_LATENCY_PANELS, APF_PANELS, HEALTH_PANELS, ETCD_PANELS, APISERVER_PANELS, CONTROLLER_MANAGER_PANELS, VM_PANELS
    24  
    25  
    26  def extended_copy(panels):
    27      extended_panels = []
    28  
    29      for panel in panels:
    30          # copy of an original panel
    31          extended_panels.append(deepcopy(panel))
    32  
    33          # secondary panel
    34          # same criteria, different data source and starting point
    35          panel.title = "[SECONDARY] " + panel.title
    36          panel.dataSource = "$secondary_source"
    37          panel.timeShift = "$timeshift"
    38          extended_panels.append(panel)
    39  
    40      return extended_panels
    41  
    42  
    43  dashboard = d.Dashboard(
    44      title="Comparison Master dashboard",
    45      refresh="",
    46      rows=[
    47          d.Row(title="API call latency", panels=extended_copy(API_CALL_LATENCY_PANELS)),
    48          d.Row(title="API call latency aggregated with quantile", panels=extended_copy(QUANTILE_API_CALL_LATENCY_PANELS), collapse=True),
    49          d.Row(title="P&F metrics", panels=extended_copy(APF_PANELS), collapse=True),
    50          d.Row(title="Overall cluster health", panels=extended_copy(HEALTH_PANELS), collapse=True),
    51          d.Row(title="etcd", panels=extended_copy(ETCD_PANELS), collapse=True),
    52          d.Row(title="kube-apiserver", panels=extended_copy(APISERVER_PANELS), collapse=True),
    53          d.Row(title="kube-controller-manager", panels=extended_copy(CONTROLLER_MANAGER_PANELS), collapse=True),
    54          d.Row(title="Master VM", panels=extended_copy(VM_PANELS), collapse=True),
    55      ],
    56      templating=g.Templating(
    57          list=[
    58              d.SOURCE_TEMPLATE,
    59              g.Template(
    60                  name="secondary_source",
    61                  type="datasource",
    62                  query="prometheus",
    63              ),
    64              g.Template(
    65                  name="timeshift",
    66                  type="interval",
    67                  query="",
    68              ),
    69              g.Template(
    70                  name="etcd_type",
    71                  type="query",
    72                  dataSource="$source",
    73                  regex=r"\*\[+\]+(.*)",
    74                  query="label_values(etcd_request_duration_seconds_count, type)",
    75                  multi=True,
    76                  includeAll=True,
    77                  refresh=g.REFRESH_ON_TIME_RANGE_CHANGE,
    78              ),
    79              g.Template(
    80                  name="etcd_operation",
    81                  type="query",
    82                  dataSource="$source",
    83                  query="label_values(etcd_request_duration_seconds_count, operation)",
    84                  multi=True,
    85                  includeAll=True,
    86                  refresh=g.REFRESH_ON_TIME_RANGE_CHANGE,
    87              ),
    88              g.Template(
    89                  name="verb",
    90                  type="query",
    91                  dataSource="$source",
    92                  query="label_values(apiserver_request_duration_seconds_count, verb)",
    93                  multi=True,
    94                  includeAll=True,
    95                  refresh=g.REFRESH_ON_TIME_RANGE_CHANGE,
    96              ),
    97              g.Template(
    98                  name="resource",
    99                  type="query",
   100                  dataSource="$source",
   101                  regex="(.*)s",
   102                  query="label_values(apiserver_request_duration_seconds_count, resource)",
   103                  multi=True,
   104                  includeAll=True,
   105                  refresh=g.REFRESH_ON_TIME_RANGE_CHANGE,
   106              ),
   107          ]
   108      ),
   109  ).auto_panel_ids()