# grafana_charts_logs-instance.yaml
{{- with (.Values.metaMonitoring).grafanaAgent }}
{{- if .enabled }}
apiVersion: monitoring.grafana.com/v1alpha1
kind: LogsInstance
metadata:
  name: {{ include "tempo.resourceName" (dict "ctx" $ "component" "meta-monitoring") }}
  namespace: {{ (($.Values.metaMonitoring).grafanaAgent).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:
  clients:
    {{- if or (.logs).additionalClientConfigs (.logs).remote }}
    {{- range $i, $cfg := prepend ((.logs).additionalClientConfigs | default list) (.logs).remote }}
    {{- with $cfg }}
    {{- if $cfg.url }}
    - {{- include "tempo.metaMonitoring.logs.client" (dict "ctx" $ "url" .url "auth" .auth "usernameKey" (printf "username-%d" $i)) | nindent 6 -}}
    {{- end }}
    {{- 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 "tempo.selectorLabels" (dict "ctx" $) | nindent 6 }}

{{- end -}}
{{- end -}}