Skip to content

Commit

Permalink
checkpoint watching files
Browse files Browse the repository at this point in the history
  • Loading branch information
david-martin committed Sep 27, 2023
1 parent 51c07bb commit ff12698
Show file tree
Hide file tree
Showing 7 changed files with 244 additions and 2,085 deletions.
22 changes: 16 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,26 @@ generate-bundles:
compare-bundles: generate-bundles
git diff --exit-code

define GENERATE_DASHBOARDS
jsonnet -J vendor $< -o $@
endef

JSONNET_SRC_DIR := src/dashboards
JSONNET_TARGET_DIR := config/examples/dashboards
JSONNET_TARGETS := $(addprefix $(JSONNET_TARGET_DIR)/,$(patsubst %.jsonnet,%.json,$(shell ls $(JSONNET_SRC_DIR)/*.jsonnet | xargs -n 1 basename))) $(addprefix $(JSONNET_TARGET_DIR)/,$(patsubst %.jsonnet,%.json,$(shell ls $(JSONNET_SRC_DIR)/*.jsonnet | xargs -n 1 basename)))
JSONNET_TARGETS := $(addprefix $(JSONNET_TARGET_DIR)/,$(patsubst %.jsonnet,%.json,$(shell ls $(JSONNET_SRC_DIR)/*.jsonnet | xargs -n 1 basename)))
DASHBOARD_CR_TARGETS := $(addprefix $(JSONNET_TARGET_DIR)/,$(patsubst %.jsonnet,%.yaml,$(shell ls $(JSONNET_SRC_DIR)/*.jsonnet | xargs -n 1 basename)))

$(JSONNET_TARGET_DIR)/%.json: $(JSONNET_SRC_DIR)/%.jsonnet
$(GENERATE_DASHBOARDS)
jsonnet -J vendor $< -o $@

$(JSONNET_TARGET_DIR)/%.yaml: $(JSONNET_TARGET_DIR)/%.json
DASHBOARD_NAME=$(shell echo "$<" | sed -r "s/.+\/(.+)\..+/\1/") envsubst < $(JSONNET_SRC_DIR)/dashboard_cr_template.yaml > $@
cat "$<" | jq -c . >> $@

.PHONY: generate-dashboards
generate-dashboards: ${JSONNET_TARGETS}

.PHONY: generate-dashboard-crs
generate-dashboard-crs: generate-dashboards ${DASHBOARD_CR_TARGETS}

.PHONY: apply-latest-dashboard-crs
apply-latest-dashboard-crs: generate-dashboard-crs
for i in ${DASHBOARD_CR_TARGETS}; do kubectl apply -f $$i; done

print-% : ; @echo $* = $($*)
10 changes: 10 additions & 0 deletions config/examples/dashboards/gatewayclasses.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: grafana.integreatly.org/v1beta1
kind: GrafanaDashboard
metadata:
name: gatewayclasses
spec:
instanceSelector:
matchLabels:
dashboards: "grafana"
json: >
{"editable":false,"links":[{"asDropdown":false,"includeVars":true,"keepTime":true,"tags":["gateway-api-state"],"targetBlank":false,"title":"Gateway Dashboards","type":"dashboards"}],"panels":[{"gridPos":{"h":1,"w":24,"x":0,"y":0},"id":1,"title":"Gateway Classes","type":"row"},{"datasource":{"type":"prometheus","uid":"$datasource"},"description":"Total number of GatewayClasses across all clusters","gridPos":{"h":3,"w":2,"x":0,"y":1},"id":2,"pluginVersion":"v10.0.0","targets":[{"datasource":{"type":"prometheus","uid":"$datasource"},"expr":"count(gatewayapi_gatewayclass_info)","instant":true}],"title":"Total","type":"stat"},{"datasource":{"type":"prometheus","uid":"$datasource"},"description":"Total GatewayClasses with an Accepted state of True","gridPos":{"h":3,"w":2,"x":2,"y":1},"id":3,"pluginVersion":"v10.0.0","targets":[{"datasource":{"type":"prometheus","uid":"$datasource"},"expr":"count(gatewayapi_gatewayclass_status{type=\"Accepted\"} > 0)","instant":true}],"title":"Accepted","type":"stat"},{"datasource":{"type":"prometheus","uid":"$datasource"},"fieldConfig":{"overrides":[{"matcher":{"id":"byName","options":"Created At"},"properties":[{"id":"unit","value":"dateTimeAsIso"}]}]},"gridPos":{"h":6,"w":10,"x":4,"y":1},"id":4,"pluginVersion":"v10.0.0","targets":[{"datasource":{"type":"prometheus","uid":"$datasource"},"expr":"gatewayapi_gatewayclass_created","format":"table","instant":true,"range":false}],"title":"GatewayClasses","transformations":[{"id":"filterFieldsByName","options":{"include":{"names":["customresource_version","name","Value"]}}},{"id":"calculateField","options":{"alias":"Created At","binary":{"left":"Value","operator":"*","reducer":"sum","right":"1000"},"mode":"binary","reduce":{"reducer":"sum"},"replaceFields":false}},{"id":"organize","options":{"excludeByName":{"Value":true,"customresource_kind":true},"indexByName":{},"renameByName":{"Value":"Created","customresource_kind":"Kind","customresource_version":"Version","name":"Name","namespace":"Namespace"}}}],"type":"table"},{"datasource":{"type":"prometheus","uid":"$datasource"},"fieldConfig":{"overrides":[{"matcher":{"id":"byName","options":"Name"},"properties":[{"id":"links","value":[{"title":"Gateway Details","url":"/d/gatewayapigateways/gateway-api-state-gateways?var-gateway=${__value.text}"}]},{"id":"custom.displayMode","value":"color-text"}]}]},"gridPos":{"h":6,"w":10,"x":14,"y":1},"id":5,"pluginVersion":"v10.0.0","targets":[{"datasource":{"type":"prometheus","uid":"$datasource"},"expr":"gatewayapi_gateway_info","format":"table","instant":true,"range":false}],"title":"Gateways (by GatewayClass)","transformations":[{"id":"filterFieldsByName","options":{"include":{"names":["gatewayclass_name","name","namespace"]}}},{"id":"organize","options":{"excludeByName":{"Value":false,"customresource_kind":true},"indexByName":{"Value":3,"gatewayclass_name":2,"name":0,"namespace":1},"renameByName":{"Value":"# Instances","customresource_kind":"Kind","customresource_version":"Version","gatewayclass_name":"GatewayClass","name":"Name","namespace":"Namespace"}}}],"type":"table"},{"datasource":{"type":"prometheus","uid":"$datasource"},"fieldConfig":{"overrides":[{"matcher":{"id":"byName","options":"name"},"properties":[{"id":"custom.width","value":333}]}]},"gridPos":{"h":6,"w":20,"x":4,"y":7},"id":6,"pluginVersion":"v10.0.0","targets":[{"datasource":{"type":"prometheus","uid":"$datasource"},"expr":"gatewayapi_gatewayclass_status_supported_features{name=\"$gatewayclass\"}","format":"table","instant":true,"range":false}],"title":"Supported Features (by GatewayClass)","transformations":[{"id":"reduce","options":{"includeTimeField":false,"labelsToFields":true,"mode":"seriesToRows","reducers":["last"]}},{"id":"filterFieldsByName","options":{"include":{"names":["features","name"]}}},{"id":"groupBy","options":{"fields":{"features":{"aggregations":["allValues"],"operation":"aggregate"},"name":{"aggregations":[],"operation":"groupby"}}}},{"id":"organize","options":{"excludeByName":{},"indexByName":{},"renameByName":{"features (allValues)":"Features","name":"GatewayClass"}}}],"type":"table"}],"schemaVersion":36,"style":"dark","tags":["gateway-api","gateway-api-state"],"templating":{"list":[{"label":"Data Source","name":"datasource","query":"prometheus","type":"datasource"}]},"time":{"from":"now-1h","to":"now"},"timezone":"utc","title":"Gateway API State / GatewayClasses","uid":"gatewayapigatewayclass"}
Loading

0 comments on commit ff12698

Please sign in to comment.