added repo

This commit is contained in:
Your Name
2026-08-26 03:39:42 +05:30
parent 45c25a95af
commit b8575bb8b9
6889 changed files with 1217125 additions and 0 deletions
@@ -0,0 +1,70 @@
{{- define "mimir.metaMonitoring.metrics.remoteWrite" -}}
{{- $writeBackToMimir := not .url -}}
{{- $url := .url -}}
{{- if $writeBackToMimir -}}
{{- $url = include "mimir.remoteWriteUrl.inCluster" .ctx }}
{{- end -}}
- url: {{ $url }}
{{- if .auth }}
basicAuth:
{{- if .auth.username }}
username:
name: {{ include "mimir.resourceName" (dict "ctx" $.ctx "component" "metrics-instance-usernames") }}
key: {{ .usernameKey | quote }}
{{- end }}
{{- with .auth }}
{{- if and .passwordSecretKey .passwordSecretName }}
password:
name: {{ .passwordSecretName | quote }}
key: {{ .passwordSecretKey | quote }}
{{- else if or .passwordSecretKey .passwordSecretName }}{{ required "Set either both passwordSecretKey and passwordSecretName or neither" nil }}
{{- end }}
{{- end }}
{{- end }}
{{- $headers := .headers -}}
{{- if $writeBackToMimir -}}{{- $_ := set $headers "X-Scope-OrgID" "metamonitoring" -}}{{- end -}}
{{- with $headers }}
headers:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end -}}
{{- define "mimir.metaMonitoring.logs.client" -}}
{{- if .url }}
- url: {{ .url }}
{{- if .auth }}
{{- if .auth.tenantId }}
tenantId: {{ .auth.tenantId | quote }}
{{- end }}
basicAuth:
{{- if .auth.username }}
username:
name: {{ include "mimir.resourceName" (dict "ctx" $.ctx "component" "logs-instance-usernames") }}
key: {{ .usernameKey | quote }}
{{- end }}
{{- with .auth }}
{{- if and .passwordSecretKey .passwordSecretName }}
password:
name: {{ .passwordSecretName | quote }}
key: {{ .passwordSecretKey | quote }}
{{- else if or .passwordSecretKey .passwordSecretName }}
{{ required "Set either both passwordSecretKey and passwordSecretName or neither" nil }}
{{- end }}
{{- end }}
{{- end }}
externalLabels:
cluster: {{ include "mimir.clusterName" $.ctx | quote}}
{{- end -}}
{{- end -}}
{{- define "mimir.metaMonitoring.metrics.remoteReadUrl" -}}
{{- with $.ctx.Values.metaMonitoring.grafanaAgent.metrics }}
{{- $writeBackToMimir := not (.remote).url -}}
{{- if $writeBackToMimir -}}
{{- include "mimir.remoteReadUrl.inCluster" $.ctx }}
{{- else -}}
{{- $parsed := urlParse (.remote).url -}}
{{ $parsed.scheme }}://{{ $parsed.host }}/prometheus
{{- end }}
{{- end -}}
{{- end -}}
@@ -0,0 +1,19 @@
{{- with (.Values.metaMonitoring).grafanaAgent }}
{{- if .enabled }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ include "mimir.resourceName" (dict "ctx" $ "component" "grafana-agent") }}
namespace: {{ .namespace | default $.Release.Namespace | quote }}
labels:
{{- include "mimir.labels" (dict "ctx" $ "component" "meta-monitoring" ) | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ include "mimir.resourceName" (dict "ctx" $ "component" "grafana-agent") }}
subjects:
- kind: ServiceAccount
name: {{ include "mimir.serviceAccountName" $ }}
namespace: {{ .namespace | default $.Release.Namespace }}
{{- end }}
{{- end }}
@@ -0,0 +1,39 @@
{{- with (.Values.metaMonitoring).grafanaAgent }}
{{- if .enabled }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ include "mimir.resourceName" (dict "ctx" $ "component" "grafana-agent") }}
namespace: {{ .namespace | default $.Release.Namespace | quote }}
labels:
{{- include "mimir.labels" (dict "ctx" $ "component" "meta-monitoring" ) | nindent 4 }}
rules:
- apiGroups:
- ""
resources:
- nodes
- nodes/proxy
- nodes/metrics
- services
- endpoints
- pods
- events
verbs:
- get
- list
- watch
- apiGroups:
- networking.k8s.io
resources:
- ingresses
verbs:
- get
- list
- watch
- nonResourceURLs:
- /metrics
- /metrics/cadvisor
verbs:
- get
{{- end }}
{{- end }}
@@ -0,0 +1,59 @@
{{- with (.Values.metaMonitoring).grafanaAgent }}
{{- if .enabled }}
apiVersion: monitoring.grafana.com/v1alpha1
kind: GrafanaAgent
metadata:
name: {{ include "mimir.resourceName" (dict "ctx" $ "component" "meta-monitoring") }}
namespace: {{ .namespace | default $.Release.Namespace | quote }}
labels:
{{- include "mimir.labels" (dict "ctx" $ "component" "meta-monitoring" ) | nindent 4 }}
{{- with .labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
serviceAccountName: {{ include "mimir.serviceAccountName" $ }}
{{- with .podSecurityContext }}
securityContext:
{{- . | toYaml | nindent 4 }}
{{- end }}
containers:
# The container specs here are merged with the ones in the operator using a strategic merge patch.
- name: config-reloader
{{- if .imageRepo }}{{ if .imageRepo.configReloader }}
{{- with .imageRepo.configReloader }}
image: {{ .repo }}/{{ .image }}:{{ .tag }}
{{- end }}
{{- end }}{{ end }}
{{- with .containerSecurityContext }}
securityContext:
{{- . | toYaml | nindent 8 }}
{{- end }}
- name: grafana-agent
{{- if .imageRepo }}{{ if .imageRepo.grafanaAgent }}
{{- with .imageRepo.grafanaAgent }}
image: {{ .repo }}/{{ .image }}:{{ .tag }}
{{- end }}
{{- end }}{{ end }}
{{- with .containerSecurityContext }}
securityContext:
{{- . | toYaml | nindent 8 }}
{{- end }}
logs:
instanceSelector:
matchLabels:
{{- include "mimir.selectorLabels" (dict "ctx" $ "component" "meta-monitoring") | nindent 8 }}
# cluster label for logs is added in the LogsInstance
metrics:
scrapeInterval: {{ .metrics.scrapeInterval }}
instanceSelector:
matchLabels:
{{- include "mimir.selectorLabels" (dict "ctx" $ "component" "meta-monitoring") | nindent 8 }}
externalLabels:
cluster: {{ include "mimir.clusterName" $ }}
{{- end }}
{{- end }}
@@ -0,0 +1,27 @@
{{- $currentScope := .Values.metaMonitoring.dashboards }}
{{- if $currentScope.enabled }}
{{ range $path, $_ := $.Files.Glob "mixins/dashboards/*.json" }}
{{ $file := $path | base }}
{{ $name := print ($file | trimSuffix ".json") "-dashboard" }}
{{- with $currentScope}}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ $name }}
namespace: {{ $.Release.Namespace }}
labels:
{{- include "mimir.labels" (dict "ctx" $) | nindent 4 }}
{{- with .labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
data:
{{ $file }}: |-
{{ $.Files.Get $path | indent 4 }}
---
{{- end }}
{{ end }}
{{- end }}
@@ -0,0 +1,49 @@
{{- if and .Values.metaMonitoring.grafanaAgent.enabled .Values.metaMonitoring.grafanaAgent.metrics.enabled .Values.metaMonitoring.grafanaAgent.metrics.scrapeK8s.enabled }}
{{- with .Values.metaMonitoring.serviceMonitor }}
{{- if .enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ include "mimir.resourceName" (dict "ctx" $ "component" "k8s-ksm") }}
namespace: {{ .namespace | default $.Release.Namespace | quote }}
labels:
{{- include "mimir.labels" (dict "ctx" $ "component" "meta-monitoring") | nindent 4 }}
{{- with .labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
endpoints:
- port: {{ $.Values.metaMonitoring.grafanaAgent.metrics.scrapeK8s.kubeStateMetrics.service.port }}
metricRelabelings:
- action: keep
regex: "(^|.*;){{ include "mimir.resourceName" (dict "ctx" $) }}.*"
sourceLabels:
- deployment
- statefulset
- pod
separator: ';'
{{- if kindIs "string" .clusterLabel }}
relabelings:
- targetLabel: cluster
replacement: "{{ .clusterLabel | default (include "mimir.clusterName" $) }}"
{{- end }}
path: /metrics
honorLabels: true # retain namespace label from kube-state-metrics
{{- with .scrapeTimeout }}
scrapeTimeout: {{ . }}
{{- end }}
{{- with ((((($.Values).metaMonitoring).grafanaAgent).metrics).scrapeK8s).kubeStateMetrics }}
namespaceSelector:
matchNames:
- {{ .namespace }}
selector:
matchLabels:
{{- toYaml .labelSelectors | nindent 6 }}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
@@ -0,0 +1,91 @@
{{- if and .Values.metaMonitoring.grafanaAgent.enabled .Values.metaMonitoring.grafanaAgent.metrics.enabled .Values.metaMonitoring.grafanaAgent.metrics.scrapeK8s.enabled }}
{{- with .Values.metaMonitoring.serviceMonitor }}
{{- if .enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ include "mimir.resourceName" (dict "ctx" $ "component" "k8s-kubelet-cadvisor") }}
namespace: {{ .namespace | default $.Release.Namespace | quote }}
labels:
{{- include "mimir.labels" (dict "ctx" $ "component" "meta-monitoring") | nindent 4 }}
{{- with .labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
endpoints:
- bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
{{- with .interval }}
interval: {{ . }}
{{- end }}
{{- with .scrapeTimeout }}
scrapeTimeout: {{ . }}
{{- end }}
port: https-metrics
honorLabels: true # retain namespace label from kubelet
relabelings:
- replacement: kubelet # add so that e.g. up{} metric doesn't get clashes with the other endpoint
targetLabel: source
{{- if kindIs "string" .clusterLabel }}
- targetLabel: cluster
replacement: "{{ .clusterLabel | default (include "mimir.clusterName" $) }}"
{{- end }}
{{- with .relabelings }}
{{- toYaml . | nindent 8 }}
{{- end }}
metricRelabelings:
- action: keep
regex: storage-{{ include "mimir.resourceName" (dict "ctx" $) }}.*
sourceLabels:
- persistentvolumeclaim # present on kubelet_volume_stats* metrics
- targetLabel: instance # replace so that the metrics work with the default metrics mixin
sourceLabels:
- node
scheme: https
tlsConfig:
caFile: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
- bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
{{- with .interval }}
interval: {{ . }}
{{- end }}
{{- with .scrapeTimeout }}
scrapeTimeout: {{ . }}
{{- end }}
path: /metrics/cadvisor
port: https-metrics
honorLabels: true # retain namespace label from cadvisor
relabelings:
- replacement: cadvisor # add so that e.g. up{} metric doesn't get clashes with the other endpoint
targetLabel: source
- targetLabel: instance # replace so that the metrics work with the default metrics mixin
sourceLabels:
- node
{{- if kindIs "string" .clusterLabel }}
- targetLabel: cluster
replacement: "{{ .clusterLabel | default (include "mimir.clusterName" $) }}"
{{- end }}
{{- with .relabelings }}
{{- toYaml . | nindent 8 }}
{{- end }}
metricRelabelings:
- action: keep
regex: {{ include "mimir.resourceName" (dict "ctx" $) }}.*
sourceLabels:
- pod
scheme: https
tlsConfig:
caFile: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
namespaceSelector:
matchNames:
# "default" is the default namespace in which the operator creates the kubelet service.
- default
selector:
matchLabels:
# This is a service added by the agent operator, so this labels is hardcoded to what the operator creates.
app.kubernetes.io/name: kubelet
{{- end -}}
{{- end -}}
{{- end -}}
@@ -0,0 +1,17 @@
{{- if and .Values.metaMonitoring.grafanaAgent.enabled .Values.metaMonitoring.grafanaAgent.logs.enabled }}
{{- with ((.Values.metaMonitoring).grafanaAgent).logs }}
apiVersion: v1
kind: Secret
metadata:
name: {{ include "mimir.resourceName" (dict "ctx" $ "component" "logs-instance-usernames") }}
namespace: {{ (($.Values.metaMonitoring).grafanaAgent).namespace | default $.Release.Namespace | quote }}
labels:
{{- include "mimir.labels" (dict "ctx" $ "component" "meta-monitoring") | nindent 4 }}
data:
{{- range $i, $cfg := prepend (.additionalClientConfigs | default list) .remote }}
{{- if (($cfg).auth).username }}
username-{{ $i }}: {{ (($cfg).auth).username | b64enc | quote }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
@@ -0,0 +1,36 @@
{{- with (.Values.metaMonitoring).grafanaAgent }}
{{- if and .enabled .logs.enabled }}
apiVersion: monitoring.grafana.com/v1alpha1
kind: LogsInstance
metadata:
name: {{ include "mimir.resourceName" (dict "ctx" $ "component" "meta-monitoring") }}
namespace: {{ (($.Values.metaMonitoring).grafanaAgent).namespace | default $.Release.Namespace | quote }}
labels:
{{- include "mimir.labels" (dict "ctx" $ "component" "meta-monitoring" ) | nindent 4 }}
{{- with .labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
clients:
{{- if or (.logs).additionalClientConfigs (.logs).remote }}
{{- range $i, $cfg := prepend ((.logs).additionalClientConfigs | default list) (.logs).remote }}
{{- with $cfg }}
{{- include "mimir.metaMonitoring.logs.client" (dict "ctx" $ "url" .url "auth" .auth "usernameKey" (printf "username-%d" $i)) | nindent 6 -}}
{{- end }}
{{- end }}
{{- end }}
# Supply an empty namespace selector to look in all namespaces. Remove
# this to only look in the same namespace as the LogsInstance CR
podLogsNamespaceSelector: {}
podLogsSelector:
matchLabels:
{{- include "mimir.selectorLabels" (dict "ctx" $) | nindent 6 }}
{{- end -}}
{{- end -}}
@@ -0,0 +1,19 @@
{{- with .Values.metaMonitoring.grafanaAgent }}
{{- if and .enabled .metrics.enabled }}
{{- with .metrics }}
apiVersion: v1
kind: Secret
metadata:
name: {{ include "mimir.resourceName" (dict "ctx" $ "component" "metrics-instance-usernames") }}
namespace: {{ $.Values.metaMonitoring.grafanaAgent.namespace | default $.Release.Namespace | quote }}
labels:
{{- include "mimir.labels" (dict "ctx" $ "component" "meta-monitoring") | nindent 4 }}
data:
{{- range $i, $cfg := prepend (.additionalRemoteWriteConfigs | default list) .remote }}
{{- if (($cfg).auth).username }}
username-{{ $i }}: {{ $cfg.auth.username | b64enc | quote }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
@@ -0,0 +1,36 @@
{{- with .Values.metaMonitoring.grafanaAgent }}
{{- if and .enabled .metrics.enabled }}
apiVersion: monitoring.grafana.com/v1alpha1
kind: MetricsInstance
metadata:
name: {{ include "mimir.resourceName" (dict "ctx" $ "component" "meta-monitoring") }}
namespace: {{ $.Values.metaMonitoring.grafanaAgent.namespace | default $.Release.Namespace | quote }}
labels:
{{- include "mimir.labels" (dict "ctx" $ "component" "meta-monitoring" ) | nindent 4 }}
{{- with .labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
remoteWrite:
{{- if or (.metrics).additionalRemoteWriteConfigs (.metrics).remote }}
{{- range $i, $cfg := prepend ((.metrics).additionalRemoteWriteConfigs | default list) (.metrics).remote }}
{{- with $cfg }}
{{- include "mimir.metaMonitoring.metrics.remoteWrite" (dict "ctx" $ "url" .url "auth" .auth "usernameKey" (printf "username-%d" $i) "headers" .headers ) | nindent 6 -}}
{{- end }}
{{- end }}
{{- end }}
# Supply an empty namespace selector to look in all namespaces. Remove
# this to only look in the same namespace as the MetricsInstance CR
serviceMonitorNamespaceSelector: {}
serviceMonitorSelector:
# Scrape ServiceMonitors from all components
matchLabels:
{{- include "mimir.selectorLabels" (dict "ctx" $) | nindent 6 }}
{{- end }}
{{- end }}
@@ -0,0 +1,20 @@
{{- with .Values.metaMonitoring.prometheusRule }}
{{- if .mimirAlerts }}
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
name: {{ include "mimir.resourceName" (dict "ctx" $ "component" "alerts") }}
{{- with .annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "mimir.labels" (dict "ctx" $) | nindent 4 }}
{{- with .labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
namespace: {{ .namespace | default $.Release.Namespace | quote }}
spec:
{{- $.Files.Get "mixins/alerts.yaml" | nindent 2 }}
{{- end }}
{{- end }}
@@ -0,0 +1,47 @@
{{- with (.Values.metaMonitoring).grafanaAgent }}
{{- if and .enabled .logs.enabled }}
apiVersion: monitoring.grafana.com/v1alpha1
kind: PodLogs
metadata:
name: {{ include "mimir.resourceName" (dict "ctx" $ "component" "meta-monitoring") }}
namespace: {{ .namespace | default $.Release.Namespace | quote }}
labels:
{{- include "mimir.labels" (dict "ctx" $ "component" "meta-monitoring") | nindent 4 }}
{{- with .labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
pipelineStages:
- cri: { }
relabelings:
- action: replace # For consistency with metrics
replacement: $1
separator: /
sourceLabels:
- __meta_kubernetes_namespace
- __meta_kubernetes_pod_container_name
targetLabel: job
- action: replace # Necessary for slow queries dashboard
sourceLabels:
- __meta_kubernetes_pod_container_name
targetLabel: name
{{- if kindIs "string" .logs.clusterLabel }}
- targetLabel: cluster
replacement: "{{ .logs.clusterLabel | default (include "mimir.clusterName" $) }}"
{{- end }}
namespaceSelector:
matchNames:
- {{ $.Release.Namespace | quote }}
selector:
matchLabels:
# Scrape logs from all components
{{- include "mimir.selectorLabels" (dict "ctx" $) | nindent 6 }}
{{- end -}}
{{- end -}}
@@ -0,0 +1,21 @@
{{- with .Values.metaMonitoring.prometheusRule }}
{{- if .enabled }}
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
name: {{ include "mimir.resourceName" (dict "ctx" $ "component" "prometheus-rule") }}
{{- with .annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "mimir.labels" (dict "ctx" $) | nindent 4 }}
{{- with .labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
namespace: {{ .namespace | default $.Release.Namespace | quote }}
spec:
groups:
{{- toYaml .groups | nindent 4 }}
{{- end }}
{{- end }}
@@ -0,0 +1,20 @@
{{- with .Values.metaMonitoring.prometheusRule }}
{{- if .mimirRules }}
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
name: {{ include "mimir.resourceName" (dict "ctx" $ "component" "rules") }}
{{- with .annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "mimir.labels" (dict "ctx" $) | nindent 4 }}
{{- with .labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
namespace: {{ .namespace | default $.Release.Namespace | quote }}
spec:
{{- $.Files.Get "mixins/rules.yaml" | nindent 2 }}
{{- end }}
{{- end }}