1

我按照这些说明在 docker 本地运行 loki、pomtrail、grafana

当我尝试运行以下测试将数据直接发送到 loki 时:

curl -i -H "Content-type: application/json" -X POST --data '{ "streams": [ { "labels": { "job": "randomjob" }, "entries": [{ "ts": "2021-10-12T16:13:06.801064Z", "line": "TEST!" }] } ] }' http://localhost:3100/loki/api/v1/push

我得到错误:

HTTP/1.1 400 Bad Request
Content-Type: text/plain; charset=utf-8
X-Content-Type-Options: nosniff
Date: Tue, 02 Nov 2021 12:09:26 GMT
Content-Length: 53

error at least one label pair is required per stream

为什么找不到标签?谢谢。

4

1 回答 1

0

标签对的格式应该是(对于旧端点/api/prom/push)并且它有效:

"labels": "{job=\"randomjob\"}"

例如:

curl -H "Content-Type: application/json" -XPOST -s "172.30.11.21:3100/api/prom/push" --data-raw   '{"streams": [
  { 
      "labels": "{job=\"randomjob\"}", 
      "entries": [
          { 
              "ts": "2021-11-13T19:55:51.801064-00:00", 
              "line": "TEST!" 
          }
      ] 
  }
]

}'

对于新端点/loki/api/v1/push,似乎需要将labels字段更改为stream

curl -H "Content-Type: application/json" -XPOST -s "172.30.11.21:3100/loki/api/v1/push" --data-raw '{"streams": [{ "stream": {"job": "randomjob"}, "values": [["1636841990000000000",  "TEST!" ]] }] }]}'
于 2021-11-13T20:39:36.460 回答