Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update loki push path #1049

Merged
merged 13 commits into from
Sep 25, 2019
6 changes: 3 additions & 3 deletions cmd/docker-driver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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://<user_id>:<password>@logs-us-west1.grafana.net/api/prom/push" \
--log-opt loki-url="https://<user_id>:<password>@logs-us-west1.grafana.net/loki/api/v1/push" \
--log-opt loki-retries=5 \
--log-opt loki-batch-size=400 \
grafana/grafana
Expand All @@ -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://<user_id>:<password>@logs-us-west1.grafana.net/api/prom/push",
"loki-url": "https://<user_id>:<password>@logs-us-west1.grafana.net/loki/api/v1/push",
"loki-batch-size": "400"
}
}
Expand All @@ -90,7 +90,7 @@ services:
logging:
driver: loki
options:
loki-url: "https://<user_id>:<password>@logs-us-west1.grafana.net/api/prom/push"
loki-url: "https://<user_id>:<password>@logs-us-west1.grafana.net/loki/api/v1/push"
```

You can then deploy your stack using:
Expand Down
2 changes: 1 addition & 1 deletion cmd/promtail/promtail-docker-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion cmd/promtail/promtail-local-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion fluentd/fluent-plugin-grafana-loki/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 7 additions & 3 deletions pkg/loki/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/promtail/promtail_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"'
Expand Down
2 changes: 1 addition & 1 deletion production/helm/promtail/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: promtail
version: 0.12.2
version: 0.12.3
joe-elliott marked this conversation as resolved.
Show resolved Hide resolved
appVersion: v0.3.0
kubeVersion: "^1.10.0-0"
description: "Responsible for gathering logs and sending them to Loki"
Expand Down
4 changes: 2 additions & 2 deletions production/helm/promtail/templates/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions production/ksonnet/loki/gateway.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions production/ksonnet/promtail/promtail.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion tools/promtail.sh
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ spec:
spec:
containers:
- args:
- -client.url=https://<instanceId>:<apiKey>@<instanceUrl>/api/prom/push
- -client.url=https://<instanceId>:<apiKey>@<instanceUrl>/loki/api/v1/push
- -config.file=/etc/promtail/promtail.yml
env:
- name: HOSTNAME
Expand Down