# grafana_charts_grafana-agent.yaml
{{- with (.Values.metaMonitoring).grafanaAgent }}
{{- if .enabled }}
apiVersion: monitoring.grafana.com/v1alpha1
kind: GrafanaAgent
metadata:
  name: {{ include "tempo.resourceName" (dict "ctx" $ "component" "meta-monitoring") }}
  namespace: {{ .namespace | default $.Release.Namespace | quote }}
  labels:
    {{- include "tempo.labels" (dict "ctx" $ "component" "meta-monitoring" ) | nindent 4 }}
    {{- with .labels }}
    {{- toYaml . | nindent 4 }}
    {{- end }}
  {{- with .annotations }}
  annotations:
    {{- toYaml . | nindent 4 }}
  {{- end }}
spec:
  serviceAccountName: {{ include "tempo.resourceName" (dict "ctx" $ "component" "grafana-agent") }}
  logs:
    instanceSelector:
      matchLabels:
        {{- include "tempo.selectorLabels" (dict "ctx" $ "component" "meta-monitoring") | nindent 8 }}
    # cluster label for logs is added in the LogsInstance
  metrics:
    instanceSelector:
      matchLabels:
        {{- include "tempo.selectorLabels" (dict "ctx" $ "component" "meta-monitoring") | nindent 8 }}
    externalLabels:
      cluster: {{ include "tempo.clusterName" $ }}
{{- end }}
{{- end }}