I tested customising the graphs on the kots admin console this morning, documented here:
When changing the kots-app.yaml to add a graphs section the CPU and Memory Usage charts were blank and viewing the logs from the kotsadm pod there were lots if messages:
{"level":"error","ts":"2022-09-08T10:10:11Z","msg":"failed to prometheus query range: Unexpected status code 400"}
Narrowing things down it looks like there is an issue with the usage of fmt.sprintf in the query syntax.
by temporary hard coding the namespace I was able to recreate the original charts, note the two commented out queries in CPU Usage will give the 400 return status/error code:
graphs:
# CPU, Memory and Disk Usage charts
- title: CPU Usage
#query: fmt.Sprintf(`sum(rate(container_cpu_usage_seconds_total{namespace="%s",container!="POD",pod!=""}[5m])) by (pod)`, util.PodNamespace)'
#query: 'fmt.Sprintf(`sum(rate(container_cpu_usage_seconds_total{namespace="%s",container!="POD",pod!=""}[5m])) by (pod)`, "default")'
query: 'sum(rate(container_cpu_usage_seconds_total{namespace="default",container!="POD",pod!=""}[5m])) by (pod)'
legend: '{{ pod }}'
- title: Memory Usage
queries:
- query: 'sum(container_memory_usage_bytes{namespace="default",container!="POD",pod!=""}) by (pod)'
legend: '{{ pod }}'
yAxisFormat: bytes
- title: Disk Usage
queries:
- query: 'sum((node_filesystem_size_bytes{job="node-exporter",fstype!="",instance!=""} - node_filesystem_avail_bytes{job="node-exporter", fstype!=""})) by (instance)'
legend: 'Used: {{ instance }}'
- query: 'sum((node_filesystem_avail_bytes{job="node-exporter",fstype!="",instance!=""})) by (instance)'
legend: 'Available: {{ instance }}'
yAxisFormat: bytes
Anyone get the sprintf working, what am I missing?, ty