### Dashboard Hierarchy Example Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/README.md Visualizes the drill-down pattern of the Views dashboards, starting from a global cluster view down to specific resources. ```text Global (cluster-wide) ↓ Namespaces (team/project scope) ↓ Nodes (infrastructure scope) | Pods (workload scope) ``` -------------------------------- ### Clone Repository and Navigate Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/README.md Clone the Grafana dashboards repository and navigate into the directory. This is the initial step for most installation methods. ```bash git clone https://github.com/dotdc/grafana-dashboards-kubernetes.git cd grafana-dashboards-kubernetes ``` -------------------------------- ### Install GrafanaDashboards with Grafana Operator Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/README.md Use these manifests to provision Grafana dashboards when using the Grafana Operator. Ensure you specify the correct namespace. ```yaml apiVersion: grafana.integreatly.org/v1beta1 kind: GrafanaDashboard metadata: name: k8s-system-api-server namespace: monitoring spec: instanceSelector: matchLabels: dashboards: "grafana" url: "https://raw.githubusercontent.com/dotdc/grafana-dashboards-kubernetes/master/dashboards/k8s-system-api-server.json" --- apiVersion: grafana.integreatly.org/v1beta1 kind: GrafanaDashboard metadata: name: k8s-system-coredns namespace: monitoring spec: instanceSelector: matchLabels: dashboards: "grafana" url: "https://raw.githubusercontent.com/dotdc/grafana-dashboards-kubernetes/master/dashboards/k8s-system-coredns.json" --- apiVersion: grafana.integreatly.org/v1beta1 kind: GrafanaDashboard metadata: name: k8s-views-global namespace: monitoring spec: instanceSelector: matchLabels: dashboards: "grafana" url: "https://raw.githubusercontent.com/dotdc/grafana-dashboards-kubernetes/master/dashboards/k8s-views-global.json" --- apiVersion: grafana.integreatly.org/v1beta1 kind: GrafanaDashboard metadata: name: k8s-views-namespaces namespace: monitoring spec: instanceSelector: matchLabels: dashboards: "grafana" url: "https://raw.githubusercontent.com/dotdc/grafana-dashboards-kubernetes/master/dashboards/k8s-views-namespaces.json" --- apiVersion: grafana.integreatly.org/v1beta1 kind: GrafanaDashboard metadata: name: k8s-views-nodes namespace: monitoring spec: instanceSelector: matchLabels: dashboards: "grafana" url: "https://raw.githubusercontent.com/dotdc/grafana-dashboards-kubernetes/master/dashboards/k8s-views-nodes.json" --- apiVersion: grafana.integreatly.org/v1beta1 kind: GrafanaDashboard metadata: name: k8s-views-pods namespace: monitoring spec: instanceSelector: matchLabels: dashboards: "grafana" url: "https://raw.githubusercontent.com/dotdc/grafana-dashboards-kubernetes/master/dashboards/k8s-views-pods.json" ``` -------------------------------- ### Complete Minimal Dashboard Example Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/types.md A basic Grafana dashboard JSON structure including a timeseries panel, Prometheus datasource target, templating, and time settings. This serves as a starting point for creating custom dashboards. ```json { "title": "Simple Dashboard", "uid": "simple-dashboard", "timezone": "browser", "panels": [ { "id": 1, "type": "timeseries", "title": "Request Rate", "gridPos": {"x": 0, "y": 0, "w": 12, "h": 8}, "targets": [ { "expr": "rate(http_requests_total[5m])", "refId": "A", "datasource": { "type": "prometheus", "uid": "prometheus_uid" } } ], "fieldConfig": { "defaults": {"unit": "rps"}, "overrides": [] }, "options": {} } ], "templating": { "list": [ { "name": "datasource", "type": "datasource", "current": {"text": "Prometheus", "value": "prometheus"} } ] }, "time": {"from": "now-6h", "to": "now"}, "refresh": "30s" } ``` -------------------------------- ### Pods with Container Issues (Image Pull or Crash Loop) Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-views-pods.md Identifies pods that are in a waiting state due to image pull issues or crash loops. Use this to find pods that are failing to start. ```PromQL kube_pod_container_status_waiting_reason{reason=~"ErrImagePull|ImagePullBackOff|CrashLoopBackOff"} == 1 ``` -------------------------------- ### Install Trivy Operator using Helm Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/addon-dashboards.md This YAML defines a Kubernetes namespace for Trivy Operator and provides Helm commands to install the operator, specifying the image registry. ```yaml apiVersion: v1 kind: Namespace metadata: name: trivy-system --- # Install via Helm or Kustomize helm repo add aqua https://aquasecurity.github.io/helm-charts/ helm install trivy-operator aqua/trivy-operator \ -n trivy-system \ --set trivy.imageRegistry=docker.io ``` -------------------------------- ### AlertRule Example Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/types.md An example structure for an alert rule definition. Note that alerts are configured separately in Grafana and not directly within dashboards. ```json { "uid": "alert_1", "title": "Alert Title", "condition": "A", "data": [ {"refId": "A", "queryType": "", "model": {...}} ], "noDataState": "NoData", "execErrState": "Alerting" } ``` -------------------------------- ### Documentation Structure Hierarchy Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/MANIFEST.md Illustrates the hierarchical organization of the documentation files, showing how the main entry point leads to overview, category guides, and detailed API references. ```plaintext README.md (entry point) ├── index.md (overview) ├── configuration.md (setup) ├── views-dashboards.md (category guide) │ └── api-reference/k8s-views-*.md (details) ├── system-dashboards.md (category guide) │ └── api-reference/k8s-system-*.md (details) ├── addon-dashboards.md (category guide) │ └── api-reference/k8s-addons-*.md (details) ├── variables.md (reference) ├── types.md (reference) └── metrics-and-queries.md (reference) ``` -------------------------------- ### Install Dashboards with Helm Values Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/README.md Add or merge this block into your helm chart values to provision dashboards. This example is for kube-prometheus-stack; adjust for the official Grafana helm chart by removing the 'grafana:' prefix and reducing indentation. ```yaml grafana: # Provision grafana-dashboards-kubernetes dashboardProviders: dashboardproviders.yaml: apiVersion: 1 providers: - name: 'grafana-dashboards-kubernetes' orgId: 1 folder: 'Kubernetes' type: file disableDeletion: true editable: true options: path: /var/lib/grafana/dashboards/grafana-dashboards-kubernetes dashboards: grafana-dashboards-kubernetes: k8s-system-api-server: url: https://raw.githubusercontent.com/dotdc/grafana-dashboards-kubernetes/master/dashboards/k8s-system-api-server.json token: '' k8s-system-coredns: url: https://raw.githubusercontent.com/dotdc/grafana-dashboards-kubernetes/master/dashboards/k8s-system-coredns.json token: '' k8s-views-global: url: https://raw.githubusercontent.com/dotdc/grafana-dashboards-kubernetes/master/dashboards/k8s-views-global.json token: '' k8s-views-namespaces: url: https://raw.githubusercontent.com/dotdc/grafana-dashboards-kubernetes/master/dashboards/k8s-views-namespaces.json token: '' k8s-views-nodes: url: https://raw.githubusercontent.com/dotdc/grafana-dashboards-kubernetes/master/dashboards/k8s-views-nodes.json token: '' k8s-views-pods: url: https://raw.githubusercontent.com/dotdc/grafana-dashboards-kubernetes/master/dashboards/k8s-views-pods.json token: '' ``` -------------------------------- ### Deploy Dashboards with ArgoCD Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/README.md Apply the ArgoCD application manifest to deploy dashboards. Ensure the Grafana sidecar is configured as per the installation instructions. ```bash kubectl apply -f argocd-app.yml ``` -------------------------------- ### FieldConfigOverride Example Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/types.md Defines how to override specific field properties based on a matcher condition. Use this to customize the appearance of series that meet certain criteria. ```json { "matcher": {"id": "byName", "options": "Series 1"}, "properties": [ {"id": "color", "value": {"mode": "fixed", "fixedColor": "green"}} ] } ``` -------------------------------- ### Filesystem Usage in % Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-views-nodes.md Calculates the percentage of disk space used on a filesystem for a given instance and cluster. ```PromQL 100 - ((node_filesystem_avail_bytes{instance="$instance", cluster="$cluster"} * 100) / node_filesystem_size_bytes{instance="$instance", cluster="$clus... ``` -------------------------------- ### Build ConfigMaps for Grafana Sidecar Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/README.md Use this command to build ConfigMaps from kustomization and output them to STDOUT. The namespace is not set by default and can be changed in `kustomization.yaml`. ```terminal kubectl kustomize . ``` -------------------------------- ### Available Replicas by Deployment Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-views-namespaces.md Query the number of available replicas for each deployment within specified namespaces and clusters. ```PromQL sum(kube_deployment_status_replicas_available{namespace=~"$namespace", cluster="$cluster"}) by (deployment) ``` -------------------------------- ### Network I/O by Namespace Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/views-dashboards.md Calculates the network receive bandwidth per pod within a specified namespace using `container_network_receive_bytes_total`. ```promql # Network I/O by namespace sum by (pod_name) ( rate(container_network_receive_bytes_total{cluster=~"$cluster", namespace="$namespace"}[$__rate_interval]) ) ``` -------------------------------- ### List Image Vulnerability Resources Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/addon-dashboards.md This command lists all ImageVulnerability custom resources across all namespaces, showing detected vulnerabilities in container images. ```bash kubectl get imagevulnerability -A ``` -------------------------------- ### Persistent Volumes - Capacity and Usage in % Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-views-namespaces.md Calculate the percentage of used capacity for Persistent Volume Claims, aggregated by persistent volume claim and namespace. ```PromQL max(kubelet_volume_stats_used_bytes{namespace=~"$namespace", cluster="$cluster"}) by (persistentvolumeclaim, namespace) / max(kubelet_volume_stats_cap... ``` -------------------------------- ### TimeRange Object Schema Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/types.md Defines the start and end times for a dashboard's time range. Supports relative time expressions or ISO timestamps. ```json { "from": "now-6h", "to": "now" } ``` -------------------------------- ### Get Top N Metric Values Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/metrics-and-queries.md Retrieves the top N highest values for a given metric. Useful for identifying the most significant contributors or outliers. ```prometheus topk(n, metric) ``` -------------------------------- ### Kubernetes Dashboard File Structure Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/README.md Illustrates the hierarchical organization of dashboard definition files and API reference documentation within the project. ```directory output/ ├── README.md # This file ├── index.md # Dashboard overview ├── configuration.md # Installation & deployment ├── variables.md # Template variables reference ├── types.md # JSON schema definitions ├── metrics-and-queries.md # Prometheus metrics catalog ├── views-dashboards.md # Hierarchical monitoring dashboards ├── system-dashboards.md # System component dashboards ├── addon-dashboards.md # Addon tool dashboards └── api-reference/ # Detailed dashboard specs ├── k8s-views-global.md ├── k8s-views-namespaces.md ├── k8s-views-nodes.md ├── k8s-views-pods.md ├── k8s-system-api-server.md ├── k8s-system-coredns.md ├── k8s-addons-prometheus.md └── k8s-addons-trivy-operator.md ``` -------------------------------- ### CPU Usage vs. Requests & Limits by Container Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-views-pods.md Compares the rate of CPU usage against requested and limited CPU by container. Use this to identify potential CPU bottlenecks or over-provisioning. ```PromQL sum(rate(container_cpu_usage_seconds_total{namespace="$namespace", pod=~"$pod", image!="", cluster="$cluster"}[$__rate_interval])) by (container) / su... ``` ```PromQL sum(rate(container_cpu_usage_seconds_total{namespace="$namespace", pod=~"$pod", image!="", cluster="$cluster"}[$__rate_interval])) by (container) / su... ``` -------------------------------- ### Get Created By Labels Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-views-namespaces.md Fetches unique 'created_by_name' labels from 'kube_pod_info' metric, filtered by selected namespaces and cluster. Used for filtering by creation source. ```Prometheus Query Language label_values(kube_pod_info{namespace=~"$namespace", cluster="$cluster"},created_by_name) ``` -------------------------------- ### CPU Throttled Seconds by Namespace Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-views-global.md Monitors CPU throttling in seconds per namespace, highlighting namespaces experiencing CPU contention. Alerts when throttling exceeds zero. ```PromQL sum(rate(container_cpu_cfs_throttled_seconds_total{image!="", cluster="$cluster"}[$__rate_interval])) by (namespace) > 0 ``` -------------------------------- ### API Server Stacked HTTP Requests by Instance Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/system-dashboards.md Shows the total API server requests stacked per instance. This visualization helps understand the distribution of request load across different instances. ```PromQL sum(rate(apiserver_request_total[$__rate_interval])) by (instance) ``` -------------------------------- ### Configure Prometheus Datasource via YAML Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/configuration.md Provision a Prometheus datasource in Grafana using YAML configuration. This is useful for automated setup and ensuring dashboards have access to metrics. ```yaml apiVersion: 1 datasources: - name: Prometheus type: prometheus url: http://prometheus:9090 access: proxy isDefault: true ``` -------------------------------- ### Get Namespace Labels Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-views-namespaces.md Fetches all unique values for the 'namespace' label from the 'kube_pod_info' metric, filtered by the selected cluster. Used for populating the namespace selection variable. ```Prometheus Query Language label_values(kube_pod_info{cluster="$cluster"}, namespace) ``` -------------------------------- ### Filesystem Inode Usage in % Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-views-nodes.md Calculates the percentage of inodes used on a filesystem for a given instance and cluster. ```PromQL 100 - (node_filesystem_files_free{instance="$instance", cluster="$cluster"} / node_filesystem_files{instance="$instance", cluster="$cluster"} * 100) ``` -------------------------------- ### Kubernetes Nodes View Dashboard Configuration Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-views-nodes.md This dashboard is preconfigured for a Prometheus setup, supporting variable-based datasource selection and a configurable scrape interval. It utilizes specific labels for data filtering. ```json { "datasource": "Prometheus", "scrapeInterval": "30s", "labels": { "cluster": null, "job": null, "instance": null, "pod": null, "namespace": null, "node": null } } ``` -------------------------------- ### Deploying Kustomization Configuration Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/configuration.md Apply the Kustomization configuration to deploy Grafana dashboards to a Kubernetes cluster. Ensure the target namespace is correctly specified. ```bash kubectl apply -k . -n monitoring ``` -------------------------------- ### Persistent Volumes Usage in % Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-views-nodes.md Calculates the percentage of used space for persistent volume claims on a node. ```PromQL max(kubelet_volume_stats_used_bytes{node="$node", cluster="$cluster"}) by (persistentvolumeclaim, namespace) / max(kubelet_volume_stats_capacity_bytes... ``` -------------------------------- ### API Server HTTP Requests by Verb Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/system-dashboards.md Tracks the rate of API server requests, broken down by HTTP verb (GET, POST, PUT, etc.). Helps identify the most frequent API operations. ```PromQL sum by (verb) (rate(apiserver_request_total[$__rate_interval])) ``` -------------------------------- ### Scan Image using Trivy CLI Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/addon-dashboards.md This command demonstrates how to scan a container image using the Trivy CLI. It's typically used in CI/CD pipelines before pushing images to a registry. ```bash # Use Trivy CLI: `trivy image myapp:latest` ``` -------------------------------- ### Prometheus Query for Uptime Stat Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-views-nodes.md Calculates the uptime of a selected instance and cluster by subtracting the boot time from the current time. ```prometheus sum(node_time_seconds{instance="$instance", cluster="$cluster"} - node_boot_time_seconds{instance="$instance", cluster="$cluster"}) ``` -------------------------------- ### Available Disk Space Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/views-dashboards.md Shows available disk space for a given mount point, excluding temporary file systems. Useful for disk capacity monitoring. ```promql node_filesystem_avail_bytes{fstype!="tmpfs", mountpoint="/"} ``` -------------------------------- ### CPU Utilization by Instance Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-views-global.md Calculates the average CPU utilization per instance, excluding idle, iowait, and steal modes. Useful for identifying high CPU load on specific nodes. ```PromQL avg(sum by (instance, cpu) (rate(node_cpu_seconds_total{mode!~"idle|iowait|steal", cluster="$cluster", job="$job"}[$__rate_interval]))) by (instance) ``` -------------------------------- ### Memory Utilization by Instance Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-views-global.md Calculates memory utilization per instance by subtracting available memory from total memory. Helps pinpoint memory-intensive nodes. ```PromQL sum(node_memory_MemTotal_bytes{cluster="$cluster", job="$job"} - node_memory_MemAvailable_bytes{cluster="$cluster", job="$job"}) by (instance) ``` -------------------------------- ### TCP Connections Established Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-views-nodes.md Shows the current number of TCP connections that are in the established state for a given instance and cluster. ```PromQL node_netstat_Tcp_CurrEstab{instance="$instance", cluster="$cluster"} ``` -------------------------------- ### Target Sync Length Query Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-addons-prometheus.md Calculates the target synchronization length in milliseconds, broken down by pod and scrape job. Useful for identifying synchronization delays. ```PromQL sum(rate(prometheus_target_sync_length_seconds_sum{pod=~"$pod", cluster=~"$cluster"}[$__rate_interval])) by (pod, scrape_job) * 1000 ``` -------------------------------- ### System Load Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-views-nodes.md Retrieves the system load averages for the last 1, 5, and 15 minutes for a specified instance and cluster. ```PromQL node_load1{instance="$instance", cluster="$cluster"} ``` ```PromQL node_load5{instance="$instance", cluster="$cluster"} ``` ```PromQL node_load15{instance="$instance", cluster="$cluster"} ``` -------------------------------- ### DNS Queries by Zone (Table) Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/system-dashboards.md Provides a tabular view of DNS query counts per zone, offering precise figures for analysis. Useful for detailed examination of zone-specific traffic. ```PromQL coredns_dns_requests_total ``` -------------------------------- ### OOM Events by Namespace and Pod Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-views-namespaces.md Count Out-Of-Memory (OOM) events for containers, aggregated by namespace and pod. Only shows pods with OOM events. ```PromQL sum(increase(container_oom_events_total{namespace=~"${namespace}", cluster="$cluster"}[$__rate_interval])) by (namespace, pod) > 0 ``` -------------------------------- ### Container Restarts by Namespace and Pod Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-views-namespaces.md Count container restarts, aggregated by namespace and pod. Only shows pods with restarts. ```PromQL sum(increase(kube_pod_container_status_restarts_total{namespace=~"${namespace}", cluster="$cluster"}[$__rate_interval])) by (namespace, pod) > 0 ``` -------------------------------- ### File Descriptors Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-views-nodes.md Provides the maximum and currently allocated file descriptors for a given instance and cluster. ```PromQL node_filefd_maximum{instance="$instance", cluster="$cluster"} ``` ```PromQL node_filefd_allocated{instance="$instance", cluster="$cluster"} ``` -------------------------------- ### CPU Usage by Node Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-views-nodes.md Calculates the average CPU usage percentage across all modes for a given instance and cluster. ```PromQL avg(rate(node_cpu_seconds_total{instance="$instance", cluster="$cluster"}[$__rate_interval]) * 100) by (mode) ``` -------------------------------- ### Network Bandwidth by Pod Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-views-namespaces.md Calculate the network receive and transmit bandwidth rates for pods, filtered by namespace and cluster. Filters for pods matching the created_by pattern. ```PromQL sum(rate(container_network_receive_bytes_total{namespace=~"$namespace", pod=~"${created_by}.*", cluster="$cluster"}[$__rate_interval])) by (pod) ``` ```PromQL - sum(rate(container_network_transmit_bytes_total{namespace=~"$namespace", pod=~"${created_by}.*", cluster="$cluster"}[$__rate_interval])) by (pod) ``` -------------------------------- ### Memory Usage by Node Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-views-nodes.md Provides queries to calculate total memory, cached memory, buffered memory, free memory, and used swap space for a node. ```PromQL node_memory_MemTotal_bytes{instance="$instance", cluster="$cluster"} - node_memory_MemFree_bytes{instance="$instance", cluster="$cluster"} - (node_mem... ``` ```PromQL node_memory_MemTotal_bytes{instance="$instance", cluster="$cluster"} ``` ```PromQL node_memory_Cached_bytes{instance="$instance", cluster="$cluster"} ``` ```PromQL node_memory_Buffers_bytes{instance="$instance", cluster="$cluster"} ``` ```PromQL node_memory_MemFree_bytes{instance="$instance", cluster="$cluster"} ``` ```PromQL node_memory_SwapTotal_bytes{instance="$instance", cluster="$cluster"} - node_memory_SwapFree_bytes{instance="$instance", cluster="$cluster"} ``` ```PromQL node_memory_SwapTotal_bytes{instance="$instance", cluster="$cluster"} ``` -------------------------------- ### Total Config Audit Report by Namespaces Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-addons-trivy-operator.md Query to count total configuration audit reports, grouped by namespace. It utilizes the trivy_resource_configaudits metric. ```PromQL sum(trivy_resource_configaudits{cluster=~"$cluster", namespace=~"$namespace"}) by (namespace) ``` -------------------------------- ### Memory Usage vs. Requests & Limits by Container Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-views-pods.md Compares the working set memory usage against requested memory by container. Use this to identify potential memory issues or inefficient allocation. ```PromQL sum(container_memory_working_set_bytes{namespace="$namespace", pod=~"$pod", image!="", cluster="$cluster"}) by (container) / sum(kube_pod_container_re... ``` ```PromQL sum(container_memory_working_set_bytes{namespace="$namespace", pod=~"$pod", image!="", cluster="$cluster"}) by (container) / sum(kube_pod_container_re... ``` -------------------------------- ### Pod Counts by State Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-views-namespaces.md Count pods based on their readiness, running, waiting, restart, and terminated states within specified namespaces and clusters. Filters for pods matching the created_by pattern. ```PromQL sum(kube_pod_container_status_ready{namespace=~"$namespace", pod=~"${created_by}.*", cluster="$cluster"}) ``` ```PromQL sum(kube_pod_container_status_running{namespace=~"$namespace", pod=~"${created_by}.*", cluster="$cluster"}) ``` ```PromQL sum(kube_pod_container_status_waiting{namespace=~"$namespace", cluster="$cluster"}) ``` ```PromQL sum(kube_pod_container_status_restarts_total{namespace=~"$namespace", cluster="$cluster"}) ``` ```PromQL sum(kube_pod_container_status_terminated{namespace=~"$namespace", cluster="$cluster"}) ``` -------------------------------- ### Persistent Volumes - Capacity and Usage in Bytes Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-views-namespaces.md Query the used and total capacity in bytes for Persistent Volume Claims, aggregated by persistent volume claim and namespace. ```PromQL max(kubelet_volume_stats_used_bytes{namespace=~"$namespace", cluster="$cluster"}) by (persistentvolumeclaim, namespace) ``` ```PromQL max(kubelet_volume_stats_capacity_bytes{namespace=~"$namespace", cluster="$cluster"}) by (persistentvolumeclaim, namespace) ``` -------------------------------- ### CPU Utilization by Namespace Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-views-global.md Aggregates CPU usage by namespace, filtering out containers without an image. This helps identify which namespaces are consuming the most CPU resources. ```PromQL sum(rate(container_cpu_usage_seconds_total{image!="", cluster="$cluster"}[$__rate_interval])) by (namespace) ``` -------------------------------- ### Total Vulnerabilities by Severity in Selected Namespace(s) Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-addons-trivy-operator.md Query to show the total vulnerabilities grouped by severity within the selected namespaces. It aggregates the trivy_image_vulnerabilities metric. ```PromQL sum(max by (namespace, image_registry, image_repository, image_tag, severity) (trivy_image_vulnerabilities{cluster=~"$cluster"})) by (severity) ``` -------------------------------- ### DNS Queries by Type Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/system-dashboards.md Analyzes the distribution of DNS query types (e.g., A, AAAA, SRV, MX). Helps understand the nature of DNS lookups in the cluster. ```PromQL sum by (type) (rate(coredns_dns_requests_total[$__rate_interval])) ``` -------------------------------- ### Pod Liveness Query Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-addons-prometheus.md Monitors the liveness of pods within a cluster. Use this to check if pods are running and healthy. ```PromQL up{pod=~"$pod", cluster=~"$cluster"} ``` -------------------------------- ### Memory Usage by Workload Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/views-dashboards.md Calculates memory usage per workload (Deployment/StatefulSet) by joining container memory data with pod owner information. ```promql # Memory by workload sum by (owner_name, owner_kind) ( container_memory_working_set_bytes{cluster=~"$cluster", namespace="$namespace"} * on(pod_name) group_left(owner_name, owner_kind) kube_pod_owner{cluster=~"$cluster", namespace="$namespace"} ) ``` -------------------------------- ### Kubernetes Resource Counts Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-views-global.md Provides queries to count various Kubernetes resources like namespaces, pods, services, deployments, and more. Useful for understanding the scale and composition of your cluster. ```PromQL sum(kube_namespace_labels{cluster="$cluster"}) ``` ```PromQL sum(kube_pod_container_status_running{cluster="$cluster"}) ``` ```PromQL sum(kube_pod_status_phase{phase="Running", cluster="$cluster"}) ``` ```PromQL sum(kube_service_info{cluster="$cluster"}) ``` ```PromQL sum(kube_endpoint_info{cluster="$cluster"}) ``` ```PromQL sum(kube_ingress_info{cluster="$cluster"}) ``` ```PromQL sum(kube_deployment_labels{cluster="$cluster"}) ``` ```PromQL sum(kube_statefulset_labels{cluster="$cluster"}) ``` ```PromQL sum(kube_daemonset_labels{cluster="$cluster"}) ``` ```PromQL sum(kube_persistentvolumeclaim_info{cluster="$cluster"}) ``` ```PromQL sum(kube_hpa_labels{cluster="$cluster"}) ``` ```PromQL sum(kube_configmap_info{cluster="$cluster"}) ``` ```PromQL sum(kube_secret_info{cluster="$cluster"}) ``` ```PromQL sum(kube_networkpolicy_labels{cluster="$cluster"}) ``` ```PromQL count(count by (node) (kube_node_info{cluster="$cluster"})) ``` -------------------------------- ### Persistent Volume Capacity and Usage Bytes Queries Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-addons-prometheus.md Provides the used bytes and total capacity for persistent volumes matching the 'prom' pattern, aggregated by persistent volume claim and namespace. ```PromQL max(kubelet_volume_stats_used_bytes{persistentvolumeclaim=~".*prom.*", cluster=~"$cluster"}) by (persistentvolumeclaim, namespace) ``` ```PromQL max(kubelet_volume_stats_capacity_bytes{persistentvolumeclaim=~".*prom.*", cluster=~"$cluster"}) by (persistentvolumeclaim, namespace) ``` -------------------------------- ### Convert Kustomize to Terraform using tfk8s Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/configuration.md Convert Kustomize configurations into Terraform HCL using the `tfk8s` tool. This facilitates managing Kubernetes resources, including Grafana dashboards, as Infrastructure as Code. ```bash kubectl kustomize . | tfk8s | tee main.tf ``` -------------------------------- ### Persistent Volume Usage Percentage Query Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-addons-prometheus.md Calculates the percentage of used capacity for persistent volumes matching the 'prom' pattern, aggregated by persistent volume claim and namespace. Note: The provided query is truncated. ```PromQL max(kubelet_volume_stats_used_bytes{persistentvolumeclaim=~".*prom.*", cluster=~"$cluster"}) by (persistentvolumeclaim, namespace) / max(kubelet_volum... ``` -------------------------------- ### Total Config Audit Report by Severity Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-addons-trivy-operator.md Query to aggregate the total configuration audit reports by severity. It uses the trivy_resource_configaudits metric. ```PromQL sum(trivy_resource_configaudits{cluster=~"$cluster"}) by (severity) ``` -------------------------------- ### Kubernetes Pods QoS Classes Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-views-namespaces.md Count Kubernetes pods grouped by their Quality of Service (QoS) class and also provides a general pod info count. ```PromQL sum(kube_pod_status_qos_class{namespace=~"$namespace", cluster="$cluster"}) by (qos_class) ``` ```PromQL sum(kube_pod_info{namespace=~"$namespace", cluster="$cluster"}) ``` -------------------------------- ### Network Bandwidth Rate Queries Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-addons-prometheus.md Monitors the network bandwidth in bytes per second for pods, showing both received and transmitted data rates. Useful for analyzing network traffic. ```PromQL sum(rate(container_network_receive_bytes_total{pod=~"$pod", cluster=~"$cluster"}[$__rate_interval])) by (pod) ``` ```PromQL - sum(rate(container_network_transmit_bytes_total{pod=~"$pod", cluster=~"$cluster"}[$__rate_interval])) by (pod) ``` -------------------------------- ### Unavailable Replicas by Deployment Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-views-namespaces.md Query the number of unavailable replicas for each deployment within specified namespaces and clusters. Filters for pods matching the created_by pattern. ```PromQL sum(kube_deployment_status_replicas_unavailable{namespace=~"$namespace", pod=~"${created_by}.*", cluster="$cluster"}) by (deployment) ``` -------------------------------- ### Context Switches and Interrupts Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-views-nodes.md Calculates the rate of context switches and interrupts per second for a given instance and cluster. ```PromQL rate(node_context_switches_total{instance="$instance", cluster="$cluster"}[$__rate_interval]) ``` ```PromQL rate(node_intr_total{instance="$instance", cluster="$cluster"}[$__rate_interval]) ``` -------------------------------- ### Kubernetes Pod Resource Limits (CPU) Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-views-pods.md Calculates the sum of CPU resource limits for pods. Use this to monitor CPU allocation limits. ```PromQL sum(kube_pod_container_resource_limits{namespace="$namespace", pod=~"$pod", resource="cpu", job=~"$job", cluster="$cluster"} and on(namespace, pod) ma... ``` -------------------------------- ### Disk Reads (bytes) Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-views-nodes.md Calculates the rate of data read from disks in bytes per second for a given instance and cluster. ```PromQL rate(node_disk_read_bytes_total{instance="$instance", cluster="$cluster"}[$__rate_interval]) ``` -------------------------------- ### CPU Usage by Pod Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-views-namespaces.md Calculate the CPU usage rate for containers within pods, filtering by namespace and cluster. Excludes containers without an image specified. ```PromQL sum(rate(container_cpu_usage_seconds_total{namespace=~"$namespace", image!="", pod=~"${created_by}.*", cluster="$cluster"}[$__rate_interval])) by (pod ``` -------------------------------- ### Persistent Volume Inode Usage Query Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-addons-prometheus.md Calculates the ratio of used inodes to total inodes for persistent volumes matching the 'prom' pattern. A value close to 1 indicates high inode utilization. Note: The provided query is truncated. ```PromQL 1 - (sum(kubelet_volume_stats_inodes_used{persistentvolumeclaim=~".*prom.*", cluster=~"$cluster"}) by (persistentvolumeclaim) / sum(kubelet_volume_sta... ``` -------------------------------- ### API Server Work Queue Depth by Instance Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/system-dashboards.md Monitors the depth of the API server's internal work queue per instance. High values suggest a backlog and potential performance issues. ```PromQL sum(workqueue_depth{cluster=~"$cluster", job=~"$job"}) by (instance) ``` -------------------------------- ### Container CPU Usage Rate Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-views-pods.md Calculates the sum of the rate of CPU usage for containers. Use this to monitor real-time CPU consumption. ```PromQL sum(rate(container_cpu_usage_seconds_total{namespace="$namespace", pod=~"$pod", image!="", container!="", cluster="$cluster"}[$__rate_interval])) by (... ``` -------------------------------- ### Container CPU Usage Query Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-addons-prometheus.md Monitors the CPU usage rate for containers within pods, excluding empty image or container names. This is a fundamental metric for resource monitoring. ```PromQL sum(rate(container_cpu_usage_seconds_total{pod=~"$pod", image!="", container!="", cluster=~"$cluster"}[$__rate_interval])) by (pod, container) ``` -------------------------------- ### Network Usage (bytes/s) Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-views-nodes.md Calculates the total network traffic in bytes per second, both received and transmitted, for a given instance and cluster. ```PromQL sum(rate(node_network_receive_bytes_total{instance="$instance", cluster="$cluster"}[$__rate_interval])) ``` ```PromQL - sum(rate(node_network_transmit_bytes_total{instance="$instance", cluster="$cluster"}[$__rate_interval])) ``` -------------------------------- ### CPU Core Throttled by Instance Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-views-global.md Tracks the rate of CPU core throttles per instance. Useful for diagnosing performance issues related to CPU limits on specific nodes. ```PromQL sum(rate(node_cpu_core_throttles_total{cluster="$cluster", job="$job"}[$__rate_interval])) by (instance) ``` -------------------------------- ### CPU Usage by Pod Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-views-nodes.md Calculates the sum of CPU usage rate for containers within a specific node and cluster, grouped by pod. ```PromQL sum(rate(container_cpu_usage_seconds_total{node="$node", image!="", cluster="$cluster"}[$__rate_interval])) by (pod) ``` -------------------------------- ### Query Variable Configuration Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/types.md Configuration for a template variable that fetches its values by executing a query against a specified datasource. ```json { "name": "cluster", "type": "query", "label": "Cluster", "datasource": { "type": "prometheus", "uid": "${datasource}" }, "query": { "qryType": 1, "query": "label_values(kube_node_info, cluster)" }, "current": {"text": "prod", "value": "prod"}, "hide": 0, "skipUrlSync": false } ``` -------------------------------- ### Kubernetes Pod Resource Requests (CPU) Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-views-pods.md Calculates the sum of CPU resource requests for pods. Use this to monitor requested CPU capacity. ```PromQL sum(kube_pod_container_resource_requests{namespace="$namespace", pod=~"$pod", resource="cpu", job=~"$job", cluster="$cluster"} and on(namespace, pod) ... ``` -------------------------------- ### Field Configuration Defaults Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/types.md Defines default settings for fields, including unit formatting, custom options, and threshold configurations. ```json { "defaults": { "unit": "short", "custom": {}, "thresholds": { "mode": "absolute", "steps": [ {"color": "green", "value": null}, {"color": "red", "value": 80} ] } }, "overrides": [] } ``` -------------------------------- ### Available Memory on Node Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/views-dashboards.md Retrieves the available memory in bytes from the node exporter. Use for memory capacity checks. ```promql node_memory_MemAvailable_bytes{node="$node"} ``` -------------------------------- ### Total Vulnerabilities by Namespaces Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-addons-trivy-operator.md Query to display the total number of vulnerabilities aggregated by namespace. It uses the trivy_image_vulnerabilities metric. ```PromQL sum(max by (namespace, image_registry, image_repository, image_tag, severity) (trivy_image_vulnerabilities{cluster=~"$cluster", namespace=~"$namespace"...)) ``` -------------------------------- ### Container Memory Usage Query Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-addons-prometheus.md Tracks the working set memory usage in bytes for containers within pods, excluding empty image or container names. Essential for memory capacity planning. ```PromQL sum(container_memory_working_set_bytes{pod=~"$pod", image!="", container!="", cluster=~"$cluster"}) by (pod, container) ``` -------------------------------- ### Namespace CPU Usage Query Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-views-namespaces.md Calculates the total CPU usage for specified namespaces in cores. It sums the rate of container CPU usage and compares it against machine CPU cores. ```Prometheus Query Language sum(rate(container_cpu_usage_seconds_total{namespace=~"$namespace", image!="", cluster="$cluster"}[$__rate_interval])) ``` -------------------------------- ### Disk Writes (bytes) Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-views-nodes.md Calculates the rate of data written to disks in bytes per second for a given instance and cluster. ```PromQL rate(node_disk_written_bytes_total{instance="$instance", cluster="$cluster"}[$__rate_interval]) ``` -------------------------------- ### Network Received and Transmitted (excluding loopback) by Instance Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-views-global.md Calculates network traffic received and transmitted per instance, excluding loopback and virtual interfaces. Provides a view of external network traffic per node. ```PromQL sum(rate(node_network_receive_bytes_total{device!~"(veth|azv|lxc|lo).*", cluster="$cluster", job="$job"}[$__rate_interval])) by (instance) ``` ```PromQL - sum(rate(node_network_transmit_bytes_total{device!~"(veth|azv|lxc|lo).*", cluster="$cluster", job="$job"}[$__rate_interval])) by (instance) ``` -------------------------------- ### Prometheus Query for RAM Usage Gauge Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-views-nodes.md Calculates the used RAM as a percentage of total RAM for a selected instance and cluster. ```prometheus sum(node_memory_MemTotal_bytes{instance="$instance", cluster="$cluster"} - node_memory_MemAvailable_bytes{instance="$instance", cluster="$cluster"}) /... ``` -------------------------------- ### Number of Containers by Pod Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-views-namespaces.md Count the number of containers within each pod, filtered by namespace and cluster. Filters for pods matching the created_by pattern. ```PromQL sum(kube_pod_container_info{namespace=~"$namespace", pod=~"${created_by}.*", cluster="$cluster"}) by (pod) ``` -------------------------------- ### API Server CPU Usage by Instance Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/system-dashboards.md Measures the CPU seconds consumed per API server instance as a rate. This trend helps in understanding CPU consumption patterns. ```PromQL rate(process_cpu_seconds_total{cluster=~"$cluster", job=~"$job"}[$__rate_interval]) ``` -------------------------------- ### Disk I/O Operations per Second Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-views-nodes.md Calculates the number of disk I/O operations currently in progress for a given instance and cluster. ```PromQL rate(node_disk_io_now{instance="$instance", cluster="$cluster"}[$__rate_interval]) ``` -------------------------------- ### Network Received and Transmitted (loopback only) by Instance Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-views-global.md Calculates network traffic received and transmitted specifically on the loopback interface (lo) per instance. Useful for diagnosing intra-node communication. ```PromQL sum(rate(node_network_receive_bytes_total{device="lo", cluster="$cluster", job="$job"}[$__rate_interval])) by (instance) ``` ```PromQL - sum(rate(node_network_transmit_bytes_total{device="lo", cluster="$cluster", job="$job"}[$__rate_interval])) by (instance) ``` -------------------------------- ### Persistent Volumes - Inodes Usage Percentage Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-views-namespaces.md Calculate the percentage of used inodes for Persistent Volume Claims, aggregated by persistent volume claim. This query calculates (1 - (used_inodes / total_inodes)). ```PromQL 1 - (sum(kubelet_volume_stats_inodes_used{namespace=~"$namespace", cluster="$cluster"}) by (persistentvolumeclaim) / sum(kubelet_volume_stats_inodes{n... ``` -------------------------------- ### Custom Variable Configuration Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/types.md Configuration for a template variable with a fixed, predefined value. ```json { "name": "resolution", "type": "custom", "label": "Resolution", "current": {"text": "30s", "value": "30s"}, "hide": 0 } ``` -------------------------------- ### Namespace CPU Requests Query Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-views-namespaces.md Calculates the sum of CPU resource requests for pods within specified namespaces. This helps in understanding the requested CPU capacity. ```Prometheus Query Language sum(kube_pod_container_resource_requests{namespace=~"$namespace", resource="cpu", cluster="$cluster"} and on(namespace, pod) max by (namespace, pod) (...) ``` -------------------------------- ### Kubernetes Pods QoS Classes and Count Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-views-global.md Aggregates pods by their Quality of Service (QoS) class and provides a total count of pods. Useful for understanding workload stability and resource guarantees. ```PromQL sum(kube_pod_status_qos_class{cluster="$cluster"}) by (qos_class) ``` ```PromQL sum(kube_pod_info{cluster="$cluster"}) ``` -------------------------------- ### Update Deployment with New Image Version Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/addon-dashboards.md This command updates a specific deployment to use a new container image version. Ensure the image is rebuilt and pushed to the registry first. ```bash # Update deployment to use new image kubectl set image deployment/myapp myapp=myapp:1.1.0 -n mynamespace ``` -------------------------------- ### Total Network Received and Transmitted by Instance Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-views-global.md Calculates the total network traffic received and transmitted per instance, including all network devices. Useful for monitoring overall network I/O on each node. ```PromQL sum(rate(node_network_receive_bytes_total{cluster="$cluster", job="$job"}[$__rate_interval])) by (instance) ``` ```PromQL - sum(rate(node_network_transmit_bytes_total{cluster="$cluster", job="$job"}[$__rate_interval])) by (instance) ``` -------------------------------- ### CoreDNS CPU Usage by Instance Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-system-coredns.md Monitors the CPU usage of each CoreDNS instance. Use this to identify high-CPU instances. ```PromQL rate(process_cpu_seconds_total{job=~"$job", instance=~"$instance", cluster=~"$cluster"}[$__rate_interval]) ``` -------------------------------- ### DNS Queries by Protocol Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/system-dashboards.md Tracks the volume of DNS requests over TCP and UDP. UDP is typically primary, while TCP is used for larger responses. ```PromQL sum by (protocol) (rate(coredns_dns_requests_total[$__rate_interval])) ``` -------------------------------- ### Container Restarts by Namespace Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-views-global.md Tracks the number of container restarts aggregated by namespace. High restart counts can indicate application instability or frequent crashes. ```PromQL sum(increase(kube_pod_container_status_restarts_total{cluster="$cluster"}[$__rate_interval])) by (namespace) > 0 ``` -------------------------------- ### Memory Usage by Container Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-views-pods.md Calculates the sum of the working set memory for containers. Use this to monitor individual container memory consumption. ```PromQL sum(container_memory_working_set_bytes{namespace="$namespace", pod=~"$pod", image!="", container!="", cluster="$cluster"}) by (container, id) ``` -------------------------------- ### Namespace RAM Requests Query Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-views-namespaces.md Calculates the sum of memory resource requests for pods within specified namespaces. This helps in understanding the requested memory capacity. ```Prometheus Query Language sum(kube_pod_container_resource_requests{namespace=~"$namespace", resource="memory", cluster="$cluster"} and on(namespace, pod) max by (namespace, pod) (... ``` -------------------------------- ### Find Vulnerable Images in Kubernetes Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/addon-dashboards.md This command lists all unique container images currently in use across all namespaces in your Kubernetes cluster. ```bash # Find vulnerable images in use kubectl get pods -A -o jsonpath='{.items[*].spec.containers[*].image}' | tr -s '[[:space:]]' '\n' | sort -u ``` -------------------------------- ### Network Usage (packets/s) Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-views-nodes.md Calculates the total number of network packets per second, both received and transmitted, for a given instance and cluster. ```PromQL sum(rate(node_network_receive_packets_total{instance="$instance", cluster="$cluster"}[$__rate_interval])) ``` ```PromQL - sum(rate(node_network_transmit_packets_total{instance="$instance", cluster="$cluster"}[$__rate_interval])) ``` -------------------------------- ### API Server Memory Usage by Instance Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/system-dashboards.md Tracks the resident memory usage per API server instance. Useful for detecting memory leaks, indicated by continuously increasing values. ```PromQL process_resident_memory_bytes{cluster=~"$cluster", job=~"$job"} ``` -------------------------------- ### Interval Variable Configuration Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/types.md Configuration for a template variable that allows selecting a time interval from a predefined list. ```json { "name": "interval", "type": "interval", "label": "Interval", "values": ["1m", "5m", "10m", "30m"], "current": {"text": "1m", "value": "1m"} } ``` -------------------------------- ### Namespace Filtering Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/views-dashboards.md A basic PromQL query to filter metrics by cluster and namespace. ```promql # Namespace filtering {cluster=~"$cluster", namespace="$namespace"} ``` -------------------------------- ### RAM Usage Metrics Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-views-global.md This panel displays various RAM usage metrics, including total used memory, pod memory requests, pod memory limits, and total machine memory. ```Prometheus sum(node_memory_MemTotal_bytes{cluster="$cluster", job="$job"} - node_memory_MemAvailable_bytes{cluster="$cluster", job="$job"}) ``` ```Prometheus sum(kube_pod_container_resource_requests{resource="memory", cluster="$cluster"} and on(namespace, pod) max by (namespace, pod) (kube_pod_status_phase{... ``` ```Prometheus sum(kube_pod_container_resource_limits{resource="memory", cluster="$cluster"} and on(namespace, pod) max by (namespace, pod) (kube_pod_status_phase{ph... ``` ```Prometheus sum(machine_memory_bytes{cluster="$cluster"}) ``` -------------------------------- ### Filter Metrics by Job and Instance Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/metrics-and-queries.md Shows how to further refine metric queries by filtering on `job` and `instance` labels when available. This provides more specific and targeted data retrieval. ```prometheus # More specific rate(apiserver_request_total{cluster="$cluster", job="kube-apiserver"}[$__rate_interval]) ``` -------------------------------- ### Query for Filesystem Device Errors Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-views-nodes.md This query retrieves the sum of filesystem device errors for a specific instance and cluster, grouped by mountpoint. Use this to identify storage-related issues on your nodes. ```promql sum(node_filesystem_device_error{instance="$instance", cluster="$cluster"}) by (mountpoint) ``` -------------------------------- ### Verify Scan Results Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/addon-dashboards.md This command retrieves the ImageAudit custom resources, which can be used to verify if vulnerability scan results have been updated. ```bash # Verify scan results updated kubectl get imageaudit -n mynamespace ``` -------------------------------- ### Network Packets Rate by Pod Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-views-namespaces.md Calculate the network receive and transmit packets rate for pods, filtered by namespace and cluster. Filters for pods matching the created_by pattern. ```PromQL sum(rate(container_network_receive_packets_total{namespace=~"$namespace", pod=~"${created_by}.*", cluster="$cluster"}[$__rate_interval])) by (pod) ``` -------------------------------- ### Prometheus Up Targets Query Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/addon-dashboards.md Counts the number of healthy Prometheus scrape targets. This should match the total configured targets. ```PromQL count(up{cluster=~"$cluster"} == 1) ``` -------------------------------- ### Deploy ConfigMaps to Kubernetes Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/README.md Apply the generated ConfigMaps directly to your Kubernetes cluster in the specified namespace. Ensure the Grafana `dashboards sidecar` is enabled and configured. ```terminal kubectl apply -k . -n monitoring ``` -------------------------------- ### Container Restarts by Container Source: https://github.com/dotdc/grafana-dashboards-kubernetes/blob/master/_autodocs/api-reference/k8s-views-pods.md Calculates the increase in container restart counts. Use this to monitor pod stability and identify frequently restarting containers. ```PromQL sum(increase(kube_pod_container_status_restarts_total{namespace="${namespace}", pod=~"${pod}", container!="", job=~"$job", cluster="$cluster"}[$__rate... ```