Merge pull request #2 from grafana/enable_dbs_individually

Enable DBs separately
This commit is contained in:
Michel Hollands 2023-06-30 12:45:08 +01:00 committed by GitHub
commit 39a187457c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 70 additions and 27 deletions

View File

@ -27,19 +27,22 @@ dependencies:
- name: loki - name: loki
repository: https://grafana.github.io/helm-charts repository: https://grafana.github.io/helm-charts
version: "5.8.0" version: "5.8.0"
condition: local.enabled condition: local.logs.enabled
- name: grafana-agent - name: grafana-agent
repository: https://grafana.github.io/helm-charts repository: https://grafana.github.io/helm-charts
version: "0.15.0" version: "0.15.0"
- name: mimir-distributed - name: mimir-distributed
repository: https://grafana.github.io/helm-charts repository: https://grafana.github.io/helm-charts
version: "4.4.1" version: "4.4.1"
condition: local.enabled condition: local.metrics.enabled
- name: tempo-distributed - name: tempo-distributed
repository: https://grafana.github.io/helm-charts repository: https://grafana.github.io/helm-charts
version: "1.4.7" version: "1.4.7"
condition: local.enabled condition: local.traces.enabled
- name: minio - name: minio
repository: https://charts.min.io repository: https://charts.min.io
version: "5.0.11" version: "5.0.11"
condition: local.enabled tags:
- local-logs
- local-metrics
- local-traces

View File

@ -8,10 +8,10 @@
{{- define "agent.loki_write_targets" -}} {{- define "agent.loki_write_targets" -}}
{{- $list := list }} {{- $list := list }}
{{- if .Values.local.enabled }} {{- if .Values.local.logs.enabled }}
{{- $list = append $list ("loki.write.local.receiver") }} {{- $list = append $list ("loki.write.local.receiver") }}
{{- end }} {{- end }}
{{- if .Values.cloud.enabled }} {{- if .Values.cloud.logs.enabled }}
{{- $list = append $list ("loki.write.cloud.receiver") }} {{- $list = append $list ("loki.write.cloud.receiver") }}
{{- end }} {{- end }}
{{- join ", " $list }} {{- join ", " $list }}
@ -19,10 +19,10 @@
{{- define "agent.prometheus_write_targets" -}} {{- define "agent.prometheus_write_targets" -}}
{{- $list := list }} {{- $list := list }}
{{- if .Values.local.enabled }} {{- if .Values.local.metrics.enabled }}
{{- $list = append $list ("prometheus.remote_write.local.receiver") }} {{- $list = append $list ("prometheus.remote_write.local.receiver") }}
{{- end }} {{- end }}
{{- if .Values.cloud.enabled }} {{- if .Values.cloud.metrics.enabled }}
{{- $list = append $list ("prometheus.remote_write.cloud.receiver") }} {{- $list = append $list ("prometheus.remote_write.cloud.receiver") }}
{{- end }} {{- end }}
{{- join ", " $list }} {{- join ", " $list }}
@ -30,10 +30,10 @@
{{- define "agent.tempo_write_targets" -}} {{- define "agent.tempo_write_targets" -}}
{{- $list := list }} {{- $list := list }}
{{- if .Values.local.enabled }} {{- if .Values.local.traces.enabled }}
{{- $list = append $list ("otelcol.exporter.otlp.local.input") }} {{- $list = append $list ("otelcol.exporter.otlp.local.input") }}
{{- end }} {{- end }}
{{- if .Values.cloud.enabled }} {{- if .Values.cloud.traces.enabled }}
{{- $list = append $list ("otelcol.exporter.otlp.cloud.input") }} {{- $list = append $list ("otelcol.exporter.otlp.cloud.input") }}
{{- end }} {{- end }}
{{- join ", " $list }} {{- join ", " $list }}

View File

@ -37,16 +37,21 @@ data:
} }
} }
{{- if or .Values.local.logs.enabled .Values.cloud.logs.enabled }}
loki.source.kubernetes "pods" { loki.source.kubernetes "pods" {
targets = discovery.relabel.rename_meta_labels.output targets = discovery.relabel.rename_meta_labels.output
forward_to = [ {{ include "agent.loki_write_targets" . }} ] forward_to = [ {{ include "agent.loki_write_targets" . }} ]
} }
{{- end }}
{{- if or .Values.local.metrics.enabled .Values.cloud.metrics.enabled }}
prometheus.scrape "pods" { prometheus.scrape "pods" {
targets = discovery.relabel.rename_meta_labels.output targets = discovery.relabel.rename_meta_labels.output
forward_to = [ {{ include "agent.prometheus_write_targets" . }} ] forward_to = [ {{ include "agent.prometheus_write_targets" . }} ]
} }
{{- end }}
{{- if or .Values.local.traces.enabled .Values.cloud.traces.enabled }}
// Shamelessly copied from https://github.com/grafana/intro-to-mlt/blob/main/agent/config.river // Shamelessly copied from https://github.com/grafana/intro-to-mlt/blob/main/agent/config.river
otelcol.receiver.otlp "otlp_receiver" { otelcol.receiver.otlp "otlp_receiver" {
// We don't technically need this, but it shows how to change listen address and incoming port. // We don't technically need this, but it shows how to change listen address and incoming port.
@ -75,20 +80,25 @@ data:
traces = [ {{ include "agent.tempo_write_targets" . }} ] traces = [ {{ include "agent.tempo_write_targets" . }} ]
} }
} }
{{- end }}
{{- if .Values.local.enabled }} {{- if .Values.local.logs.enabled }}
loki.write "local" { loki.write "local" {
endpoint { endpoint {
url = "http://loki-gateway.{{- .Release.Namespace -}}.svc.cluster.local:80/loki/api/v1/push" url = "http://loki-gateway.{{- .Release.Namespace -}}.svc.cluster.local:80/loki/api/v1/push"
} }
} }
{{- end }}
{{- if .Values.local.metrics.enabled }}
prometheus.remote_write "local" { prometheus.remote_write "local" {
endpoint { endpoint {
url = "http://{{- .Release.Name -}}-mimir-nginx.{{- .Release.Namespace -}}.svc:80/api/v1/push" url = "http://{{- .Release.Name -}}-mimir-nginx.{{- .Release.Namespace -}}.svc:80/api/v1/push"
} }
} }
{{- end }}
{{- if or .Values.local.traces.enabled .Values.cloud.traces.enabled }}
// The OpenTelemetry exporter exports processed trace spans to another target that is listening for OTLP format traces. // The OpenTelemetry exporter exports processed trace spans to another target that is listening for OTLP format traces.
// A unique label, 'local', is added to uniquely identify this exporter. // A unique label, 'local', is added to uniquely identify this exporter.
otelcol.exporter.otlp "local" { otelcol.exporter.otlp "local" {
@ -107,7 +117,7 @@ data:
} }
{{- end }} {{- end }}
{{- if .Values.cloud.enabled }} {{- if .Values.cloud.logs.enabled }}
loki.write "cloud" { loki.write "cloud" {
endpoint { endpoint {
url = "{{- .Values.cloud.logs.endpoint -}}/loki/api/v1/push" url = "{{- .Values.cloud.logs.endpoint -}}/loki/api/v1/push"
@ -118,7 +128,9 @@ data:
} }
} }
} }
{{- end }}
{{- if .Values.cloud.metrics.enabled }}
prometheus.remote_write "cloud" { prometheus.remote_write "cloud" {
endpoint { endpoint {
url = "{{- .Values.cloud.metrics.endpoint -}}/api/prom/push" url = "{{- .Values.cloud.metrics.endpoint -}}/api/prom/push"
@ -129,7 +141,9 @@ data:
} }
} }
} }
{{- end }}
{{- if .Values.cloud.traces.enabled }}
otelcol.exporter.otlp "cloud" { otelcol.exporter.otlp "cloud" {
client { client {
endpoint = "{{- .Values.cloud.traces.endpoint -}}" endpoint = "{{- .Values.cloud.traces.endpoint -}}"

View File

@ -1,4 +1,4 @@
{{ if .Values.local.enabled }} {{- if .Values.local.logs.enabled }}
--- ---
apiVersion: v1 apiVersion: v1
kind: ConfigMap kind: ConfigMap

View File

@ -1,4 +1,4 @@
{{ if .Values.local.enabled }} {{- if .Values.local.logs.enabled }}
--- ---
apiVersion: v1 apiVersion: v1
kind: ConfigMap kind: ConfigMap

View File

@ -1,4 +1,4 @@
{{ if .Values.local.enabled }} {{- if .Values.local.logs.enabled }}
--- ---
apiVersion: v1 apiVersion: v1
kind: ConfigMap kind: ConfigMap

View File

@ -1,4 +1,4 @@
{{ if .Values.local.enabled }} {{- if or (or .Values.local.logs.enabled .Values.local.metrics.enabled) .Values.local.traces.enabled }}
--- ---
apiVersion: v1 apiVersion: v1
kind: ConfigMap kind: ConfigMap
@ -20,6 +20,7 @@ data:
datasources: datasources:
# <string, required> Sets the name you use to refer to # <string, required> Sets the name you use to refer to
# the data source in panels and queries. # the data source in panels and queries.
{{- if .Values.local.logs.enabled }}
- name: Loki - name: Loki
# <string, required> Sets the data source type. # <string, required> Sets the data source type.
type: loki type: loki
@ -39,6 +40,8 @@ data:
# <bool> Allows users to edit data sources from the # <bool> Allows users to edit data sources from the
# Grafana UI. # Grafana UI.
editable: true editable: true
{{- end }}
{{- if .Values.local.metrics.enabled }}
- name: Mimir - name: Mimir
# <string, required> Sets the data source type. # <string, required> Sets the data source type.
type: prometheus type: prometheus
@ -58,6 +61,8 @@ data:
# <bool> Allows users to edit data sources from the # <bool> Allows users to edit data sources from the
# Grafana UI. # Grafana UI.
editable: true editable: true
{{- end }}
{{- if .Values.local.traces.enabled }}
- name: Tempo - name: Tempo
# <string, required> Sets the data source type. # <string, required> Sets the data source type.
type: tempo type: tempo
@ -77,4 +82,5 @@ data:
# <bool> Allows users to edit data sources from the # <bool> Allows users to edit data sources from the
# Grafana UI. # Grafana UI.
editable: true editable: true
{{- end }}
{{- end }} {{- end }}

View File

@ -1,4 +1,4 @@
{{ if .Values.local.enabled }} {{- if or (or .Values.local.logs.enabled .Values.local.metrics.enabled) .Values.local.traces.enabled }}
--- ---
apiVersion: v1 apiVersion: v1
kind: PersistentVolumeClaim kind: PersistentVolumeClaim
@ -63,30 +63,34 @@ spec:
volumeMounts: volumeMounts:
- mountPath: /var/lib/grafana - mountPath: /var/lib/grafana
name: grafana-pv name: grafana-pv
- mountPath: /etc/grafana/provisioning/datasources
name: loki-datasources-provisioning
{{- if .Values.local.logs.enabled }}
- mountPath: /etc/grafana/provisioning/dashboards
name: loki-dashboards-provisioning
- mountPath: /var/lib/grafana/dashboards/loki-1 - mountPath: /var/lib/grafana/dashboards/loki-1
name: loki-dashboards-1 name: loki-dashboards-1
- mountPath: /var/lib/grafana/dashboards/loki-2 - mountPath: /var/lib/grafana/dashboards/loki-2
name: loki-dashboards-2 name: loki-dashboards-2
- mountPath: /etc/grafana/provisioning/dashboards {{- end }}
name: loki-dashboards-provisioning
- mountPath: /etc/grafana/provisioning/datasources
name: loki-datasources-provisioning
volumes: volumes:
- name: grafana-pv - name: grafana-pv
persistentVolumeClaim: persistentVolumeClaim:
claimName: grafana-pvc claimName: grafana-pvc
- name: loki-dashboards-provisioning
configMap:
name: loki-dashboards-provisioning
- name: loki-datasources-provisioning - name: loki-datasources-provisioning
configMap: configMap:
name: loki-datasources-provisioning name: loki-datasources-provisioning
{{- if .Values.local.logs.enabled }}
- name: loki-dashboards-provisioning
configMap:
name: loki-dashboards-provisioning
- name: loki-dashboards-1 - name: loki-dashboards-1
configMap: configMap:
name: loki-dashboards-1 name: loki-dashboards-1
- name: loki-dashboards-2 - name: loki-dashboards-2
configMap: configMap:
name: loki-dashboards-2 name: loki-dashboards-2
{{- end }}
--- ---
apiVersion: v1 apiVersion: v1

View File

@ -3,19 +3,35 @@ namespacesToMonitor:
- mimir - mimir
- tempo - tempo
clusterName: "observability" # TODO check if this can be derived clusterName: "observability" # TODO check if this can be derived
# Turn on or off for local storing of metrics, logs or traces
tags:
local-logs: true
local-metrics: true
local-traces: true
# Unfortunately this is duplicate as Helm's tags and conditions fro dependencies are limited
local: local:
enabled: true
cloud:
enabled: false
logs: logs:
enabled: false
metrics:
enabled: false
traces:
enabled: false
cloud:
logs:
enabled: true
endpoint: endpoint:
username: username:
password: password:
metrics: metrics:
enabled: true
endpoint: endpoint:
username: username:
password: password:
traces: traces:
enabled: true
endpoint: endpoint:
username: username:
password: password: