diff --git a/docs/sources/clients/promtail/installation.md b/docs/sources/clients/promtail/installation.md index 596dc43c5b..a12d62ddb9 100644 --- a/docs/sources/clients/promtail/installation.md +++ b/docs/sources/clients/promtail/installation.md @@ -47,10 +47,10 @@ $ helm upgrade --install promtail grafana/promtail --set "loki.serviceName=loki" A `DaemonSet` will deploy Promtail on every node within a Kubernetes cluster. The DaemonSet deployment works well at collecting the logs of all containers within a -cluster. It's the best solution for a single-tenant model. +cluster. It's the best solution for a single-tenant model. Replace `{YOUR_LOKI_ENDPOINT}` with your Loki endpoint. ```yaml ----Daemonset.yaml +--- # Daemonset.yaml apiVersion: apps/v1 kind: DaemonSet metadata: @@ -64,15 +64,7 @@ spec: labels: name: promtail spec: - serviceAccount: SERVICE_ACCOUNT - serviceAccountName: SERVICE_ACCOUNT - volumes: - - name: logs - hostPath: - path: HOST_PATH - - name: promtail-config - configMap: - name: promtail-config + serviceAccount: promtail-serviceaccount containers: - name: promtail-container image: grafana/promtail @@ -85,19 +77,79 @@ spec: fieldPath: 'spec.nodeName' volumeMounts: - name: logs - mountPath: MOUNT_PATH + mountPath: /var/log - name: promtail-config mountPath: /etc/promtail - ----configmap.yaml + - mountPath: /var/lib/docker/containers + name: varlibdockercontainers + readOnly: true + volumes: + - name: logs + hostPath: + path: /var/log + - name: varlibdockercontainers + hostPath: + path: /var/lib/docker/containers + - name: promtail-config + configMap: + name: promtail-config +--- # configmap.yaml apiVersion: v1 kind: ConfigMap metadata: name: promtail-config data: - promtail.yaml: YOUR CONFIG - ----Clusterrole.yaml + promtail.yaml: | + server: + http_listen_port: 9080 + grpc_listen_port: 0 + + clients: + - url: https://{YOUR_LOKI_ENDPOINT}/loki/api/v1/push + + positions: + filename: /tmp/positions.yaml + target_config: + sync_period: 10s + scrape_configs: + - job_name: pod-logs + kubernetes_sd_configs: + - role: pod + pipeline_stages: + - docker: {} + relabel_configs: + - source_labels: + - __meta_kubernetes_pod_node_name + target_label: __host__ + - action: labelmap + regex: __meta_kubernetes_pod_label_(.+) + - action: replace + replacement: $1 + separator: / + source_labels: + - __meta_kubernetes_namespace + - __meta_kubernetes_pod_name + target_label: job + - action: replace + source_labels: + - __meta_kubernetes_namespace + target_label: namespace + - action: replace + source_labels: + - __meta_kubernetes_pod_name + target_label: pod + - action: replace + source_labels: + - __meta_kubernetes_pod_container_name + target_label: container + - replacement: /var/log/pods/*$1/*.log + separator: / + source_labels: + - __meta_kubernetes_pod_uid + - __meta_kubernetes_pod_container_name + target_label: __path__ + +--- # Clusterrole.yaml apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: @@ -113,13 +165,13 @@ rules: - watch - list ----ServiceAccount.yaml +--- # ServiceAccount.yaml apiVersion: v1 kind: ServiceAccount metadata: name: promtail-serviceaccount ----Rolebinding.yaml +--- # Rolebinding.yaml apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: @@ -133,45 +185,3 @@ roleRef: name: promtail-clusterrole apiGroup: rbac.authorization.k8s.io ``` - -### Sidecar - -The Sidecar method deploys Promtail as a sidecar container for a specific pod. -In a multi-tenant environment, this enables teams to aggregate logs for specific -pods and deployments. - -```yaml ----Deployment.yaml -apiVersion: apps/v1 -kind: Deployment -metadata: - name: promtail-deployment -spec: - selector: - matchLabels: - name: promtail - template: - metadata: - labels: - name: promtail - spec: - serviceAccount: SERVICE_ACCOUNT - serviceAccountName: SERVICE_ACCOUNT - volumes: - - name: logs - hostPath: - path: HOST_PATH - - name: promtail-config - configMap: - name: promtail-config - containers: - - name: promtail-container - image: grafana/promtail - args: - - -config.file=/etc/promtail/promtail.yaml - volumeMounts: - - name: logs - mountPath: MOUNT_PATH - - name: promtail-config - mountPath: /etc/promtail -``` diff --git a/docs/sources/installation/simple-scalable-helm.md b/docs/sources/installation/simple-scalable-helm.md index 948d693833..7fe3f1f629 100644 --- a/docs/sources/installation/simple-scalable-helm.md +++ b/docs/sources/installation/simple-scalable-helm.md @@ -42,12 +42,20 @@ within a Kubernetes cluster. helm upgrade --install loki --namespace=loki grafana/loki-simple-scalable ``` - - Deploy with added custom configuration: + - Deploy with added custom configuration using an overrides YAML file, useful for overriding a set of values: + + ```bash + helm upgrade --install loki grafana/loki-simple-scalable --values {PATH_TO_OVERRIDES_VALUES_FILE} + ``` + + - Deploy with added custom configuration, useful for overriding a small quantity of values: ```bash helm upgrade --install loki grafana/loki-simple-scalable --set "key1=val1,key2=val2,..." ``` +Find deployment examples at [https://github.com/grafana/helm-charts/tree/main/charts/loki-simple-scalable/docs/examples](https://github.com/grafana/helm-charts/tree/main/charts/loki-simple-scalable/docs/examples). + ## Deploy Grafana to your Kubernetes cluster Install Grafana on your Kubernetes cluster with Helm: @@ -112,6 +120,10 @@ spec: - {{ .Values.ingress.host }} ``` +## Run Promtail within Kubernetes as a Daemonset + +In order to run Promtail within Kubernetes to gather logs from each node, start with the [Promtail installation](../../clients/promtail/installation/#daemonset-recommended) documentation example. + ## Run Promtail with syslog support In order to receive and process syslog messages in Promtail, the following changes will be necessary: