README.md.gotmpl 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. {{ template "chart.header" . }}
  2. {{ template "chart.versionBadge" . }}{{ template "chart.typeBadge" . }}{{ template "chart.appVersionBadge" . }}
  3. {{ template "chart.description" . }}
  4. {{ template "chart.sourcesSection" . }}
  5. {{ template "chart.requirementsSection" . }}
  6. ## Chart Repo
  7. Add the following repo to use the chart:
  8. ```console
  9. helm repo add grafana https://grafana.github.io/helm-charts
  10. ```
  11. ## Upgrading
  12. A major chart version change indicates that there is an incompatible breaking change needing manual actions.
  13. ### From Chart Versions >= 3.0.0
  14. * Customizeable initContainer added.
  15. ### From Chart Versions < 3.0.0
  16. #### Notable Changes
  17. * Helm 3 is required
  18. * Labels have been updated to follow the official Kubernetes [label recommendations](https://kubernetes.io/docs/concepts/overview/working-with-objects/common-labels/)
  19. * The default scrape configs have been updated to take new and old labels into consideration
  20. * The config file must be specified as string which can be templated.
  21. See below for details
  22. * The config file is now stored in a Secret and no longer in a ConfigMap because it may contain sensitive data, such as basic auth credentials
  23. Due to the label changes, an existing installation cannot be upgraded without manual interaction.
  24. There are basically two options:
  25. ##### Option 1
  26. Uninstall the old release and re-install the new one.
  27. There will be no data loss.
  28. Promtail will cleanly shut down and write the `positions.yaml`.
  29. The new release which will pick up again from the existing `positions.yaml`.
  30. ##### Option 2
  31. * Add new selector labels to the existing pods:
  32. ```
  33. kubectl label pods -n <namespace> -l app=promtail,release=<release> app.kubernetes.io/name=promtail app.kubernetes.io/instance=<release>
  34. ```
  35. * Perform a non-cascading deletion of the DaemonSet which will keep the pods running:
  36. ```
  37. kubectl delete daemonset -n <namespace> -l app=promtail,release=<release> --cascade=false
  38. ```
  39. * Perform a regular Helm upgrade on the existing release.
  40. The new DaemonSet will pick up the existing pods and perform a rolling upgrade.
  41. {{ template "chart.valuesSection" . }}
  42. ## Configuration
  43. The config file for Promtail must be configured as string.
  44. This is necessary because the contents are passed through the `tpl` function.
  45. With this, the file can be templated and assembled from reusable YAML snippets.
  46. It is common to have multiple `kubernetes_sd_configs` that, in turn, usually need the same `pipeline_stages`.
  47. Thus, extracting reusable snippets helps reduce redundancy and avoid copy/paste errors.
  48. See `values.yaml´ for details.
  49. Also, the following examples make use of this feature.
  50. For additional reference, please refer to Promtail's docs:
  51. https://grafana.com/docs/loki/latest/clients/promtail/configuration/
  52. ### Syslog Support
  53. ```yaml
  54. extraPorts:
  55. syslog:
  56. name: tcp-syslog
  57. containerPort: 1514
  58. service:
  59. port: 80
  60. type: LoadBalancer
  61. externalTrafficPolicy: Local
  62. loadBalancerIP: 123.234.123.234
  63. config:
  64. snippets:
  65. extraScrapeConfigs: |
  66. # Add an additional scrape config for syslog
  67. - job_name: syslog
  68. syslog:
  69. listen_address: 0.0.0.0:{{"{{"}} .Values.extraPorts.syslog.containerPort {{"}}"}}
  70. labels:
  71. job: syslog
  72. relabel_configs:
  73. - source_labels:
  74. - __syslog_message_hostname
  75. target_label: hostname
  76. # example label values: kernel, CRON, kubelet
  77. - source_labels:
  78. - __syslog_message_app_name
  79. target_label: app
  80. # example label values: debug, notice, informational, warning, error
  81. - source_labels:
  82. - __syslog_message_severity
  83. target_label: level
  84. ```
  85. Find additional source labels in the Promtail's docs:
  86. https://grafana.com/docs/loki/latest/clients/promtail/configuration/#syslog
  87. ### Journald Support
  88. ```yaml
  89. config:
  90. snippets:
  91. extraScrapeConfigs: |
  92. # Add an additional scrape config for syslog
  93. - job_name: journal
  94. journal:
  95. path: /var/log/journal
  96. max_age: 12h
  97. labels:
  98. job: systemd-journal
  99. relabel_configs:
  100. - source_labels:
  101. - __journal__hostname
  102. target_label: hostname
  103. # example label values: kubelet.service, containerd.service
  104. - source_labels:
  105. - __journal__systemd_unit
  106. target_label: unit
  107. # example label values: debug, notice, info, warning, error
  108. - source_labels:
  109. - __journal_priority_keyword
  110. target_label: level
  111. # Mount journal directory and machine-id file into promtail pods
  112. extraVolumes:
  113. - name: journal
  114. hostPath:
  115. path: /var/log/journal
  116. - name: machine-id
  117. hostPath:
  118. path: /etc/machine-id
  119. extraVolumeMounts:
  120. - name: journal
  121. mountPath: /var/log/journal
  122. readOnly: true
  123. - name: machine-id
  124. mountPath: /etc/machine-id
  125. readOnly: true
  126. ```
  127. Find additional configuration options in Promtail's docs:
  128. https://grafana.com/docs/loki/latest/clients/promtail/configuration/#journal
  129. More journal source labels can be found here https://www.freedesktop.org/software/systemd/man/systemd.journal-fields.html.
  130. > Note that each message from the journal may have a different set of fields and software may write an arbitrary set of custom fields for their logged messages. [(related issue)](https://github.com/grafana/loki/issues/2048#issuecomment-626234611)
  131. The machine-id needs to be available in the container as it is required for scraping.
  132. This is described in Promtail's scraping docs:
  133. https://grafana.com/docs/loki/latest/clients/promtail/scraping/#journal-scraping-linux-only
  134. ### Push API Support
  135. ```yaml
  136. extraPorts:
  137. httpPush:
  138. name: http-push
  139. containerPort: 3500
  140. grpcPush:
  141. name: grpc-push
  142. containerPort: 3600
  143. config:
  144. file: |
  145. server:
  146. log_level: {{"{{"}} .Values.config.logLevel {{"}}"}}
  147. http_listen_port: {{"{{"}} .Values.config.serverPort {{"}}"}}
  148. clients:
  149. - url: {{"{{"}} .Values.config.lokiAddress {{"}}"}}
  150. positions:
  151. filename: /run/promtail/positions.yaml
  152. scrape_configs:
  153. {{"{{"}}- tpl .Values.config.snippets.scrapeConfigs . | nindent 2 {{"}}"}}
  154. - job_name: push1
  155. loki_push_api:
  156. server:
  157. http_listen_port: {{"{{"}} .Values.extraPorts.httpPush.containerPort {{"}}"}}
  158. grpc_listen_port: {{"{{"}} .Values.extraPorts.grpcPush.containerPort {{"}}"}}
  159. labels:
  160. pushserver: push1
  161. ```
  162. ### Customize client config options
  163. By default, promtail send logs scraped to `loki` server at `http://loki-gateway/loki/api/v1/push`.
  164. If you want to customize clients or add additional options to `loki`, please use the `clients` section. For example, to enable HTTP basic auth and include OrgID header, you can use:
  165. ```yaml
  166. config:
  167. clients:
  168. - url: http://loki.server/loki/api/v1/push
  169. tenant_id: 1
  170. basic_auth:
  171. username: loki
  172. password: secret
  173. ```