Skip to content

Commit

Permalink
[kube-prometheus-stack] Fix IO panels in Cluster Overview
Browse files Browse the repository at this point in the history
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
  • Loading branch information
jkroepke committed Oct 15, 2023
1 parent 92907b0 commit fbfea29
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 4 deletions.
2 changes: 1 addition & 1 deletion charts/kube-prometheus-stack/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ name: kube-prometheus-stack
sources:
- https://github.com/prometheus-community/helm-charts
- https://github.com/prometheus-operator/kube-prometheus
version: 51.7.0
version: 51.8.0
appVersion: v0.68.0
kubeVersion: ">=1.19.0-0"
home: https://github.com/prometheus-operator/kube-prometheus
Expand Down
17 changes: 17 additions & 0 deletions charts/kube-prometheus-stack/hack/sync_grafana_dashboards.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,18 @@ def yaml_str_repr(struct, indent=2):
return text


def replace_nested_key(data, key, value, replace):
if isinstance(data, dict):
return {
k: replace if k == key and v == value else replace_nested_key(v, key, value, replace)
for k, v in data.items()
}
elif isinstance(data, list):
return [replace_nested_key(v, key, value, replace) for v in data]
else:
return data


def patch_dashboards_json(content, multicluster_key):
try:
content_struct = json.loads(content)
Expand All @@ -115,6 +127,11 @@ def patch_dashboards_json(content, multicluster_key):
variable['hide'] = ':multicluster:'
overwrite_list.append(variable)
content_struct['templating']['list'] = overwrite_list

# Replace decimals=-1 with decimals=auto
# ref: https://github.com/kubernetes-monitoring/kubernetes-mixin/pull/859
content_struct = replace_nested_key(content_struct, "decimals", -1, None)

content = json.dumps(content_struct, separators=(',', ':'))
content = content.replace('":multicluster:"', '`}}{{ if %s }}0{{ else }}2{{ end }}{{`' % multicluster_key,)
except (ValueError, KeyError):
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

0 comments on commit fbfea29

Please sign in to comment.