Skip to content

Commit

Permalink
Added postgres grafana datasource creation
Browse files Browse the repository at this point in the history
  • Loading branch information
dm3ch committed Jul 30, 2021
1 parent 1f02fcb commit df3cf36
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ repos:
- id: end-of-file-fixer
- id: check-added-large-files
- id: check-yaml
exclude: ^charts/.*/templates/
exclude: ^(charts/.*/templates/|helmfile/helmfile-.*\.yaml)
- repo: git://github.com/antonbabenko/pre-commit-terraform
rev: v1.50.0
hooks:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
{
"__inputs": [
{
"name": "DS_POSTGRESQL",
"label": "PostgreSQL",
"description": "",
"type": "datasource",
"pluginId": "postgres",
"pluginName": "PostgreSQL"
}
],
"__inputs": [],
"__requires": [
{
"type": "grafana",
Expand Down Expand Up @@ -56,7 +47,7 @@
"links": [],
"panels": [
{
"datasource": "${DS_POSTGRESQL}",
"datasource": "postgres",
"fieldConfig": {
"defaults": {
"color": {
Expand Down Expand Up @@ -374,7 +365,7 @@
},
{
"columns": [],
"datasource": "${DS_POSTGRESQL}",
"datasource": "postgres",
"fontSize": "100%",
"gridPos": {
"h": 8,
Expand Down Expand Up @@ -575,7 +566,7 @@
"type": "table-old"
},
{
"datasource": "${DS_POSTGRESQL}",
"datasource": "postgres",
"fieldConfig": {
"defaults": {
"custom": {
Expand Down Expand Up @@ -832,7 +823,7 @@
"type": "table"
},
{
"datasource": "${DS_POSTGRESQL}",
"datasource": "postgres",
"fieldConfig": {
"defaults": {
"color": {
Expand Down Expand Up @@ -1251,7 +1242,7 @@
},
{
"columns": [],
"datasource": "${DS_POSTGRESQL}",
"datasource": "postgres",
"fontSize": "80%",
"gridPos": {
"h": 4,
Expand Down Expand Up @@ -1359,7 +1350,7 @@
},
{
"columns": [],
"datasource": "${DS_POSTGRESQL}",
"datasource": "postgres",
"fontSize": "80%",
"gridPos": {
"h": 4,
Expand Down
17 changes: 17 additions & 0 deletions charts/graph-grafana-dashboards/templates/_postgres-datasource.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{{- define "graph-grafana-dashboards.postgres" -}}
apiVersion: 1
datasources:
- access: proxy
editable: true
name: postgres
orgId: 1
type: postgres
url: {{ .Values.postgresDatasource.url }}
user: {{ .Values.postgresDatasource.user }}
database: {{ .Values.postgresDatasource.db }}
secureJsonData:
password: {{ .Values.postgresDatasource.password }}
jsonData:
sslmode: disable
postgresVersion: 1200
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ .Release.Name }}
labels:
grafana_datasource: "1"
data:
postgres.yaml: {{ include "graph-grafana-dashboards.postgres" . | b64enc }}
5 changes: 5 additions & 0 deletions charts/graph-grafana-dashboards/values.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
#
postgresDatasource:
url:
user:
db:
password:
8 changes: 5 additions & 3 deletions helmfile/helmfile-infra.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ releases:
chart: kubernetes-dashboard/kubernetes-dashboard
version: ~4.3.1

- name: graph-grafana-dashboards
chart: ../charts/graph-grafana-dashboards

- name: prometheus-stack
chart: prometheus-community/kube-prometheus-stack
version: ~17.0.3
Expand All @@ -62,3 +59,8 @@ releases:
foldersFromFilesStructure: true
persistence:
enabled: true

- name: graph-grafana-dashboards
chart: ../charts/graph-grafana-dashboards
values:
- postgresDatasource: {{ toYaml .Values.postgresDatasource | nindent 6 }}

0 comments on commit df3cf36

Please sign in to comment.