{{- $Values := (.helm).Values | default .Values }}
{{- $clusterLabel := ($Values.global).clusterLabel | default "cluster" }}
{{- $multicluster := ((($Values.grafana).sidecar).dashboards).multicluster | default false }}
{{- $defaultDatasource := "prometheus" -}}
{{- range (((($Values.grafana).sidecar).datasources).victoriametrics | default list) }}
  {{- if and .isDefault .type }}{{ $defaultDatasource = .type }}{{- end }}
{{- end }}
condition: {{ ($Values.kubeEtcd).enabled }}
description: etcd sample Grafana dashboard with Prometheus
editable: false
panels:
- datasource:
    type: {{ $defaultDatasource }}
    uid: -- Mixed --
  gridPos:
    h: 7
    w: 6
    x: 0
    'y': 0
  id: 1
  interval: 1m
  options:
    colorMode: none
    graphMode: none
    reduceOptions:
      calcs:
      - lastNotNull
  pluginVersion: v10.0.0
  targets:
  - datasource:
      type: {{ $defaultDatasource }}
      uid: $datasource
    expr: sum(etcd_server_has_leader{job=~".*etcd.*", {{ $clusterLabel }}=~"$cluster"})
    legendFormat: '{{`{{`}}cluster{{`}}`}} - {{`{{`}}namespace{{`}}`}}

      '
  title: Up
  type: stat
- datasource:
    type: {{ $defaultDatasource }}
    uid: -- Mixed --
  fieldConfig:
    defaults:
      custom:
        fillOpacity: 0
        lineWidth: 2
        showPoints: never
      unit: ops
  gridPos:
    h: 7
    w: 10
    x: 6
    'y': 0
  id: 2
  interval: 1m
  pluginVersion: v10.0.0
  targets:
  - datasource:
      type: {{ $defaultDatasource }}
      uid: $datasource
    expr: sum(rate(grpc_server_started_total{job=~".*etcd.*", {{ $clusterLabel }}=~"$cluster",grpc_type="unary"}[$__rate_interval]))
    legendFormat: RPC rate
  - datasource:
      type: {{ $defaultDatasource }}
      uid: $datasource
    expr: sum(rate(grpc_server_handled_total{job=~".*etcd.*", {{ $clusterLabel }}=~"$cluster",grpc_type="unary",grpc_code=~"Unknown|FailedPrecondition|ResourceExhausted|Internal|Unavailable|DataLoss|DeadlineExceeded"}[$__rate_interval]))
    legendFormat: RPC failed rate
  title: RPC rate
  type: timeseries
- datasource:
    type: {{ $defaultDatasource }}
    uid: -- Mixed --
  fieldConfig:
    defaults:
      custom:
        fillOpacity: 0
        lineWidth: 2
        showPoints: never
  gridPos:
    h: 7
    w: 8
    x: 16
    'y': 0
  id: 3
  interval: 1m
  pluginVersion: v10.0.0
  targets:
  - datasource:
      type: {{ $defaultDatasource }}
      uid: $datasource
    expr: sum(grpc_server_started_total{job=~".*etcd.*", {{ $clusterLabel }}=~"$cluster",grpc_service="etcdserverpb.Watch",grpc_type="bidi_stream"}) - sum(grpc_server_handled_total{ {{ $clusterLabel }}=~"$cluster",grpc_service="etcdserverpb.Watch",grpc_type="bidi_stream"})
    legendFormat: Watch streams
  - datasource:
      type: {{ $defaultDatasource }}
      uid: $datasource
    expr: sum(grpc_server_started_total{job=~".*etcd.*", {{ $clusterLabel }}=~"$cluster",grpc_service="etcdserverpb.Lease",grpc_type="bidi_stream"}) - sum(grpc_server_handled_total{ {{ $clusterLabel }}=~"$cluster",grpc_service="etcdserverpb.Lease",grpc_type="bidi_stream"})
    legendFormat: Lease streams
  title: Active streams
  type: timeseries
- datasource:
    type: {{ $defaultDatasource }}
    uid: -- Mixed --
  fieldConfig:
    defaults:
      custom:
        fillOpacity: 0
        lineWidth: 2
        showPoints: never
      unit: bytes
  gridPos:
    h: 7
    w: 8
    x: 0
    'y': 25
  id: 4
  interval: 1m
  pluginVersion: v10.0.0
  targets:
  - datasource:
      type: {{ $defaultDatasource }}
      uid: $datasource
    expr: etcd_mvcc_db_total_size_in_bytes{job=~".*etcd.*", {{ $clusterLabel }}=~"$cluster"}
    legendFormat: '{{`{{`}}instance{{`}}`}} DB size'
  title: DB size
  type: timeseries
- datasource:
    type: {{ $defaultDatasource }}
    uid: -- Mixed --
  fieldConfig:
    defaults:
      custom:
        fillOpacity: 0
        lineWidth: 2
        showPoints: never
      unit: s
  gridPos:
    h: 7
    w: 8
    x: 8
    'y': 25
  id: 5
  interval: 1m
  pluginVersion: v10.0.0
  targets:
  - datasource:
      type: {{ $defaultDatasource }}
      uid: $datasource
    expr: histogram_quantile(0.99, sum(rate(etcd_disk_wal_fsync_duration_seconds_bucket{job=~".*etcd.*", {{ $clusterLabel }}=~"$cluster"}[$__rate_interval])) by (instance, le))
    legendFormat: '{{`{{`}}instance{{`}}`}} WAL fsync'
  - datasource:
      type: {{ $defaultDatasource }}
      uid: $datasource
    expr: histogram_quantile(0.99, sum(rate(etcd_disk_backend_commit_duration_seconds_bucket{job=~".*etcd.*", {{ $clusterLabel }}=~"$cluster"}[$__rate_interval])) by (instance, le))
    legendFormat: '{{`{{`}}instance{{`}}`}} DB fsync'
  title: Disk sync duration
  type: timeseries
- datasource:
    type: {{ $defaultDatasource }}
    uid: -- Mixed --
  fieldConfig:
    defaults:
      custom:
        fillOpacity: 0
        lineWidth: 2
        showPoints: never
      unit: bytes
  gridPos:
    h: 7
    w: 8
    x: 16
    'y': 25
  id: 6
  interval: 1m
  pluginVersion: v10.0.0
  targets:
  - datasource:
      type: {{ $defaultDatasource }}
      uid: $datasource
    expr: process_resident_memory_bytes{job=~".*etcd.*", {{ $clusterLabel }}=~"$cluster"}
    legendFormat: '{{`{{`}}instance{{`}}`}} resident memory'
  title: Memory
  type: timeseries
- datasource:
    type: {{ $defaultDatasource }}
    uid: -- Mixed --
  fieldConfig:
    defaults:
      custom:
        fillOpacity: 0
        lineWidth: 2
        showPoints: never
      unit: Bps
  gridPos:
    h: 7
    w: 6
    x: 0
    'y': 50
  id: 7
  interval: 1m
  pluginVersion: v10.0.0
  targets:
  - datasource:
      type: {{ $defaultDatasource }}
      uid: $datasource
    expr: rate(etcd_network_client_grpc_received_bytes_total{job=~".*etcd.*", {{ $clusterLabel }}=~"$cluster"}[$__rate_interval])
    legendFormat: '{{`{{`}}instance{{`}}`}} client traffic in'
  title: Client traffic in
  type: timeseries
- datasource:
    type: {{ $defaultDatasource }}
    uid: -- Mixed --
  fieldConfig:
    defaults:
      custom:
        fillOpacity: 0
        lineWidth: 2
        showPoints: never
      unit: Bps
  gridPos:
    h: 7
    w: 6
    x: 6
    'y': 50
  id: 8
  interval: 1m
  pluginVersion: v10.0.0
  targets:
  - datasource:
      type: {{ $defaultDatasource }}
      uid: $datasource
    expr: rate(etcd_network_client_grpc_sent_bytes_total{job=~".*etcd.*", {{ $clusterLabel }}=~"$cluster"}[$__rate_interval])
    legendFormat: '{{`{{`}}instance{{`}}`}} client traffic out'
  title: Client traffic out
  type: timeseries
- datasource:
    type: {{ $defaultDatasource }}
    uid: -- Mixed --
  fieldConfig:
    defaults:
      custom:
        fillOpacity: 0
        lineWidth: 2
        showPoints: never
      unit: Bps
  gridPos:
    h: 7
    w: 6
    x: 12
    'y': 50
  id: 9
  interval: 1m
  pluginVersion: v10.0.0
  targets:
  - datasource:
      type: {{ $defaultDatasource }}
      uid: $datasource
    expr: sum(rate(etcd_network_peer_received_bytes_total{job=~".*etcd.*", {{ $clusterLabel }}=~"$cluster"}[$__rate_interval])) by (instance)
    legendFormat: '{{`{{`}}instance{{`}}`}} peer traffic in'
  title: Peer traffic in
  type: timeseries
- datasource:
    type: {{ $defaultDatasource }}
    uid: -- Mixed --
  fieldConfig:
    defaults:
      custom:
        fillOpacity: 0
        lineWidth: 2
        showPoints: never
      unit: Bps
  gridPos:
    h: 7
    w: 6
    x: 18
    'y': 50
  id: 10
  interval: 1m
  pluginVersion: v10.0.0
  targets:
  - datasource:
      type: {{ $defaultDatasource }}
      uid: $datasource
    expr: sum(rate(etcd_network_peer_sent_bytes_total{job=~".*etcd.*", {{ $clusterLabel }}=~"$cluster"}[$__rate_interval])) by (instance)
    legendFormat: '{{`{{`}}instance{{`}}`}} peer traffic out'
  title: Peer traffic out
  type: timeseries
- datasource:
    type: {{ $defaultDatasource }}
    uid: -- Mixed --
  fieldConfig:
    defaults:
      custom:
        fillOpacity: 0
        lineWidth: 2
        showPoints: never
  gridPos:
    h: 7
    w: 8
    x: 0
    'y': 75
  id: 11
  interval: 1m
  pluginVersion: v10.0.0
  targets:
  - datasource:
      type: {{ $defaultDatasource }}
      uid: $datasource
    expr: changes(etcd_server_leader_changes_seen_total{job=~".*etcd.*", {{ $clusterLabel }}=~"$cluster"}[1d])
    legendFormat: '{{`{{`}}instance{{`}}`}} total leader elections per day'
  title: Raft proposals
  type: timeseries
- datasource:
    type: {{ $defaultDatasource }}
    uid: -- Mixed --
  fieldConfig:
    defaults:
      custom:
        fillOpacity: 0
        lineWidth: 2
        showPoints: never
  gridPos:
    h: 7
    w: 8
    x: 8
    'y': 75
  id: 12
  interval: 1m
  pluginVersion: v10.0.0
  targets:
  - datasource:
      type: {{ $defaultDatasource }}
      uid: $datasource
    expr: changes(etcd_server_leader_changes_seen_total{job=~".*etcd.*", {{ $clusterLabel }}=~"$cluster"}[1d])
    legendFormat: '{{`{{`}}instance{{`}}`}} total leader elections per day'
  title: Total leader elections per day
  type: timeseries
- datasource:
    type: {{ $defaultDatasource }}
    uid: -- Mixed --
  fieldConfig:
    defaults:
      custom:
        fillOpacity: 0
        lineWidth: 2
        showPoints: never
      unit: s
  gridPos:
    h: 7
    w: 8
    x: 16
    'y': 75
  id: 13
  interval: 1m
  pluginVersion: v10.0.0
  targets:
  - datasource:
      type: {{ $defaultDatasource }}
      uid: $datasource
    expr: histogram_quantile(0.99, sum by (instance, le) (rate(etcd_network_peer_round_trip_time_seconds_bucket{job=~".*etcd.*", {{ $clusterLabel }}=~"$cluster"}[$__rate_interval])))
    legendFormat: '{{`{{`}}instance{{`}}`}} peer round trip time'
  title: Peer round trip time
  type: timeseries
refresh: 10s
schemaVersion: 36
tags:
- etcd-mixin
- vm-k8s-stack
templating:
  list:
  - label: Data Source
    name: datasource
    query: {{ $defaultDatasource }}
    type: datasource
  - datasource:
      type: prometheus
      uid: ${datasource}
    hide: {{ ternary 0 2 $multicluster }}
    label: cluster
    name: cluster
    query: {{ ternary (b64dec "ImxhYmVsX3ZhbHVlcyhldGNkX3NlcnZlcl9oYXNfbGVhZGVye2pvYj1+XCIuKmV0Y2QuKlwifSwgY2x1c3Rlciki" | replace "cluster" $clusterLabel) ".*" $multicluster }}
    refresh: 2
    type: {{ ternary "query" "constant" $multicluster }}
time:
  from: now-15m
  to: now
timezone: {{ default "utc" ($Values.defaultDashboards).defaultTimezone }}
title: etcd
uid: c2f4e12cdf69feb95caa41a5a1b423d9
