Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 1 | *********************************************************************** |
| 2 | Welcome to Grafana Loki |
| 3 | Chart version: {{ .Chart.Version }} |
Mohammed Naser | 7d1623e | 2024-06-17 09:12:39 -0400 | [diff] [blame] | 4 | Chart Name: {{ .Chart.Name }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 5 | Loki version: {{ .Chart.AppVersion }} |
| 6 | *********************************************************************** |
| 7 | |
Mohammed Naser | 7d1623e | 2024-06-17 09:12:39 -0400 | [diff] [blame] | 8 | ** Please be patient while the chart is being deployed ** |
| 9 | |
| 10 | Tip: |
| 11 | |
| 12 | Watch the deployment status using the command: kubectl get pods -w --namespace {{ $.Release.Namespace }} |
| 13 | |
| 14 | If pods are taking too long to schedule make sure pod affinity can be fulfilled in the current cluster. |
| 15 | |
| 16 | *********************************************************************** |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 17 | Installed components: |
Mohammed Naser | 7d1623e | 2024-06-17 09:12:39 -0400 | [diff] [blame] | 18 | *********************************************************************** |
| 19 | |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 20 | {{- if .Values.monitoring.selfMonitoring.enabled }} |
| 21 | * grafana-agent-operator |
| 22 | {{- end }} |
| 23 | {{- if eq (include "loki.deployment.isSingleBinary" .) "true" }} |
Mohammed Naser | 7d1623e | 2024-06-17 09:12:39 -0400 | [diff] [blame] | 24 | * loki |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 25 | {{- else -}} |
| 26 | {{- if .Values.gateway.enabled }} |
| 27 | * gateway |
| 28 | {{- end }} |
| 29 | {{- if .Values.minio.enabled }} |
Mohammed Naser | 7d1623e | 2024-06-17 09:12:39 -0400 | [diff] [blame] | 30 | * minio |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 31 | {{- end }} |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 32 | {{- if eq (include "loki.deployment.isScalable" .) "true" }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 33 | * read |
| 34 | * write |
| 35 | {{- if not .Values.read.legacyReadTarget }} |
| 36 | * backend |
| 37 | {{- end }} |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 38 | {{- else }} |
| 39 | * compactor |
| 40 | * index gateway |
| 41 | * query scheduler |
| 42 | * ruler |
| 43 | * distributor |
| 44 | * ingester |
| 45 | * querier |
| 46 | * query frontend |
| 47 | {{- end }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 48 | {{- end }} |
Mohammed Naser | 7d1623e | 2024-06-17 09:12:39 -0400 | [diff] [blame] | 49 | |
| 50 | |
| 51 | {{- if eq (include "loki.deployment.isSingleBinary" .) "true" }} |
| 52 | |
| 53 | Loki has been deployed as a single binary. |
| 54 | This means a single pod is handling reads and writes. You can scale that pod vertically by adding more CPU and memory resources. |
| 55 | |
| 56 | {{- end }} |
| 57 | |
| 58 | |
| 59 | *********************************************************************** |
| 60 | Sending logs to Loki |
| 61 | *********************************************************************** |
| 62 | |
| 63 | {{- if .Values.gateway.enabled }} |
| 64 | |
| 65 | Loki has been configured with a gateway (nginx) to support reads and writes from a single component. |
| 66 | |
| 67 | {{- end }} |
| 68 | |
| 69 | You can send logs from inside the cluster using the cluster DNS: |
| 70 | |
| 71 | {{- if .Values.gateway.enabled }} |
| 72 | |
| 73 | http://{{ include "loki.gatewayFullname" . }}.{{ $.Release.Namespace }}.svc.cluster.local/loki/api/v1/push |
| 74 | |
| 75 | {{- else }} |
| 76 | {{- if eq (include "loki.deployment.isSingleBinary" .) "true" }} |
| 77 | |
| 78 | http://{{ include "loki.singleBinaryFullname" . }}.{{ $.Release.Namespace }}.svc.cluster.local:{{ .Values.loki.server.http_listen_port }}/loki/api/v1/push |
| 79 | |
| 80 | {{- end}} |
| 81 | {{- if eq (include "loki.deployment.isScalable" .) "true" }} |
| 82 | |
| 83 | http://{{ include "loki.writeFullname" . }}.{{ $.Release.Namespace }}.svc.cluster.local:{{ .Values.loki.server.http_listen_port }}/loki/api/v1/push |
| 84 | |
| 85 | {{- end }} |
| 86 | {{- if eq (include "loki.deployment.isDistributed" .) "true" }} |
| 87 | |
| 88 | http://{{ include "loki.distributorFullname" . }}.{{ $.Release.Namespace }}.svc.cluster.local:3100/loki/api/v1/push |
| 89 | |
| 90 | {{- end }} |
| 91 | {{- end }} |
| 92 | |
| 93 | You can test to send data from outside the cluster by port-forwarding the gateway to your local machine: |
| 94 | {{- if .Values.gateway.enabled }} |
| 95 | |
| 96 | kubectl port-forward --namespace {{ $.Release.Namespace }} svc/{{ include "loki.gatewayFullname" . }} 3100:{{ .Values.gateway.service.port }} & |
| 97 | |
| 98 | {{- else }} |
| 99 | {{- if eq (include "loki.deployment.isSingleBinary" .) "true" }} |
| 100 | |
| 101 | kubectl port-forward --namespace {{ $.Release.Namespace }} svc/{{ include "loki.singleBinaryFullname" . }} 3100:{{ .Values.loki.server.http_listen_port }} & |
| 102 | |
| 103 | {{- end}} |
| 104 | {{- if eq (include "loki.deployment.isScalable" .) "true" }} |
| 105 | |
| 106 | kubectl port-forward --namespace {{ $.Release.Namespace }} svc/{{ include "loki.writeFullname" . }} 3100:{{ .Values.loki.server.http_listen_port }} & |
| 107 | |
| 108 | {{- end }} |
| 109 | {{- if eq (include "loki.deployment.isDistributed" .) "true" }} |
| 110 | |
| 111 | kubectl port-forward --namespace {{ $.Release.Namespace }} svc/{{ include "loki.distributorFullname" . }} 3100:3100 & |
| 112 | |
| 113 | {{- end }} |
| 114 | {{- end }} |
| 115 | |
| 116 | And then using http://127.0.0.1:3100/loki/api/v1/push URL as shown below: |
| 117 | |
| 118 | ``` |
| 119 | curl -H "Content-Type: application/json" -XPOST -s "http://127.0.0.1:3100/loki/api/v1/push" \ |
| 120 | --data-raw "{\"streams\": [{\"stream\": {\"job\": \"test\"}, \"values\": [[\"$(date +%s)000000000\", \"fizzbuzz\"]]}]}" |
| 121 | {{- if .Values.loki.auth_enabled }} \ |
| 122 | -H X-Scope-OrgId:foo |
| 123 | {{- end}} |
| 124 | ``` |
| 125 | |
| 126 | Then verify that Loki did received the data using the following command: |
| 127 | |
| 128 | ``` |
| 129 | curl "http://127.0.0.1:3100/loki/api/v1/query_range" --data-urlencode 'query={job="test"}' {{- if .Values.loki.auth_enabled }} -H X-Scope-OrgId:foo {{- end}} | jq .data.result |
| 130 | ``` |
| 131 | |
| 132 | *********************************************************************** |
| 133 | Connecting Grafana to Loki |
| 134 | *********************************************************************** |
| 135 | |
| 136 | If Grafana operates within the cluster, you'll set up a new Loki datasource by utilizing the following URL: |
| 137 | |
| 138 | {{- if .Values.gateway.enabled }} |
| 139 | |
| 140 | http://{{ include "loki.gatewayFullname" . }}.{{ $.Release.Namespace }}.svc.cluster.local/ |
| 141 | |
| 142 | {{- else }} |
| 143 | {{- if eq (include "loki.deployment.isSingleBinary" .) "true" }} |
| 144 | |
| 145 | http://{{ include "loki.singleBinaryFullname" . }}.{{ $.Release.Namespace }}.svc.cluster.local:{{ .Values.loki.server.http_listen_port }}/ |
| 146 | |
| 147 | {{- end}} |
| 148 | {{- if eq (include "loki.deployment.isScalable" .) "true" }} |
| 149 | |
| 150 | http://{{ include "loki.readFullname" . }}.{{ $.Release.Namespace }}.svc.cluster.local:{{ .Values.loki.server.http_listen_port }}/ |
| 151 | |
| 152 | {{- end }} |
| 153 | {{- if eq (include "loki.deployment.isDistributed" .) "true" }} |
| 154 | |
| 155 | http://{{ include "loki.queryFrontendFullname" . }}.{{ $.Release.Namespace }}.svc.cluster.local:3100/ |
| 156 | |
| 157 | {{- end }} |
| 158 | {{- end }} |
| 159 | |
| 160 | |
| 161 | |
| 162 | {{- if .Values.loki.auth_enabled }} |
| 163 | |
| 164 | *********************************************************************** |
| 165 | Multi-tenancy |
| 166 | *********************************************************************** |
| 167 | |
| 168 | Loki is configured with auth enabled (multi-tenancy) and expects tenant headers (`X-Scope-OrgID`) to be set for all API calls. |
| 169 | |
| 170 | You must configure Grafana's Loki datasource using the `HTTP Headers` section with the `X-Scope-OrgID` to target a specific tenant. |
| 171 | For each tenant, you can create a different datasource. |
| 172 | |
| 173 | The agent of your choice must also be configured to propagate this header. |
| 174 | For example, when using Promtail you can use the `tenant` stage. https://grafana.com/docs/loki/latest/send-data/promtail/stages/tenant/ |
| 175 | |
| 176 | When not provided with the `X-Scope-OrgID` while auth is enabled, Loki will reject reads and writes with a 404 status code `no org id`. |
| 177 | |
| 178 | You can also use a reverse proxy, to automatically add the `X-Scope-OrgID` header as suggested by https://grafana.com/docs/loki/latest/operations/authentication/ |
| 179 | |
| 180 | For more information, read our documentation about multi-tenancy: https://grafana.com/docs/loki/latest/operations/multi-tenancy/ |
| 181 | |
| 182 | > When using curl you can pass `X-Scope-OrgId` header using `-H X-Scope-OrgId:foo` option, where foo can be replaced with the tenant of your choice. |
| 183 | |
| 184 | {{- end }} |