Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add dashboards as app #554

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/apps/grafana-dashboards/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.helmignore
/logos
/Makefile
8 changes: 8 additions & 0 deletions packages/apps/grafana-dashboards/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v2
name: grafana-dashboards
description: Grafana dashboards
icon: /logos/grafana-dashboards.svg

type: application
version: 0.1.0
appVersion: "0.1.0"
4 changes: 4 additions & 0 deletions packages/apps/grafana-dashboards/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include ../../../scripts/package.mk

generate:
readme-generator -v values.yaml -s values.schema.json -r README.md
11 changes: 11 additions & 0 deletions packages/apps/grafana-dashboards/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Grafana dashboards

## Parameters

### Dashboard parameters

| Name | Description | Value |
| ------------------ | ------------------------------------ | ----- |
| `urlDashboards` | List of dashboards with URLs. | `[]` |
| `jsonDashboards` | List of dashboards with inline JSON. | `[]` |
| `instanceSelector` | Selector to match Grafana instances. | `{}` |
269 changes: 269 additions & 0 deletions packages/apps/grafana-dashboards/logos/grafana-dashboards.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@

{{- $myNS := lookup "v1" "Namespace" "" .Release.Namespace }}


{{- range .Values.urlDashboards }}
---
apiVersion: grafana.integreatly.org/v1beta1
kind: GrafanaDashboard
metadata:
name: {{ .name }}
spec:
{{- if .Values.instanceSelector | not }}
instanceSelector:
matchLabels:
dashboards: {{ $myNS }}
{{- else }}
instanceSelector:
{{ $instanceSelector | indent 4 }}
{{- end }}
Comment on lines +12 to +19
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix template variable references and indentation

There are several issues in the instanceSelector conditional block:

  1. .Values is incorrectly referenced (should be Values)
  2. Indentation is incorrect for the instanceSelector template
-  {{- if .Values.instanceSelector | not }}
+  {{- if not .Values.instanceSelector }}
   instanceSelector:
     matchLabels:
       dashboards: {{ $myNS }}
   {{- else }}
   instanceSelector:
-{{ $instanceSelector | indent 4 }}
+    {{- toYaml .Values.instanceSelector | nindent 4 }}
   {{- end }}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{{- if .Values.instanceSelector | not }}
instanceSelector:
matchLabels:
dashboards: {{ $myNS }}
{{- else }}
instanceSelector:
{{ $instanceSelector | indent 4 }}
{{- end }}
{{- if not .Values.instanceSelector }}
instanceSelector:
matchLabels:
dashboards: {{ $myNS }}
{{- else }}
instanceSelector:
{{- toYaml .Values.instanceSelector | nindent 4 }}
{{- end }}

url: {{ .link }}
{{- end }}

{{- range .Values.jsonDashboards }}
---
apiVersion: grafana.integreatly.org/v1beta1
kind: GrafanaDashboard
metadata:
name: {{ .name }}
spec:
{{- if .Values.instanceSelector | not }}
instanceSelector:
matchLabels:
dashboards: {{ $myNS }}
{{- else }}
instanceSelector:
{{ $instanceSelector | indent 4 }}
{{- end }}
resyncPeriod: "30s"
json: |
{{ .json | indent 4 }}
Comment on lines +38 to +40
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Validate required fields before rendering

Add validation for required fields before rendering the template.

+  {{- if not .json }}
+    {{- fail "Dashboard json is required" }}
+  {{- end }}
   resyncPeriod: "30s"
   json: |
 {{ .json | indent 4 }}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
resyncPeriod: "30s"
json: |
{{ .json | indent 4 }}
{{- if not .json }}
{{- fail "Dashboard json is required" }}
{{- end }}
resyncPeriod: "30s"
json: |
{{ .json | indent 4 }}

{{- end }}
23 changes: 23 additions & 0 deletions packages/apps/grafana-dashboards/values.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"title": "Chart Values",
"type": "object",
"properties": {
"urlDashboards": {
"type": "array",
"description": "List of dashboards with URLs.",
"default": [],
"items": {}
},
Comment on lines +5 to +10
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Enhance schema validation for urlDashboards

The items object is empty, which means any object structure will be accepted. Add proper validation for required fields and their types.

 "urlDashboards": {
     "type": "array",
     "description": "List of dashboards with URLs.",
     "default": [],
-    "items": {}
+    "items": {
+        "type": "object",
+        "required": ["name", "link"],
+        "properties": {
+            "name": {
+                "type": "string",
+                "description": "The name of the dashboard"
+            },
+            "link": {
+                "type": "string",
+                "format": "uri",
+                "description": "The URL of the dashboard JSON"
+            }
+        },
+        "additionalProperties": false
+    }
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"urlDashboards": {
"type": "array",
"description": "List of dashboards with URLs.",
"default": [],
"items": {}
},
"urlDashboards": {
"type": "array",
"description": "List of dashboards with URLs.",
"default": [],
"items": {
"type": "object",
"required": ["name", "link"],
"properties": {
"name": {
"type": "string",
"description": "The name of the dashboard"
},
"link": {
"type": "string",
"format": "uri",
"description": "The URL of the dashboard JSON"
}
},
"additionalProperties": false
}
}

"jsonDashboards": {
"type": "array",
"description": "List of dashboards with inline JSON.",
"default": [],
"items": {}
},
Comment on lines +11 to +16
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Enhance schema validation for jsonDashboards

Similar to urlDashboards, the items object needs proper validation for required fields and their types.

 "jsonDashboards": {
     "type": "array",
     "description": "List of dashboards with inline JSON.",
     "default": [],
-    "items": {}
+    "items": {
+        "type": "object",
+        "required": ["name", "json"],
+        "properties": {
+            "name": {
+                "type": "string",
+                "description": "The name of the dashboard"
+            },
+            "json": {
+                "type": "object",
+                "description": "The JSON content of the dashboard"
+            }
+        },
+        "additionalProperties": false
+    }
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"jsonDashboards": {
"type": "array",
"description": "List of dashboards with inline JSON.",
"default": [],
"items": {}
},
"jsonDashboards": {
"type": "array",
"description": "List of dashboards with inline JSON.",
"default": [],
"items": {
"type": "object",
"required": ["name", "json"],
"properties": {
"name": {
"type": "string",
"description": "The name of the dashboard"
},
"json": {
"type": "object",
"description": "The JSON content of the dashboard"
}
},
"additionalProperties": false
}
},

"instanceSelector": {
"type": "object",
"description": "Selector to match Grafana instances.",
"default": {}
}
}
}
38 changes: 38 additions & 0 deletions packages/apps/grafana-dashboards/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
## @section Dashboard parameters

## @param urlDashboards List of dashboards with URLs.
## Each entry must include:
## - name: The name of the dashboard
## - link: The URL of the dashboard JSON
urlDashboards: [] # @param urlDashboards List of dashboards to load from URLs

## Example:
## urlDashboards:
## - name: "grafanadashboard-from-url"
## link: "https://raw.githubusercontent.com/grafana-operator/grafana-operator/master/examples/dashboard_from_url/dashboard.json"

## @param jsonDashboards List of dashboards with inline JSON.
## Each entry must include:
## - name: The name of the dashboard
## - json: The JSON content of the dashboard
jsonDashboards: [] # @param jsonDashboards List of dashboards to load from inline JSON

## Example:
## jsonDashboards:
## - name: "grafanadashboard-sample"
## json: |
## {
## "panels": [
## { "type": "graph", "title": "Sample Panel" }
## ]
## }


## @param instanceSelector Selector to match Grafana instances.
## Leave empty to skip instance selection.
instanceSelector: {} # @param instanceSelector Selector for matching Grafana instances

## Example:
## instanceSelector:
## matchLabels:
## dashboards: "grafana"
2 changes: 1 addition & 1 deletion packages/apps/tenant/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ description: Separated tenant namespace
icon: /logos/tenant.svg

type: application
version: 1.6.5
version: 1.6.6
18 changes: 1 addition & 17 deletions packages/apps/tenant/templates/tenant.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -241,23 +241,7 @@ rules:
- list
- apiGroups: ["apps.cozystack.io"]
resources:
- buckets
- clickhouses
- ferretdb
- foos
- httpcaches
- kafkas
- kuberneteses
- mysqls
- natses
- postgreses
- rabbitmqs
- redises
- seaweedfses
- tcpbalancers
- virtualmachines
- vmdisks
- vminstances
- "*"
verbs:
- get
- list
Expand Down
4 changes: 3 additions & 1 deletion packages/apps/versions_map
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ ferretdb 0.2.0 adaf603
ferretdb 0.3.0 aa2f553
ferretdb 0.4.0 def2eb0f
ferretdb 0.4.1 HEAD
grafana-dashboards 0.1.0 HEAD
http-cache 0.1.0 a956713
http-cache 0.2.0 5ca8823
http-cache 0.3.0 fab5940
Expand Down Expand Up @@ -95,7 +96,8 @@ tenant 1.6.1 edbbb9be
tenant 1.6.2 ccedc5fe
tenant 1.6.3 2057bb96
tenant 1.6.4 3c9e50a4
tenant 1.6.5 HEAD
tenant 1.6.5 f1e11451
tenant 1.6.6 HEAD
virtual-machine 0.1.4 f2015d6
virtual-machine 0.1.5 7cd7de7
virtual-machine 0.2.0 5ca8823
Expand Down
2 changes: 1 addition & 1 deletion packages/core/installer/values.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
cozystack:
image: ghcr.io/aenix-io/cozystack/cozystack:v0.21.1@sha256:05a1b10700b387594887785e49e496da13d83abb9dc6415195b70ed9898e9d39
image: kklinch0/cozystack:0.20.888@sha256:ecf3930271c5ac824dc6ceb6174f1368ee824e22652026e579f5a60fd910f4ac
2 changes: 1 addition & 1 deletion packages/extra/monitoring/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ name: monitoring
description: Monitoring and observability stack
icon: /logos/monitoring.svg
type: application
version: 1.5.3
version: 1.5.4
2 changes: 1 addition & 1 deletion packages/extra/monitoring/templates/grafana/grafana.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ kind: Grafana
metadata:
name: grafana
labels:
dashboards: grafana
dashboards: "{{ $myNS }}"
spec:
config:
log:
Expand Down
3 changes: 2 additions & 1 deletion packages/extra/versions_map
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ monitoring 1.4.0 adaf603b
monitoring 1.5.0 4b90bf5a
monitoring 1.5.1 57e90b70
monitoring 1.5.2 898374b5
monitoring 1.5.3 HEAD
monitoring 1.5.3 c1ca19dc
monitoring 1.5.4 HEAD
seaweedfs 0.1.0 5ca8823
seaweedfs 0.2.0 9e33dc0
seaweedfs 0.2.1 HEAD