
{{- $Values := (.helm).Values | default .Values }}
{{- $multicluster := ((($Values.grafana).sidecar).dashboards).multicluster | default false }}
{{- $defaultDatasource := "prometheus" -}}
{{- $clusterLabel := ($Values.global).clusterLabel | default "cluster" }}
{{- range (($Values.defaultDatasources).victoriametrics).datasources | default list }}
  {{- if and .isDefault .type }}{{ $defaultDatasource = .type }}{{- end }}
{{- end }}
title: Kubernetes / System / API Server
templating:
  list:
  - name: datasource
    type: datasource
    query: {{ $defaultDatasource }}
    hide: 0
    current:
      selected: false
      text: Prometheus
      value: Prometheus
    options: []
    queryValue: ""
    refresh: 1
    regex: ""
    skipUrlSync: false
  - name: cluster
    datasource:
      type: {{ $defaultDatasource }}
      uid: ${datasource}
    type: {{ ternary "query" "constant" $multicluster }}
    query: {{ ternary (printf "{\"qryType\":1,\"query\":\"label_values(kube_node_info, %s)\",\"refId\":\"PrometheusVariableQueryEditor-VariableQuery\"}" $clusterLabel) ".*" $multicluster }}
    definition: {{ ternary (printf "label_values(kube_node_info, %s)" $clusterLabel) ".*" $multicluster }}
    hide: {{ ternary 0 2 $multicluster }}
    current:
      isNone: true
      selected: false
      text: None
      value: ""
    options: []
    refresh: 1
    regex: ""
    skipUrlSync: false
    sort: 1
  - name: resolution
    type: custom
    query: 1s, 15s, 30s, 1m, 3m, 5m
    hide: 0
    current:
      selected: true
      text: 30s
      value: 30s
    options:
    - selected: false
      text: 1s
      value: 1s
    - selected: false
      text: 15s
      value: 15s
    - selected: true
      text: 30s
      value: 30s
    - selected: false
      text: 1m
      value: 1m
    - selected: false
      text: 3m
      value: 3m
    - selected: false
      text: 5m
      value: 5m
    queryValue: ""
    skipUrlSync: false
  - name: job
    multi: true
    datasource:
      type: {{ $defaultDatasource }}
      uid: ${datasource}
    type: query
    query:
      qryType: 1
      query: {{ printf "label_values(apiserver_request_total{%s=~\"$cluster\"}, job)" $clusterLabel }}
      refId: PrometheusVariableQueryEditor-VariableQuery
    definition: {{ printf "label_values(apiserver_request_total{%s=~\"$cluster\"}, job)" $clusterLabel }}
    hide: 0
    current: {}
    options: []
    refresh: 1
    regex: ""
    skipUrlSync: false
    sort: 1
editable: false
timezone: {{ default "utc" ($Values.defaultDashboards).defaultTimezone }}
tags:
- Kubernetes
- Prometheus
- vm-k8s-stack
annotations:
  list:
  - name: Annotations & Alerts
    datasource:
      type: datasource
      uid: grafana
    builtIn: 1
    enable: true
    hide: true
    iconColor: rgba(0, 211, 255, 1)
    target:
      limit: 100
      matchAny: false
      tags: []
      type: dashboard
    type: dashboard
  - name: terraform
    datasource:
      type: datasource
      uid: grafana
    enable: true
    hide: false
    iconColor: '#5c4ee5'
    target:
      limit: 100
      matchAny: false
      tags:
      - terraform
      type: tags
  - name: oncall
    datasource:
      type: datasource
      uid: grafana
    enable: true
    hide: false
    iconColor: red
    target:
      limit: 100
      matchAny: false
      tags:
      - oncall
      type: tags
panels:
- title: API Server - Health Status
  targets:
  - datasource:
      type: {{ $defaultDatasource }}
      uid: ${datasource}
    expr: {{ printf "up{%s=~\"$cluster\",job=~\"$job\"}" $clusterLabel }}
    exemplar: true
    interval: ""
    legendFormat: '{{`{{`}} instance {{`}}`}}'
    refId: A
  datasource:
    type: {{ $defaultDatasource }}
    uid: ${datasource}
  fieldConfig:
    defaults:
      mappings:
      - options:
          "0":
            text: DOWN
          "1":
            text: UP
        type: value
      thresholds:
        mode: absolute
        steps:
        - color: red
          value: null
        - color: green
          value: 1
    overrides: []
  gridPos:
    h: 8
    w: 12
    x: 0
    "y": 0
  id: 42
  options:
    colorMode: background
    graphMode: none
    justifyMode: auto
    orientation: horizontal
    reduceOptions:
      calcs:
      - lastNotNull
      fields: ""
      values: false
    textMode: value_and_name
  pluginVersion: 10.0.1
  type: stat
- title: Deprecated Kubernetes Resources
  targets:
  - datasource:
      type: {{ $defaultDatasource }}
      uid: ${datasource}
    expr: {{ printf "apiserver_requested_deprecated_apis{%s=~\"$cluster\"}" $clusterLabel }}
    exemplar: true
    interval: ""
    legendFormat: ""
    refId: A
  datasource:
    type: {{ $defaultDatasource }}
    uid: ${datasource}
  fieldConfig:
    defaults:
      custom:
        align: auto
        cellOptions:
          type: auto
        inspect: false
      mappings: []
      thresholds:
        mode: absolute
        steps:
        - color: green
          value: null
        - color: red
          value: 80
    overrides:
    - matcher:
        id: byName
        options: __name__
      properties:
      - id: custom.width
        value: 188
  gridPos:
    h: 8
    w: 12
    x: 12
    "y": 0
  id: 60
  options:
    cellHeight: sm
    footer:
      countRows: false
      fields: ""
      reducer:
      - sum
      show: false
    showHeader: true
    sortBy:
    - desc: false
      displayName: removed_release
  pluginVersion: 10.0.1
  transformations:
  - id: labelsToFields
    options:
      keepLabels:
      - group
      - job
      - removed_release
      - resource
      - version
      - name
      mode: columns
  - id: merge
    options: {}
  - id: organize
    options:
      excludeByName:
        Time: true
        Value: true
        job: true
      indexByName:
        Time: 6
        Value: 7
        group: 1
        job: 5
        namespace: 0
        removed_release: 4
        resource: 3
        version: 2
      renameByName: {}
  - id: groupBy
    options:
      fields:
        group:
          aggregations:
          - lastNotNull
          operation: groupby
        job:
          aggregations: []
          operation: groupby
        namespace:
          aggregations:
          - lastNotNull
          operation: groupby
        removed_release:
          aggregations: []
          operation: groupby
        resource:
          aggregations:
          - lastNotNull
          operation: groupby
        version:
          aggregations: []
          operation: groupby
  type: table
- title: API Server - HTTP Requests by code
  targets:
  - datasource:
      type: {{ $defaultDatasource }}
      uid: ${datasource}
    expr: {{ printf "sum(rate(apiserver_request_total{%s=~\"$cluster\"}[$__rate_interval])) by(code,%s)" $clusterLabel $clusterLabel }}
    exemplar: true
    interval: $resolution
    legendFormat: '{{`{{`}} code {{`}}`}}'
    refId: A
  datasource:
    type: {{ $defaultDatasource }}
    uid: ${datasource}
  fieldConfig:
    defaults:
      color:
        mode: palette-classic
      custom:
        axisCenteredZero: false
        axisColorMode: text
        axisLabel: ""
        axisPlacement: auto
        barAlignment: 0
        drawStyle: line
        fillOpacity: 25
        gradientMode: opacity
        hideFrom:
          legend: false
          tooltip: false
          viz: false
        lineInterpolation: smooth
        lineWidth: 2
        pointSize: 5
        scaleDistribution:
          type: linear
        showPoints: never
        spanNulls: false
        stacking:
          group: A
          mode: none
        thresholdsStyle:
          mode: "off"
      mappings: []
      thresholds:
        mode: absolute
        steps:
        - color: green
          value: null
        - color: red
          value: 80
      unit: short
    overrides: []
  gridPos:
    h: 8
    w: 12
    x: 0
    "y": 8
  id: 38
  options:
    legend:
      calcs: []
      displayMode: list
      placement: bottom
      showLegend: true
    tooltip:
      mode: multi
      sort: desc
  pluginVersion: 8.3.3
  type: timeseries
- title: API Server - HTTP Requests by verb
  targets:
  - datasource:
      type: {{ $defaultDatasource }}
      uid: ${datasource}
    expr: {{ printf "sum(rate(apiserver_request_total{%s=~\"$cluster\"}[$__rate_interval])) by(verb,%s)" $clusterLabel $clusterLabel }}
    exemplar: true
    interval: $resolution
    legendFormat: '{{`{{`}} verb{{`}}`}}'
    refId: A
  datasource:
    type: {{ $defaultDatasource }}
    uid: ${datasource}
  fieldConfig:
    defaults:
      color:
        mode: palette-classic
      custom:
        axisCenteredZero: false
        axisColorMode: text
        axisLabel: ""
        axisPlacement: auto
        barAlignment: 0
        drawStyle: line
        fillOpacity: 25
        gradientMode: opacity
        hideFrom:
          legend: false
          tooltip: false
          viz: false
        lineInterpolation: smooth
        lineWidth: 2
        pointSize: 5
        scaleDistribution:
          type: linear
        showPoints: never
        spanNulls: false
        stacking:
          group: A
          mode: none
        thresholdsStyle:
          mode: "off"
      mappings: []
      thresholds:
        mode: absolute
        steps:
        - color: green
          value: null
        - color: red
          value: 80
      unit: short
    overrides: []
  gridPos:
    h: 8
    w: 12
    x: 12
    "y": 8
  id: 39
  options:
    legend:
      calcs: []
      displayMode: list
      placement: bottom
      showLegend: true
    tooltip:
      mode: multi
      sort: desc
  pluginVersion: 8.3.3
  type: timeseries
- title: API Server - HTTP Requests Latency by instance
  targets:
  - datasource:
      type: {{ $defaultDatasource }}
      uid: ${datasource}
    expr: {{ printf "sum(rate(apiserver_request_duration_seconds_sum{%s=~\"$cluster\",job=~\"$job\"}[$__rate_interval])) by(instance,%s) / sum(rate(apiserver_request_duration_seconds_count{%s=~\"$cluster\",job=~\"$job\"}[$__rate_interval])) by(instance,%s)" $clusterLabel $clusterLabel $clusterLabel $clusterLabel }}
    exemplar: true
    interval: $resolution
    legendFormat: '{{`{{`}} instance {{`}}`}}'
    refId: A
  datasource:
    type: {{ $defaultDatasource }}
    uid: ${datasource}
  fieldConfig:
    defaults:
      color:
        mode: palette-classic
      custom:
        axisCenteredZero: false
        axisColorMode: text
        axisLabel: ""
        axisPlacement: auto
        barAlignment: 0
        drawStyle: line
        fillOpacity: 25
        gradientMode: opacity
        hideFrom:
          legend: false
          tooltip: false
          viz: false
        lineInterpolation: smooth
        lineWidth: 2
        pointSize: 5
        scaleDistribution:
          type: linear
        showPoints: never
        spanNulls: false
        stacking:
          group: A
          mode: none
        thresholdsStyle:
          mode: "off"
      mappings: []
      thresholds:
        mode: absolute
        steps:
        - color: green
          value: null
        - color: red
          value: 80
      unit: ms
    overrides: []
  gridPos:
    h: 8
    w: 12
    x: 0
    "y": 16
  id: 53
  options:
    legend:
      calcs: []
      displayMode: list
      placement: bottom
      showLegend: true
    tooltip:
      mode: single
      sort: none
  pluginVersion: 8.3.3
  type: timeseries
- title: API Server - HTTP Requests Latency by verb
  targets:
  - datasource:
      type: {{ $defaultDatasource }}
      uid: ${datasource}
    expr: {{ printf "sum(rate(apiserver_request_duration_seconds_sum{%s=~\"$cluster\",job=~\"$job\"}[$__rate_interval])) by(verb,%s) / sum(rate(apiserver_request_duration_seconds_count{%s=~\"$cluster\",job=~\"$job\"}[$__rate_interval])) by(verb,%s)" $clusterLabel $clusterLabel $clusterLabel $clusterLabel }}
    exemplar: true
    interval: $resolution
    legendFormat: '{{`{{`}} verb {{`}}`}}'
    refId: A
  datasource:
    type: {{ $defaultDatasource }}
    uid: ${datasource}
  fieldConfig:
    defaults:
      color:
        mode: palette-classic
      custom:
        axisCenteredZero: false
        axisColorMode: text
        axisLabel: ""
        axisPlacement: auto
        barAlignment: 0
        drawStyle: line
        fillOpacity: 25
        gradientMode: opacity
        hideFrom:
          legend: false
          tooltip: false
          viz: false
        lineInterpolation: smooth
        lineWidth: 2
        pointSize: 5
        scaleDistribution:
          type: linear
        showPoints: never
        spanNulls: false
        stacking:
          group: A
          mode: none
        thresholdsStyle:
          mode: "off"
      mappings: []
      thresholds:
        mode: absolute
        steps:
        - color: green
          value: null
        - color: red
          value: 80
      unit: ms
    overrides: []
  gridPos:
    h: 8
    w: 12
    x: 12
    "y": 16
  id: 54
  options:
    legend:
      calcs: []
      displayMode: list
      placement: bottom
      showLegend: true
    tooltip:
      mode: multi
      sort: desc
  pluginVersion: 8.3.3
  type: timeseries
- title: API Server - Errors by Instance
  targets:
  - datasource:
      type: {{ $defaultDatasource }}
      uid: ${datasource}
    expr: {{ printf "sum(rate(apiserver_request_total{code=~\"5..\",%s=~\"$cluster\",job=~\"$job\"}[$__rate_interval])) by(instance,%s) / sum(rate(apiserver_request_total{%s=~\"$cluster\",job=~\"$job\"}[$__rate_interval])) by(instance,%s)" $clusterLabel $clusterLabel $clusterLabel $clusterLabel }}
    exemplar: true
    interval: $resolution
    legendFormat: '{{`{{`}} instance {{`}}`}}'
    refId: A
  datasource:
    type: {{ $defaultDatasource }}
    uid: ${datasource}
  fieldConfig:
    defaults:
      color:
        mode: palette-classic
      custom:
        axisCenteredZero: false
        axisColorMode: text
        axisLabel: ""
        axisPlacement: auto
        barAlignment: 0
        drawStyle: line
        fillOpacity: 25
        gradientMode: opacity
        hideFrom:
          legend: false
          tooltip: false
          viz: false
        lineInterpolation: smooth
        lineWidth: 2
        pointSize: 5
        scaleDistribution:
          type: linear
        showPoints: never
        spanNulls: false
        stacking:
          group: A
          mode: none
        thresholdsStyle:
          mode: "off"
      mappings: []
      thresholds:
        mode: absolute
        steps:
        - color: green
          value: null
        - color: red
          value: 80
      unit: short
    overrides: []
  gridPos:
    h: 8
    w: 12
    x: 0
    "y": 24
  id: 50
  options:
    legend:
      calcs: []
      displayMode: list
      placement: bottom
      showLegend: true
    tooltip:
      mode: single
      sort: none
  pluginVersion: 8.3.3
  type: timeseries
- title: API Server - Errors by verb
  targets:
  - datasource:
      type: {{ $defaultDatasource }}
      uid: ${datasource}
    expr: {{ printf "sum(rate(apiserver_request_total{code=~\"5..\",%s=~\"$cluster\",job=~\"$job\"}[$__rate_interval])) by(verb,%s) / sum(rate(apiserver_request_total{%s=~\"$cluster\",job=~\"$job\"}[$__rate_interval])) by(verb,%s)" $clusterLabel $clusterLabel $clusterLabel $clusterLabel }}
    exemplar: true
    interval: $resolution
    legendFormat: '{{`{{`}} verb {{`}}`}}'
    refId: A
  datasource:
    type: {{ $defaultDatasource }}
    uid: ${datasource}
  fieldConfig:
    defaults:
      color:
        mode: palette-classic
      custom:
        axisCenteredZero: false
        axisColorMode: text
        axisLabel: ""
        axisPlacement: auto
        barAlignment: 0
        drawStyle: line
        fillOpacity: 25
        gradientMode: opacity
        hideFrom:
          legend: false
          tooltip: false
          viz: false
        lineInterpolation: smooth
        lineWidth: 2
        pointSize: 5
        scaleDistribution:
          type: linear
        showPoints: never
        spanNulls: false
        stacking:
          group: A
          mode: none
        thresholdsStyle:
          mode: "off"
      mappings: []
      thresholds:
        mode: absolute
        steps:
        - color: green
          value: null
        - color: red
          value: 80
      unit: short
    overrides: []
  gridPos:
    h: 8
    w: 12
    x: 12
    "y": 24
  id: 51
  options:
    legend:
      calcs: []
      displayMode: list
      placement: bottom
      showLegend: true
    tooltip:
      mode: multi
      sort: none
  pluginVersion: 8.3.3
  type: timeseries
- title: API Server - Stacked HTTP Requests by instance
  targets:
  - datasource:
      type: {{ $defaultDatasource }}
      uid: ${datasource}
    expr: {{ printf "sum(rate(apiserver_request_total{%s=~\"$cluster\"}[$__rate_interval])) by(instance,%s)" $clusterLabel $clusterLabel }}
    exemplar: true
    interval: $resolution
    legendFormat: '{{`{{`}} instance {{`}}`}}'
    refId: A
  datasource:
    type: {{ $defaultDatasource }}
    uid: ${datasource}
  fieldConfig:
    defaults:
      color:
        mode: palette-classic
      custom:
        axisCenteredZero: false
        axisColorMode: text
        axisLabel: ""
        axisPlacement: auto
        barAlignment: 0
        drawStyle: line
        fillOpacity: 25
        gradientMode: opacity
        hideFrom:
          legend: false
          tooltip: false
          viz: false
        lineInterpolation: smooth
        lineWidth: 2
        pointSize: 5
        scaleDistribution:
          type: linear
        showPoints: never
        spanNulls: false
        stacking:
          group: A
          mode: normal
        thresholdsStyle:
          mode: "off"
      mappings: []
      thresholds:
        mode: absolute
        steps:
        - color: green
          value: null
        - color: red
          value: 80
      unit: short
    overrides: []
  gridPos:
    h: 8
    w: 12
    x: 0
    "y": 32
  id: 40
  options:
    legend:
      calcs: []
      displayMode: list
      placement: bottom
      showLegend: true
    tooltip:
      mode: single
      sort: none
  pluginVersion: 8.3.3
  type: timeseries
- title: API Server - Work Queue by instance
  targets:
  - datasource:
      type: {{ $defaultDatasource }}
      uid: ${datasource}
    expr: {{ printf "sum(rate(workqueue_depth{%s=~\"$cluster\",job=~\"$job\"}[$__rate_interval])) by(instance,%s)" $clusterLabel $clusterLabel }}
    exemplar: true
    interval: $resolution
    legendFormat: '{{`{{`}} instance {{`}}`}}'
    refId: A
  datasource:
    type: {{ $defaultDatasource }}
    uid: ${datasource}
  fieldConfig:
    defaults:
      color:
        mode: palette-classic
      custom:
        axisCenteredZero: false
        axisColorMode: text
        axisLabel: ""
        axisPlacement: auto
        barAlignment: 0
        drawStyle: line
        fillOpacity: 25
        gradientMode: opacity
        hideFrom:
          legend: false
          tooltip: false
          viz: false
        lineInterpolation: smooth
        lineWidth: 2
        pointSize: 5
        scaleDistribution:
          type: linear
        showPoints: never
        spanNulls: false
        stacking:
          group: A
          mode: none
        thresholdsStyle:
          mode: "off"
      mappings: []
      thresholds:
        mode: absolute
        steps:
        - color: green
          value: null
        - color: red
          value: 80
      unit: short
    overrides: []
  gridPos:
    h: 8
    w: 12
    x: 12
    "y": 32
  id: 56
  options:
    legend:
      calcs: []
      displayMode: list
      placement: bottom
      showLegend: true
    tooltip:
      mode: single
      sort: none
  pluginVersion: 8.3.3
  type: timeseries
- title: API Server - CPU Usage by instance
  targets:
  - datasource:
      type: {{ $defaultDatasource }}
      uid: ${datasource}
    expr: {{ printf "rate(process_cpu_seconds_total{%s=~\"$cluster\",job=~\"$job\"}[$__rate_interval])" $clusterLabel }}
    exemplar: true
    interval: $resolution
    legendFormat: '{{`{{`}} instance {{`}}`}}'
    refId: A
  datasource:
    type: {{ $defaultDatasource }}
    uid: ${datasource}
  fieldConfig:
    defaults:
      color:
        mode: palette-classic
      custom:
        axisCenteredZero: false
        axisColorMode: text
        axisLabel: ""
        axisPlacement: auto
        barAlignment: 0
        drawStyle: line
        fillOpacity: 25
        gradientMode: opacity
        hideFrom:
          legend: false
          tooltip: false
          viz: false
        lineInterpolation: smooth
        lineWidth: 2
        pointSize: 5
        scaleDistribution:
          type: linear
        showPoints: never
        spanNulls: false
        stacking:
          group: A
          mode: none
        thresholdsStyle:
          mode: "off"
      decimals: 2
      mappings: []
      thresholds:
        mode: absolute
        steps:
        - color: green
          value: null
        - color: red
          value: 80
      unit: percent
    overrides: []
  gridPos:
    h: 8
    w: 12
    x: 0
    "y": 40
  id: 47
  options:
    legend:
      calcs: []
      displayMode: list
      placement: bottom
      showLegend: true
    tooltip:
      mode: single
      sort: none
  pluginVersion: 8.3.3
  type: timeseries
- title: API Server - Memory Usage by instance
  targets:
  - datasource:
      type: {{ $defaultDatasource }}
      uid: ${datasource}
    expr: {{ printf "process_resident_memory_bytes{%s=~\"$cluster\",job=~\"$job\"}" $clusterLabel }}
    exemplar: true
    interval: $resolution
    legendFormat: '{{`{{`}} instance {{`}}`}}'
    refId: A
  datasource:
    type: {{ $defaultDatasource }}
    uid: ${datasource}
  fieldConfig:
    defaults:
      color:
        mode: palette-classic
      custom:
        axisCenteredZero: false
        axisColorMode: text
        axisLabel: ""
        axisPlacement: auto
        barAlignment: 0
        drawStyle: line
        fillOpacity: 25
        gradientMode: opacity
        hideFrom:
          legend: false
          tooltip: false
          viz: false
        lineInterpolation: smooth
        lineWidth: 2
        pointSize: 5
        scaleDistribution:
          type: linear
        showPoints: never
        spanNulls: false
        stacking:
          group: A
          mode: none
        thresholdsStyle:
          mode: "off"
      mappings: []
      thresholds:
        mode: absolute
        steps:
        - color: green
          value: null
        - color: red
          value: 80
      unit: bytes
    overrides: []
  gridPos:
    h: 8
    w: 12
    x: 12
    "y": 40
  id: 48
  options:
    legend:
      calcs: []
      displayMode: list
      placement: bottom
      showLegend: true
    tooltip:
      mode: single
      sort: none
  pluginVersion: 8.3.3
  type: timeseries
__elements: []
__inputs:
- description: ""
  label: Prometheus
  name: DS_PROMETHEUS
  pluginId: prometheus
  pluginName: Prometheus
  type: datasource
__requires:
- id: grafana
  name: Grafana
  type: grafana
  version: 8.4.4
- id: prometheus
  name: Prometheus
  type: datasource
  version: 5.0.0
- id: timeseries
  name: Time series
  type: panel
  version: ""
- id: stat
  name: Stat
  type: panel
  version: ""
condition: {{ ($Values.kubeApiServer).enabled }}
description: 'This is a modern API Server dashboard for your Kubernetes cluster(s). Made for kube-prometheus-stack and take advantage of the latest Grafana features. GitHub repository: https://github.com/dotdc/grafana-dashboards-kubernetes'
fiscalYearStartMonth: 0
graphTooltip: 1
links: []
liveNow: false
refresh: 30s
schemaVersion: 38
style: dark
time:
  from: now-1h
  to: now
timepicker: {}
uid: k8s_system_apisrv
version: 20
weekStart: ""
