From 199071324d9bc3bb2b3118a854af2e3782afbad2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90=E1=BA=B7ng=20Minh=20D=C5=A9ng?= Date: Mon, 30 May 2022 10:19:52 +0700 Subject: [PATCH] [promtail] support multiple clients via `clients` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Đặng Minh Dũng --- charts/promtail/Chart.yaml | 2 +- charts/promtail/README.md | 18 ++++++++---------- charts/promtail/README.md.gotmpl | 13 ++++++------- charts/promtail/values.yaml | 18 ++++++------------ 4 files changed, 21 insertions(+), 30 deletions(-) diff --git a/charts/promtail/Chart.yaml b/charts/promtail/Chart.yaml index 31a803477e..99f3cb1ba8 100644 --- a/charts/promtail/Chart.yaml +++ b/charts/promtail/Chart.yaml @@ -3,7 +3,7 @@ name: promtail description: Promtail is an agent which ships the contents of local logs to a Loki instance type: application appVersion: 2.5.0 -version: 4.2.1 +version: 5.0.0 home: https://grafana.com/loki sources: - https://github.com/grafana/loki diff --git a/charts/promtail/README.md b/charts/promtail/README.md index b5b869185b..649346901b 100644 --- a/charts/promtail/README.md +++ b/charts/promtail/README.md @@ -1,6 +1,6 @@ # promtail -![Version: 4.2.1](https://img.shields.io/badge/Version-4.2.1-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 2.5.0](https://img.shields.io/badge/AppVersion-2.5.0-informational?style=flat-square) +![Version: 5.0.0](https://img.shields.io/badge/Version-5.0.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 2.5.0](https://img.shields.io/badge/AppVersion-2.5.0-informational?style=flat-square) Promtail is an agent which ships the contents of local logs to a Loki instance @@ -67,12 +67,11 @@ The new release which will pick up again from the existing `positions.yaml`. | affinity | object | `{}` | Affinity configuration for pods | | annotations | object | `{}` | Annotations for the DaemonSet | | config | object | See `values.yaml` | Section for crafting Promtails config file. The only directly relevant value is `config.file` which is a templated string that references the other values and snippets below this key. | +| config.clients | list | See `values.yaml` | The config of clients of the Promtail server Must be reference in `config.file` to configure `clients` | | config.file | string | See `values.yaml` | Config file contents for Promtail. Must be configured as string. It is templated so it can be assembled from reusable snippets in order to avoid redundancy. | | config.logLevel | string | `"info"` | The log level of the Promtail server Must be reference in `config.file` to configure `server.log_level` See default config in `values.yaml` | -| config.lokiAddress | string | `"http://loki-gateway/loki/api/v1/push"` | The Loki address to post logs to. Must be reference in `config.file` to configure `client.url`. See default config in `values.yaml` | | config.serverPort | int | `3101` | The port of the Promtail server Must be reference in `config.file` to configure `server.http_listen_port` See default config in `values.yaml` | | config.snippets | object | See `values.yaml` | A section of reusable snippets that can be reference in `config.file`. Custom snippets may be added in order to reduce redundancy. This is especially helpful when multiple `kubernetes_sd_configs` are use which usually have large parts in common. | -| config.snippets.extraClientConfigs | list | empty | You can put here any keys that will be directly added to the config file's 'client' block. | | config.snippets.extraRelabelConfigs | list | `[]` | You can put here any additional relabel_configs to "kubernetes-pods" job | | config.snippets.extraScrapeConfigs | string | empty | You can put here any additional scrape configs you want to add to the config file. | | containerSecurityContext | object | `{"allowPrivilegeEscalation":false,"capabilities":{"drop":["ALL"]},"readOnlyRootFilesystem":true}` | The security context for containers | @@ -241,18 +240,17 @@ config: pushserver: push1 ``` -### Extra client config options +### Customize client config options -If you want to add additional options to the `client` section of promtail's config, please use -the `extraClientConfigs` section. For example, to enable HTTP basic auth and include OrgID -header, you can use: +By default, promtail send logs scraped to `loki` server at `http://loki-gateway/loki/api/v1/push`. +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: ```yaml config: - snippets: - extraClientConfigs: | + clients: + - url: http://loki.server/loki/api/v1/push + tenant_id: 1 basic_auth: username: loki password: secret - tenant_id: 1 ``` diff --git a/charts/promtail/README.md.gotmpl b/charts/promtail/README.md.gotmpl index 068ba93ab1..f25d30fb18 100644 --- a/charts/promtail/README.md.gotmpl +++ b/charts/promtail/README.md.gotmpl @@ -170,18 +170,17 @@ config: pushserver: push1 ``` -### Extra client config options +### Customize client config options -If you want to add additional options to the `client` section of promtail's config, please use -the `extraClientConfigs` section. For example, to enable HTTP basic auth and include OrgID -header, you can use: +By default, promtail send logs scraped to `loki` server at `http://loki-gateway/loki/api/v1/push`. +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: ```yaml config: - snippets: - extraClientConfigs: | + clients: + - url: http://loki.server/loki/api/v1/push + tenant_id: 1 basic_auth: username: loki password: secret - tenant_id: 1 ``` diff --git a/charts/promtail/values.yaml b/charts/promtail/values.yaml index a03f795881..5e39aa7f27 100644 --- a/charts/promtail/values.yaml +++ b/charts/promtail/values.yaml @@ -238,10 +238,11 @@ config: # Must be reference in `config.file` to configure `server.http_listen_port` # See default config in `values.yaml` serverPort: 3101 - # -- The Loki address to post logs to. - # Must be reference in `config.file` to configure `client.url`. - # See default config in `values.yaml` - lokiAddress: http://loki-gateway/loki/api/v1/push + # -- The config of clients of the Promtail server + # Must be reference in `config.file` to configure `clients` + # @default -- See `values.yaml` + clients: + - url: http://loki-gateway/loki/api/v1/push # -- A section of reusable snippets that can be reference in `config.file`. # Custom snippets may be added in order to reduce redundancy. # This is especially helpful when multiple `kubernetes_sd_configs` are use which usually have large parts in common. @@ -294,10 +295,6 @@ config: # This helps debug the Promtail config. addScrapeJobLabel: false - # -- You can put here any keys that will be directly added to the config file's 'client' block. - # @default -- empty - extraClientConfigs: [] - # -- You can put here any additional scrape configs you want to add to the config file. # @default -- empty extraScrapeConfigs: "" @@ -351,10 +348,7 @@ config: http_listen_port: {{ .Values.config.serverPort }} clients: - - url: {{ tpl .Values.config.lokiAddress . }} - {{- with .Values.config.snippets.extraClientConfigs }} - {{- toYaml . | nindent 2 }} - {{- end }} + {{- toYaml .Values.config.clients | nindent 2 }} positions: filename: /run/promtail/positions.yaml