From 9f1c40a7965b86551ff67f6d280d88f110911314 Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Sat, 6 Apr 2024 21:26:55 +0200 Subject: [PATCH] migrate: support.jsonnet --- dashboards/support.jsonnet | 280 ++++++++++++++++++++----------------- 1 file changed, 154 insertions(+), 126 deletions(-) diff --git a/dashboards/support.jsonnet b/dashboards/support.jsonnet index d1a3ae2..eee92c5 100755 --- a/dashboards/support.jsonnet +++ b/dashboards/support.jsonnet @@ -2,147 +2,175 @@ // Deploys a dashboard showing information about support resources local grafonnet = import 'grafonnet/main.libsonnet'; local dashboard = grafonnet.dashboard; -local graphPanel = grafonnet.graphPanel; -local prometheus = grafonnet.prometheus; -local row = grafonnet.row; +local ts = grafonnet.panel.timeSeries; +local prometheus = grafonnet.query.prometheus; +local row = grafonnet.panel.row; local common = import './common.libsonnet'; // NFS Stats -local userNodesNFSOps = graphPanel.new( - 'User Nodes NFS Ops', - decimals=0, - min=0, - datasource='$PROMETHEUS_DS' -).addTargets([ - prometheus.target( - 'sum(rate(node_nfs_requests_total[5m])) by (node) > 0', - legendFormat='{{ node }}' - ), -]); +local userNodesNFSOps = + common.tsOptions + + ts.new('User Nodes NFS Ops') + + ts.standardOptions.withDecimals(0) + + ts.queryOptions.withTargets([ + prometheus.new( + '$PROMETHEUS_DS', + ||| + sum(rate(node_nfs_requests_total[5m])) by (node) > 0 + ||| + ) + + prometheus.withLegendFormat('{{ node }}'), + ]); -local userNodesIOWait = graphPanel.new( - 'iowait % on each node', - decimals=0, - min=0, - datasource='$PROMETHEUS_DS' -).addTargets([ - prometheus.target( - 'sum(rate(node_nfs_requests_total[5m])) by (node)', - legendFormat='{{ node }}' - ), -]); +local userNodesIOWait = + common.tsOptions + + ts.new('iowait % on each node') + + ts.standardOptions.withDecimals(0) + + ts.queryOptions.withTargets([ + prometheus.new( + '$PROMETHEUS_DS', + ||| + sum(rate(node_nfs_requests_total[5m])) by (node) + ||| + ) + + prometheus.withLegendFormat('{{ node }}'), + ]); -local userNodesHighNFSOps = graphPanel.new( - 'NFS Operation Types on user nodes', - decimals=0, - min=0, - datasource='$PROMETHEUS_DS' -).addTargets([ - prometheus.target( - 'sum(rate(node_nfs_requests_total[5m])) by (method) > 0', - legendFormat='{{method}}' - ), -]); +local userNodesHighNFSOps = + common.tsOptions + + ts.new('NFS Operation Types on user nodes') + + ts.standardOptions.withDecimals(0) + + ts.queryOptions.withTargets([ + prometheus.new( + '$PROMETHEUS_DS', + ||| + sum(rate(node_nfs_requests_total[5m])) by (method) > 0 + ||| + ) + + prometheus.withLegendFormat('{{ method }}'), + ]); -local nfsServerCPU = graphPanel.new( - 'NFS Server CPU', - min=0, - datasource='$PROMETHEUS_DS' -).addTargets([ - prometheus.target( - 'avg(rate(node_cpu_seconds_total{job="prometheus-nfsd-server", mode!="idle"}[2m])) by (mode)', - legendFormat='{{mode}}' - ), -]); +local nfsServerCPU = + common.tsOptions + + ts.new('NFS Server CPU') + + ts.queryOptions.withTargets([ + prometheus.new( + '$PROMETHEUS_DS', + ||| + avg(rate(node_cpu_seconds_total{job="prometheus-nfsd-server", mode!="idle"}[2m])) by (mode) + ||| + ) + + prometheus.withLegendFormat('{{ mode }}'), + ]); -local nfsServerIOPS = graphPanel.new( - 'NFS Server Disk ops', - decimals=0, - min=0, - datasource='$PROMETHEUS_DS' -).addTargets([ - prometheus.target( - 'sum(rate(node_nfsd_disk_bytes_read_total[5m]))', - legendFormat='Read' - ), - prometheus.target( - 'sum(rate(node_nfsd_disk_bytes_written_total[5m]))', - legendFormat='Write' - ), -]); +local nfsServerIOPS = + common.tsOptions + + ts.new('NFS Server Disk ops') + + ts.standardOptions.withDecimals(0) + + ts.queryOptions.withTargets([ + prometheus.new( + '$PROMETHEUS_DS', + ||| + sum(rate(node_nfsd_disk_bytes_read_total[5m])) + ||| + ) + + prometheus.withLegendFormat('Read'), + prometheus.new( + '$PROMETHEUS_DS', + ||| + sum(rate(node_nfsd_disk_bytes_written_total[5m])) + ||| + ) + + prometheus.withLegendFormat('Write'), + ]); -local nfsServerWriteLatency = graphPanel.new( - 'NFS Server disk write latency', - min=0, - datasource='$PROMETHEUS_DS' -).addTargets([ - prometheus.target( - 'sum(rate(node_disk_write_time_seconds_total{job="prometheus-nfsd-server"}[5m])) by (device) / sum(rate(node_disk_writes_completed_total{job="prometheus-nfsd-server"}[5m])) by (device)', - legendFormat='{{device}}' - ), -]); +local nfsServerWriteLatency = + common.tsOptions + + ts.new('NFS Server disk write latency') + + ts.queryOptions.withTargets([ + prometheus.new( + '$PROMETHEUS_DS', + ||| + sum(rate(node_disk_write_time_seconds_total{job="prometheus-nfsd-server"}[5m])) by (device) / sum(rate(node_disk_writes_completed_total{job="prometheus-nfsd-server"}[5m])) by (device) + ||| + + prometheus.withLegendFormat('{{ device }}'), + ), + ]); -local nfsServerReadLatency = graphPanel.new( - 'NFS Server disk read latency', - min=0, - datasource='$PROMETHEUS_DS' -).addTargets([ - prometheus.target( - 'sum(rate(node_disk_read_time_seconds_total{job="prometheus-nfsd-server"}[5m])) by (device) / sum(rate(node_disk_reads_completed_total{job="prometheus-nfsd-server"}[5m])) by (device)', - legendFormat='{{device}}' - ), -]); +local nfsServerReadLatency = + common.tsOptions + + ts.new('NFS Server disk read latency') + + ts.queryOptions.withTargets([ + prometheus.new( + '$PROMETHEUS_DS', + ||| + sum(rate(node_disk_read_time_seconds_total{job="prometheus-nfsd-server"}[5m])) by (device) / sum(rate(node_disk_reads_completed_total{job="prometheus-nfsd-server"}[5m])) by (device) + ||| + + prometheus.withLegendFormat('{{ device }}'), + ), + ]); // Support Metrics -local prometheusMemory = graphPanel.new( - 'Prometheus Memory (Working Set)', - formatY1='bytes', - min=0, - datasource='$PROMETHEUS_DS' -).addTargets([ - prometheus.target( - 'sum(container_memory_working_set_bytes{pod=~"support-prometheus-server-.*", namespace="support"})' - ), -]); +local prometheusMemory = + common.tsOptions + + ts.new('Prometheus Memory (Working Set)') + + ts.standardOptions.withUnit('bytes') + + ts.queryOptions.withTargets([ + prometheus.new( + '$PROMETHEUS_DS', + ||| + sum(container_memory_working_set_bytes{pod=~"support-prometheus-server-.*", namespace="support"}) + ||| + ), + ]); -local prometheusCPU = graphPanel.new( - 'Prometheus CPU', - min=0, - datasource='$PROMETHEUS_DS' -).addTargets([ - prometheus.target( - 'sum(rate(container_cpu_usage_seconds_total{pod=~"support-prometheus-server-.*",namespace="support"}[5m]))' - ), -]); +local prometheusCPU = + common.tsOptions + + ts.new('Prometheus CPU') + + ts.queryOptions.withTargets([ + prometheus.new( + '$PROMETHEUS_DS', + ||| + sum(rate(container_cpu_usage_seconds_total{pod=~"support-prometheus-server-.*",namespace="support"}[5m])) + ||| + ), + ]); -local prometheusDiskSpace = graphPanel.new( - 'Prometheus Free Disk space', - formatY1='bytes', - min=0, - datasource='$PROMETHEUS_DS' -).addTargets([ - prometheus.target( - 'sum(kubelet_volume_stats_available_bytes{namespace="support",persistentvolumeclaim="support-prometheus-server"})' - ), -]); +local prometheusDiskSpace = + common.tsOptions + + ts.new('Prometheus Free Disk space') + + ts.standardOptions.withUnit('bytes') + + ts.queryOptions.withTargets([ + prometheus.new( + '$PROMETHEUS_DS', + ||| + sum(kubelet_volume_stats_available_bytes{namespace="support",persistentvolumeclaim="support-prometheus-server"}) + ||| + ), + ]); -local prometheusNetwork = graphPanel.new( - 'Prometheus Network Usage', - formatY1='bytes', - decimals=0, - min=0, - datasource='$PROMETHEUS_DS' -).addTargets([ - prometheus.target( - 'sum(rate(container_network_receive_bytes_total{pod=~"support-prometheus-server-.*",namespace="support"}[5m]))', - legendFormat='receive' - ), - prometheus.target( - 'sum(rate(container_network_send_bytes_total{pod=~"support-prometheus-server-.*",namespace="support"}[5m]))', - legendFormat='send' - ), -]); +local prometheusNetwork = + common.tsOptions + + ts.new('Prometheus Network Usage') + + ts.standardOptions.withUnit('bytes') + + ts.standardOptions.withDecimals(0) + + ts.queryOptions.withTargets([ + prometheus.new( + '$PROMETHEUS_DS', + ||| + sum(rate(container_network_receive_bytes_total{pod=~"support-prometheus-server-.*",namespace="support"}[5m])) + ||| + + prometheus.withLegendFormat('receive'), + ), + prometheus.new( + '$PROMETHEUS_DS', + ||| + sum(rate(container_network_send_bytes_total{pod=~"support-prometheus-server-.*",namespace="support"}[5m])) + ||| + + prometheus.withLegendFormat('send'), + ), + ]); dashboard.new('NFS and Support Information') + dashboard.withTags(['support', 'kubernetes'])