From bfaf74a897606af921d56f098fb43e38ca012099 Mon Sep 17 00:00:00 2001 From: Joe Elliott Date: Mon, 23 Sep 2019 15:24:12 -0400 Subject: [PATCH 01/13] Added /loki/api/v1/push as a push handler to mirror the new v1 api Signed-off-by: Joe Elliott --- pkg/loki/modules.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pkg/loki/modules.go b/pkg/loki/modules.go index 1cab54c160d23..8b059fccee35d 100644 --- a/pkg/loki/modules.go +++ b/pkg/loki/modules.go @@ -126,10 +126,14 @@ func (t *Loki) initDistributor() (err error) { return } - t.server.HTTP.Path("/ready").Handler(http.HandlerFunc(t.distributor.ReadinessHandler)) - t.server.HTTP.Handle("/api/prom/push", middleware.Merge( + pushHandler := middleware.Merge( t.httpAuthMiddleware, - ).Wrap(http.HandlerFunc(t.distributor.PushHandler))) + ).Wrap(http.HandlerFunc(t.distributor.PushHandler)) + + t.server.HTTP.Path("/ready").Handler(http.HandlerFunc(t.distributor.ReadinessHandler)) + + t.server.HTTP.Handle("/api/prom/push", pushHandler) + t.server.HTTP.Handle("/loki/api/v1/push", pushHandler) return } From a0abb373e647e03ecce5762f56547400f8c669b0 Mon Sep 17 00:00:00 2001 From: Joe Elliott Date: Mon, 23 Sep 2019 15:38:40 -0400 Subject: [PATCH 02/13] Updated sample promtail configs to use the new path Signed-off-by: Joe Elliott --- cmd/promtail/promtail-local-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/promtail/promtail-local-config.yaml b/cmd/promtail/promtail-local-config.yaml index 9744741c57381..3b9256537ec80 100644 --- a/cmd/promtail/promtail-local-config.yaml +++ b/cmd/promtail/promtail-local-config.yaml @@ -6,7 +6,7 @@ positions: filename: /tmp/positions.yaml clients: - - url: http://localhost:3100/api/prom/push + - url: http://localhost:3100/loki/api/v1/push scrape_configs: - job_name: system From 82618fe3660cb4aba572ed448ab9900debfc43d3 Mon Sep 17 00:00:00 2001 From: Joe Elliott Date: Mon, 23 Sep 2019 15:45:50 -0400 Subject: [PATCH 03/13] Updated promtail docker config Signed-off-by: Joe Elliott --- cmd/promtail/promtail-docker-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/promtail/promtail-docker-config.yaml b/cmd/promtail/promtail-docker-config.yaml index 9dca263256802..ed06e8cdce107 100644 --- a/cmd/promtail/promtail-docker-config.yaml +++ b/cmd/promtail/promtail-docker-config.yaml @@ -6,7 +6,7 @@ positions: filename: /tmp/positions.yaml clients: - - url: http://loki:3100/api/prom/push + - url: http://loki:3100/loki/api/v1/push scrape_configs: - job_name: system From c79206fb0497da77135315ac45f8f629ff6111f7 Mon Sep 17 00:00:00 2001 From: Joe Elliott Date: Tue, 24 Sep 2019 08:39:09 -0400 Subject: [PATCH 04/13] Updated promtail test to use new path Signed-off-by: Joe Elliott --- pkg/promtail/promtail_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/promtail/promtail_test.go b/pkg/promtail/promtail_test.go index 4fec436862f22..6667e1bcda457 100644 --- a/pkg/promtail/promtail_test.go +++ b/pkg/promtail/promtail_test.go @@ -69,7 +69,7 @@ func TestPromtail(t *testing.T) { recMtx: sync.Mutex{}, t: t, } - http.Handle("/api/prom/push", handler) + http.Handle("/loki/api/v1/push", handler) defer func() { if err != nil { t.Fatal(err) @@ -526,7 +526,7 @@ func parsePromMetrics(t *testing.T, bytes []byte, contentType string, metricName func buildTestConfig(t *testing.T, positionsFileName string, logDirName string) config.Config { var clientURL flagext.URLValue - err := clientURL.Set("http://localhost:3100/api/prom/push") + err := clientURL.Set("http://localhost:3100/loki/api/v1/push") if err != nil { t.Fatal("Failed to parse client URL") } From 0947d22a28f44ebf01f950584073fe2e24c84f47 Mon Sep 17 00:00:00 2001 From: Joe Elliott Date: Tue, 24 Sep 2019 12:39:23 -0400 Subject: [PATCH 05/13] Updated and tested loki paths in docker driver Signed-off-by: Joe Elliott --- cmd/docker-driver/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/docker-driver/README.md b/cmd/docker-driver/README.md index 5cfb94c2c5273..1a1d54429d91e 100644 --- a/cmd/docker-driver/README.md +++ b/cmd/docker-driver/README.md @@ -41,7 +41,7 @@ The following command configure the container `grafana` to start with the loki d ```bash docker run --log-driver=loki \ - --log-opt loki-url="https://:@logs-us-west1.grafana.net/api/prom/push" \ + --log-opt loki-url="https://:@logs-us-west1.grafana.net/loki/api/v1/push" \ --log-opt loki-retries=5 \ --log-opt loki-batch-size=400 \ grafana/grafana @@ -68,7 +68,7 @@ The logging driver has configurable options, you can set them in the `daemon.jso "debug" : true, "log-driver": "loki", "log-opts": { - "loki-url": "https://:@logs-us-west1.grafana.net/api/prom/push", + "loki-url": "https://:@logs-us-west1.grafana.net/loki/api/v1/push", "loki-batch-size": "400" } } @@ -90,7 +90,7 @@ services: logging: driver: loki options: - loki-url: "https://:@logs-us-west1.grafana.net/api/prom/push" + loki-url: "https://:@logs-us-west1.grafana.net/loki/api/v1/push" ``` You can then deploy your stack using: From c40646ef08c639acbf3f7bbce4aee171a196a8d5 Mon Sep 17 00:00:00 2001 From: Joe Elliott Date: Tue, 24 Sep 2019 12:43:30 -0400 Subject: [PATCH 06/13] Updated fluentd plugin Signed-off-by: Joe Elliott --- fluentd/fluent-plugin-grafana-loki/README.md | 2 +- .../fluent-plugin-grafana-loki/lib/fluent/plugin/out_loki.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fluentd/fluent-plugin-grafana-loki/README.md b/fluentd/fluent-plugin-grafana-loki/README.md index 5c2902872cf58..140d14bf654cd 100644 --- a/fluentd/fluent-plugin-grafana-loki/README.md +++ b/fluentd/fluent-plugin-grafana-loki/README.md @@ -92,7 +92,7 @@ services: ## Configuration ### url -The url of the Loki server to send logs to. When sending data the publish path (`/api/prom/push`) will automatically be appended. +The url of the Loki server to send logs to. When sending data the publish path (`/loki/api/v1/push`) will automatically be appended. By default the url is set to `https://logs-us-west1.grafana.net`, the url of the Grafana Labs preview (hosted Loki)[https://grafana.com/loki] service. #### Proxy Support diff --git a/fluentd/fluent-plugin-grafana-loki/lib/fluent/plugin/out_loki.rb b/fluentd/fluent-plugin-grafana-loki/lib/fluent/plugin/out_loki.rb index c02426684a6c1..661d34648f9fb 100644 --- a/fluentd/fluent-plugin-grafana-loki/lib/fluent/plugin/out_loki.rb +++ b/fluentd/fluent-plugin-grafana-loki/lib/fluent/plugin/out_loki.rb @@ -87,7 +87,7 @@ def write(chunk) body = { 'streams': payload } # add ingest path to loki url - uri = URI.parse(url + '/api/prom/push') + uri = URI.parse(url + '/loki/api/v1/push') req = Net::HTTP::Post.new( uri.request_uri From 64971f34d7832ea4c61ea679dea17ff3e423dcd6 Mon Sep 17 00:00:00 2001 From: Joe Elliott Date: Tue, 24 Sep 2019 12:47:49 -0400 Subject: [PATCH 07/13] Updated docs and examples Signed-off-by: Joe Elliott --- .../helm/loki-stack/templates/tests/loki-test-configmap.yaml | 2 +- production/helm/promtail/templates/daemonset.yaml | 4 ++-- tools/promtail.sh | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/production/helm/loki-stack/templates/tests/loki-test-configmap.yaml b/production/helm/loki-stack/templates/tests/loki-test-configmap.yaml index 205fd774c7952..30f95f96a0aa0 100644 --- a/production/helm/loki-stack/templates/tests/loki-test-configmap.yaml +++ b/production/helm/loki-stack/templates/tests/loki-test-configmap.yaml @@ -34,7 +34,7 @@ data: local timestamp=$(date -Iseconds -u | sed 's/UTC/.000000000+00:00/') local data=$(jq -n --arg timestamp "${timestamp}" '{"streams": [{"labels": "{app=\"loki-test\"}", "entries": [{"ts": $timestamp, "line": "foobar"}]}]}') - curl -s -X POST -H "Content-Type: application/json" ${LOKI_URI}/api/prom/push -d "${data}" + curl -s -X POST -H "Content-Type: application/json" ${LOKI_URI}/loki/api/v1/push -d "${data}" curl -sG ${LOKI_URI}/api/prom/query?limit=1 --data-urlencode 'query={app="loki-test"}' | \ jq -e '.streams[].entries[].line == "foobar"' diff --git a/production/helm/promtail/templates/daemonset.yaml b/production/helm/promtail/templates/daemonset.yaml index 1fee17590e2be..90ad7418c97f9 100644 --- a/production/helm/promtail/templates/daemonset.yaml +++ b/production/helm/promtail/templates/daemonset.yaml @@ -45,9 +45,9 @@ spec: args: - "-config.file=/etc/promtail/promtail.yaml" {{- if and .Values.loki.user .Values.loki.password }} - - "-client.url={{ .Values.loki.serviceScheme }}://{{ .Values.loki.user }}:{{ .Values.loki.password }}@{{ include "loki.serviceName" . }}:{{ .Values.loki.servicePort }}/api/prom/push" + - "-client.url={{ .Values.loki.serviceScheme }}://{{ .Values.loki.user }}:{{ .Values.loki.password }}@{{ include "loki.serviceName" . }}:{{ .Values.loki.servicePort }}/loki/api/v1/push" {{- else }} - - "-client.url={{ .Values.loki.serviceScheme }}://{{ include "loki.serviceName" . }}:{{ .Values.loki.servicePort }}/api/prom/push" + - "-client.url={{ .Values.loki.serviceScheme }}://{{ include "loki.serviceName" . }}:{{ .Values.loki.servicePort }}/loki/api/v1/push" {{- end }} volumeMounts: - name: config diff --git a/tools/promtail.sh b/tools/promtail.sh index 14ae661e8e5bb..1532a0585f9a2 100755 --- a/tools/promtail.sh +++ b/tools/promtail.sh @@ -284,7 +284,7 @@ spec: spec: containers: - args: - - -client.url=https://:@/api/prom/push + - -client.url=https://:@/loki/api/v1/push - -config.file=/etc/promtail/promtail.yml env: - name: HOSTNAME From 64605e1f196422b14e802dec0cb24a9a88dacf53 Mon Sep 17 00:00:00 2001 From: Joe Elliott Date: Tue, 24 Sep 2019 12:52:19 -0400 Subject: [PATCH 08/13] Updated gateway to pass new v1 paths Signed-off-by: Joe Elliott --- production/ksonnet/loki/gateway.libsonnet | 8 ++++++++ production/ksonnet/promtail/promtail.libsonnet | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/production/ksonnet/loki/gateway.libsonnet b/production/ksonnet/loki/gateway.libsonnet index e05e141e92da7..ce8f5960ddad1 100644 --- a/production/ksonnet/loki/gateway.libsonnet +++ b/production/ksonnet/loki/gateway.libsonnet @@ -52,6 +52,14 @@ location ~ /api/prom/.* { proxy_pass http://querier.%(namespace)s.svc.cluster.local$request_uri; } + + location = /loki/api/v1/push { + proxy_pass http://distributor.%(namespace)s.svc.cluster.local$request_uri; + } + + location ~ /loki/api/.* { + proxy_pass http://querier.%(namespace)s.svc.cluster.local$request_uri; + } } } ||| % $._config, diff --git a/production/ksonnet/promtail/promtail.libsonnet b/production/ksonnet/promtail/promtail.libsonnet index 5fb2101295f13..9cb0d06312009 100644 --- a/production/ksonnet/promtail/promtail.libsonnet +++ b/production/ksonnet/promtail/promtail.libsonnet @@ -19,9 +19,9 @@ k + config + scrape_config { promtail_config+:: { local service_url(client) = if std.objectHasAll(client, 'username') then - '%(scheme)s://%(username)s:%(password)s@%(hostname)s/api/prom/push' % client + '%(scheme)s://%(username)s:%(password)s@%(hostname)s/loki/api/v1/push' % client else - '%(scheme)s://%(hostname)s/api/prom/push' % client, + '%(scheme)s://%(hostname)s/loki/api/v1/push' % client, local client_config(client) = client + { url: service_url(client), From 25dd26b9b7e34d5244fc23694c6b816784484e2d Mon Sep 17 00:00:00 2001 From: Joe Elliott Date: Tue, 24 Sep 2019 12:59:03 -0400 Subject: [PATCH 09/13] Updated helm chart semver Signed-off-by: Joe Elliott --- production/helm/promtail/Chart.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/production/helm/promtail/Chart.yaml b/production/helm/promtail/Chart.yaml index cf538596245ee..12fd854ffdf79 100644 --- a/production/helm/promtail/Chart.yaml +++ b/production/helm/promtail/Chart.yaml @@ -1,5 +1,5 @@ name: promtail -version: 0.12.2 +version: 0.12.3 appVersion: v0.3.0 kubeVersion: "^1.10.0-0" description: "Responsible for gathering logs and sending them to Loki" From c2e48e859025b0c60a51690eb2bd036a87a7a31b Mon Sep 17 00:00:00 2001 From: Joe Elliott Date: Tue, 24 Sep 2019 14:14:39 -0400 Subject: [PATCH 10/13] Revert "Updated helm chart semver" This reverts commit 25dd26b9b7e34d5244fc23694c6b816784484e2d. --- production/helm/promtail/Chart.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/production/helm/promtail/Chart.yaml b/production/helm/promtail/Chart.yaml index 12fd854ffdf79..cf538596245ee 100644 --- a/production/helm/promtail/Chart.yaml +++ b/production/helm/promtail/Chart.yaml @@ -1,5 +1,5 @@ name: promtail -version: 0.12.3 +version: 0.12.2 appVersion: v0.3.0 kubeVersion: "^1.10.0-0" description: "Responsible for gathering logs and sending them to Loki" From 903ccb6826869aa7564ef078783ccd437b28c8b9 Mon Sep 17 00:00:00 2001 From: Joe Elliott Date: Tue, 24 Sep 2019 14:16:42 -0400 Subject: [PATCH 11/13] Reverted helm chart changes Signed-off-by: Joe Elliott --- production/helm/promtail/templates/daemonset.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/production/helm/promtail/templates/daemonset.yaml b/production/helm/promtail/templates/daemonset.yaml index 90ad7418c97f9..1fee17590e2be 100644 --- a/production/helm/promtail/templates/daemonset.yaml +++ b/production/helm/promtail/templates/daemonset.yaml @@ -45,9 +45,9 @@ spec: args: - "-config.file=/etc/promtail/promtail.yaml" {{- if and .Values.loki.user .Values.loki.password }} - - "-client.url={{ .Values.loki.serviceScheme }}://{{ .Values.loki.user }}:{{ .Values.loki.password }}@{{ include "loki.serviceName" . }}:{{ .Values.loki.servicePort }}/loki/api/v1/push" + - "-client.url={{ .Values.loki.serviceScheme }}://{{ .Values.loki.user }}:{{ .Values.loki.password }}@{{ include "loki.serviceName" . }}:{{ .Values.loki.servicePort }}/api/prom/push" {{- else }} - - "-client.url={{ .Values.loki.serviceScheme }}://{{ include "loki.serviceName" . }}:{{ .Values.loki.servicePort }}/loki/api/v1/push" + - "-client.url={{ .Values.loki.serviceScheme }}://{{ include "loki.serviceName" . }}:{{ .Values.loki.servicePort }}/api/prom/push" {{- end }} volumeMounts: - name: config From 04f6904aaab98a506ab72481b04e15dd7ec346cc Mon Sep 17 00:00:00 2001 From: Joe Elliott Date: Tue, 24 Sep 2019 14:20:27 -0400 Subject: [PATCH 12/13] Updated gem version Signed-off-by: Joe Elliott --- .../fluent-plugin-grafana-loki.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fluentd/fluent-plugin-grafana-loki/fluent-plugin-grafana-loki.gemspec b/fluentd/fluent-plugin-grafana-loki/fluent-plugin-grafana-loki.gemspec index 296387fdc3991..b3b7a1caef82a 100644 --- a/fluentd/fluent-plugin-grafana-loki/fluent-plugin-grafana-loki.gemspec +++ b/fluentd/fluent-plugin-grafana-loki/fluent-plugin-grafana-loki.gemspec @@ -4,7 +4,7 @@ $LOAD_PATH.push File.expand_path('lib', __dir__) Gem::Specification.new do |spec| spec.name = 'fluent-plugin-grafana-loki' - spec.version = '1.0.2' + spec.version = '1.1.0' spec.authors = %w[woodsaj briangann] spec.email = ['awoods@grafana.com', 'brian@grafana.com'] From d411ea06660270519948f3c1e37b85035e39902c Mon Sep 17 00:00:00 2001 From: Joe Elliott Date: Tue, 24 Sep 2019 14:50:03 -0400 Subject: [PATCH 13/13] Fixed failing test Signed-off-by: Joe Elliott --- .../helm/loki-stack/templates/tests/loki-test-configmap.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/production/helm/loki-stack/templates/tests/loki-test-configmap.yaml b/production/helm/loki-stack/templates/tests/loki-test-configmap.yaml index 30f95f96a0aa0..205fd774c7952 100644 --- a/production/helm/loki-stack/templates/tests/loki-test-configmap.yaml +++ b/production/helm/loki-stack/templates/tests/loki-test-configmap.yaml @@ -34,7 +34,7 @@ data: local timestamp=$(date -Iseconds -u | sed 's/UTC/.000000000+00:00/') local data=$(jq -n --arg timestamp "${timestamp}" '{"streams": [{"labels": "{app=\"loki-test\"}", "entries": [{"ts": $timestamp, "line": "foobar"}]}]}') - curl -s -X POST -H "Content-Type: application/json" ${LOKI_URI}/loki/api/v1/push -d "${data}" + curl -s -X POST -H "Content-Type: application/json" ${LOKI_URI}/api/prom/push -d "${data}" curl -sG ${LOKI_URI}/api/prom/query?limit=1 --data-urlencode 'query={app="loki-test"}' | \ jq -e '.streams[].entries[].line == "foobar"'