Skip to content

Commit

Permalink
Turn off clustering for log gathering alloy. Move PodLogs control to …
Browse files Browse the repository at this point in the history
…the primary alloy, which does use clustering. (#474)

Also add some instructions for setting the storage path for logs instance

Signed-off-by: Pete Wall <pete.wall@grafana.com>
  • Loading branch information
petewall committed Apr 18, 2024
1 parent 08a4ba7 commit 7ec6d61
Show file tree
Hide file tree
Showing 27 changed files with 129 additions and 618 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
data-alloy
39 changes: 39 additions & 0 deletions charts/k8s-monitoring/templates/_config_validations.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,54 @@
{{- if and .Values.logs.enabled .Values.logs.pod_logs.enabled }}
{{- if eq .Values.logs.pod_logs.gatherMethod "volumes" }}
{{- if ne (index .Values "alloy-logs").controller.type "daemonset" }}
{{/*
Invalid configuration for gathering pod logs! When using logs.pod_logs.gatherMethod: "volumes", Grafana Alloy for Logs must be a Daemonset. Otherwise, logs will be missing!
Please set:
logs:
pod_logs:
gatherMethod: api
or
alloy-logs:
controller:
type: daemonset
*/}}
{{ fail "Invalid configuration for gathering pod logs! When using logs.pod_logs.gatherMethod: \"volumes\", Grafana Alloy for Logs must be a Daemonset. Otherwise, logs will be missing!\nPlease set:\nlogs:\n pod_logs:\n gatherMethod: api\n or\nalloy-logs:\n controller:\n type: daemonset"}}
{{- end }}
{{- if (index .Values "alloy-logs").alloy.clustering.enabled }}
{{/*
Invalid configuration for gathering pod logs! When using logs.pod_logs.gatherMethod: "volumes", Grafana Alloy for Logs should not utilize clustering. Otherwise, performance will suffer!
Please set:
alloy-logs:
alloy:
clustering:
enabled: false
*/}}
{{ fail "Invalid configuration for gathering pod logs! When using logs.pod_logs.gatherMethod: \"volumes\", Grafana Alloy for Logs should not utilize clustering. Otherwise, performance will suffer!\nPlease set:\nalloy-logs:\n alloy:\n clustering:\n enabled: false"}}
{{- end }}

{{- else if eq .Values.logs.pod_logs.gatherMethod "api" }}
{{- if not (index .Values "alloy-logs").alloy.clustering.enabled }}
{{- if eq (index .Values "alloy-logs").controller.type "daemonset" }}
{{/*
Invalid configuration for gathering pod logs! When using logs.pod_logs.gatherMethod: "api" and the Grafana Alloy for Logs is a Daemonset, you must enable clustering. Otherwise, log files may be duplicated!
Please set:
alloy-logs:
alloy:
clustering:
enabled: true
*/}}
{{ fail "Invalid configuration for gathering pod logs! When using logs.pod_logs.gatherMethod: \"api\" and the Grafana Alloy for Logs is a Daemonset, you must enable clustering. Otherwise, log files may be duplicated!\nPlease set:\nalloy-logs:\n alloy:\n clustering:\n enabled: true"}}
{{- end }}

{{- if gt (int (index .Values "alloy-logs").controller.replicas) 1 }}
{{/*
Invalid configuration for gathering pod logs! When using logs.pod_logs.gatherMethod: "api" and the Grafana Alloy for Logs has multiple replicas, you must enable clustering. Otherwise, log files will be duplicated!
Please set:
alloy-logs:
alloy:
clustering:
enabled: true
*/}}
{{ fail "Invalid configuration for gathering pod logs! When using logs.pod_logs.gatherMethod: \"api\" and the Grafana Alloy for Logs has multiple replicas, you must enable clustering. Otherwise, log files will be duplicated!\nPlease set:\nalloy-logs:\n alloy:\n clustering:\n enabled: true"}}
{{- end }}

Expand Down
12 changes: 6 additions & 6 deletions charts/k8s-monitoring/templates/_configs.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@
{{- include "alloy.config.metricsService" . }}
{{- end }}

{{- if and .Values.logs.enabled (or .Values.receivers.grpc.enabled .Values.receivers.http.enabled .Values.receivers.zipkin.enabled) }}
{{- if and .Values.logs.enabled (or .Values.logs.podLogsObjects.enabled .Values.receivers.grpc.enabled .Values.receivers.http.enabled) }}
{{- if .Values.logs.podLogsObjects.enabled }}
{{- include "alloy.config.pod_log_objects" . }}
{{- end }}

{{- include "alloy.config.logs.pod_logs_processor" . }}
{{- include "alloy.config.logsService" . }}
{{- end }}
Expand All @@ -100,14 +104,10 @@
{{- include "alloy.config.logsService" . }}
{{- end -}}

{{/* Grafana Allyo for Logs config */}}
{{/* Grafana Alloy for Logs config */}}
{{- define "alloyLogsConfig" -}}
{{- include "alloy.config.logs.pod_logs_discovery" . }}
{{- include "alloy.config.logs.pod_logs_processor" . }}
{{- if .Values.logs.podLogsObjects.enabled }}
{{- include "alloy.config.pod_log_objects" . }}
{{- end }}

{{- include "alloy.config.logsService" . }}

{{- if .Values.logs.extraConfig }}
Expand Down
4 changes: 2 additions & 2 deletions charts/k8s-monitoring/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1272,8 +1272,8 @@ alloy-logs:
# This chart is creating the configuration, so the alloy chart does not need to.
configMap: {create: false}

# Enable clustering by default to make it simpler when using API-based log gathering.
clustering: {enabled: true}
# Disabling clustering by default, because the default log gathering format does not require clusters.
clustering: {enabled: false}

mounts:
# Mount /var/log from the host into the container for log collection.
Expand Down
20 changes: 20 additions & 0 deletions examples/alloy-autoscaling-and-storage/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,24 @@ alloy:
resources:
requests:
storage: 5Gi

alloy-logs:
alloy:
storagePath: /var/lib/alloy
mounts:
extra:
- mountPath: /var/lib/alloy
name: alloy-log-positions

controller:
enableStatefulSetAutoDeletePVC: true
volumeClaimTemplates:
- metadata:
name: alloy-log-positions
spec:
accessModes: ["ReadWriteOnce"]
storageClassName: "standard"
resources:
requests:
storage: 100Mi
```
37 changes: 4 additions & 33 deletions examples/alloy-autoscaling-and-storage/output.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 21 additions & 1 deletion examples/alloy-autoscaling-and-storage/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,24 @@ alloy:
storageClassName: "standard"
resources:
requests:
storage: 5Gi
storage: 5Gi

alloy-logs:
alloy:
storagePath: /var/lib/alloy
mounts:
extra:
- mountPath: /var/lib/alloy
name: alloy-log-positions

controller:
enableStatefulSetAutoDeletePVC: true
volumeClaimTemplates:
- metadata:
name: alloy-log-positions
spec:
accessModes: ["ReadWriteOnce"]
storageClassName: "standard"
resources:
requests:
storage: 100Mi
32 changes: 0 additions & 32 deletions examples/control-plane-metrics/output.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 0 additions & 32 deletions examples/custom-config/output.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 0 additions & 32 deletions examples/custom-pricing/output.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 0 additions & 32 deletions examples/default-values/output.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 7ec6d61

Please sign in to comment.