Add dashboards and datasources, update flow config

Signed-off-by: Michel Hollands <michel.hollands@grafana.com>
This commit is contained in:
Michel Hollands
2023-06-21 11:22:42 +01:00
parent 0f66cad545
commit 1db4265627
17 changed files with 14260 additions and 6 deletions

View File

@@ -8,23 +8,55 @@ data:
discovery.kubernetes "pods" {
role = "pod"
namespaces {
own_namespace = false
names = [ {{ include "agent.namespaces" . }} ]
}
}
loki.source.kubernetes "pods" {
targets = discovery.kubernetes.pods.targets
forward_to = [loki.write.local.receiver]
forward_to = [loki.relabel.loki.receiver]
}
// TODO: fix this, it is not working
loki.relabel "loki" {
forward_to = [loki.process.loki.receiver]
rule {
source_labels = ["__meta_kubernetes_namespace"]
target_label = "namespace"
}
rule {
source_labels = ["__meta_kubernetes_pod_name"]
target_label = "pod"
}
}
loki.process "loki" {
forward_to = [loki.write.local.receiver]
stage.static_labels {
values = {
cluster = "{{- .Values.clusterName -}}",
}
}
stage.label_drop {
values = ["job"]
}
}
prometheus.scrape "pods" {
targets = discovery.kubernetes.pods.targets
forward_to = [prometheus.remote_write.default.receiver]
}
loki.write "local" {
endpoint {
url = "http://{{- .Release.Name -}}-loki.{{- .Release.Namespace -}}.svc.cluster.local:3100/loki/api/v1/push"
}
}
prometheus.scrape "pods" {
targets = discovery.kubernetes.pods.targets
forward_to = [prometheus.remote_write.default.receiver]
}
prometheus.remote_write "default" {
endpoint {
url = "http://{{- .Release.Name -}}-mimir-nginx.{{- .Release.Namespace -}}.svc:80/api/v1/push"

View File

@@ -0,0 +1,17 @@
---
apiVersion: v1
kind: ConfigMap
metadata:
name: loki-dashboards-1
namespace: {{ $.Release.Namespace }}
data:
"loki-chunks.json": |
{{ $.Files.Get "src/dashboards/loki-chunks.json" | fromJson | toJson }}
"loki-deletion.json": |
{{ $.Files.Get "src/dashboards/loki-deletion.json" | fromJson | toJson }}
"loki-logs.json": |
{{ $.Files.Get "src/dashboards/loki-logs.json" | fromJson | toJson }}
"loki-mixin-recording-rules.json": |
{{ $.Files.Get "src/dashboards/loki-mixin-recording-rules.json" | fromJson | toJson }}
"loki-operational.json": |
{{ $.Files.Get "src/dashboards/loki-operational.json" | fromJson | toJson }}

View File

@@ -0,0 +1,17 @@
---
apiVersion: v1
kind: ConfigMap
metadata:
name: loki-dashboards-2
namespace: {{ $.Release.Namespace }}
data:
"loki-reads-resources.json": |
{{ $.Files.Get "src/dashboards/loki-reads-resources.json" | fromJson | toJson }}
"loki-reads.json": |
{{ $.Files.Get "src/dashboards/loki-reads.json" | fromJson | toJson }}
"loki-retention.json": |
{{ $.Files.Get "src/dashboards/loki-retention.json" | fromJson | toJson }}
"loki-writes-resources.json": |
{{ $.Files.Get "src/dashboards/loki-writes-resources.json" | fromJson | toJson }}
"loki-writes.json": |
{{ $.Files.Get "src/dashboards/loki-writes.json" | fromJson | toJson }}

View File

@@ -0,0 +1,27 @@
---
apiVersion: v1
kind: ConfigMap
metadata:
name: loki-dashboards-provisioning
namespace: {{ $.Release.Namespace }}
data:
dashboards.yaml: |
---
apiVersion: 1
providers:
- disableDeletion: true
editable: false
folder: Loki
name: loki-1
options:
path: /var/lib/grafana/dashboards/loki-1
orgId: 1
type: file
- disableDeletion: true
editable: false
folder: Loki
name: loki-2
options:
path: /var/lib/grafana/dashboards/loki-2
orgId: 1
type: file

View File

@@ -0,0 +1,59 @@
---
apiVersion: v1
kind: ConfigMap
metadata:
name: loki-datasources-provisioning
namespace: {{ $.Release.Namespace }}
data:
datasources.yaml: |
# Configuration file version
apiVersion: 1
# List of data sources to delete from the database.
deleteDatasources:
- name: Loki
orgId: 1
# List of data sources to insert/update depending on what's
# available in the database.
datasources:
# <string, required> Sets the name you use to refer to
# the data source in panels and queries.
- name: Loki
# <string, required> Sets the data source type.
type: loki
# <int> Sets the organization id. Defaults to orgId 1.
orgId: 1
# <string> Sets a custom UID to reference this
# data source in other parts of the configuration.
# If not specified, Grafana generates one.
uid: loki_ds
# <string> Sets the data source's URL, including the
# port.
url: http://loki-gateway.{{- $.Release.Namespace -}}.svc.cluster.local
# <bool> Toggles whether the data source is pre-selected
# for new panels. You can set only one default
# data source per organization.
isDefault:
# <bool> Allows users to edit data sources from the
# Grafana UI.
editable: true
- name: Mimir
# <string, required> Sets the data source type.
type: prometheus
# <int> Sets the organization id. Defaults to orgId 1.
orgId: 1
# <string> Sets a custom UID to reference this
# data source in other parts of the configuration.
# If not specified, Grafana generates one.
uid: mimir_ds
# <string> Sets the data source's URL, including the
# port.
url: http://{{- $.Release.Name -}}-mimir-nginx.{{- $.Release.Namespace -}}.svc:80/prometheus
# <bool> Toggles whether the data source is pre-selected
# for new panels. You can set only one default
# data source per organization.
isDefault:
# <bool> Allows users to edit data sources from the
# Grafana UI.
editable: true

View File

@@ -62,10 +62,31 @@ spec:
volumeMounts:
- mountPath: /var/lib/grafana
name: grafana-pv
- mountPath: /var/lib/grafana/dashboards/loki-1
name: loki-dashboards-1
- mountPath: /var/lib/grafana/dashboards/loki-2
name: loki-dashboards-2
- mountPath: /etc/grafana/provisioning/dashboards
name: loki-dashboards-provisioning
- mountPath: /etc/grafana/provisioning/datasources
name: loki-datasources-provisioning
volumes:
- name: grafana-pv
persistentVolumeClaim:
claimName: grafana-pvc
- name: loki-dashboards-provisioning
configMap:
name: loki-dashboards-provisioning
- name: loki-datasources-provisioning
configMap:
name: loki-datasources-provisioning
- name: loki-dashboards-1
configMap:
name: loki-dashboards-1
- name: loki-dashboards-2
configMap:
name: loki-dashboards-2
---
apiVersion: v1
kind: Service