Search code examples
docker-composegrafana-loki

Cannot access loki API from the browser


I have grafana-loki running in a docker-compose set up. I am trying to push logs to loki calling its API, but the funny thing is that if I try to query loki from my browser (http://loki:3100/loki/) I get a "site non reachable" or 404 not found error.

I have tried loki, 127.0.0.1, localhost, my current Ip address, and also /loki/api, loki/v1 and any combination that I can imagine.

This is my docker compose section for loki:

loki:

    container_name:  olala-telemetry-loki
    image: grafana/loki:main-125e168
    command: [ "-config.file=/etc/loki/local-config.yaml" ]
    volumes:
      - ./otel-config/loki.yml:/etc/loki/local-config.yaml
    ports:
      - 3100:3100

Also, from the container views in my VS loki shows in a beautiful green status as up and running. And from the console I can see entries like this one:

olala-telemetry-loki            | level=info ts=2023-07-23T19:00:12.881124937Z caller=table_manager.go:136 index-store=boltdb-shipper-2020-10-24 msg="uploading tables"
olala-telemetry-loki            | level=info ts=2023-07-23T19:00:12.881339039Z caller=table_manager.go:227 index-store=boltdb-shipper-2020-10-24 msg="syncing tables"
olala-telemetry-loki            | ts=2023-07-23T19:00:12.881378688Z caller=spanlogger.go:85 level=info msg="building index list cache"
olala-telemetry-loki            | ts=2023-07-23T19:00:12.881396643Z caller=spanlogger.go:85 level=info msg="index list cache built" duration=10.888µs

So the loki backend seems to be happily up and running, but I cannot query it via API using tools like curl, or the browser.

Any idea of how to access it by curl using the command line or with postman? What I am doing wrong?

Edit: I finally got and answer from the console using curl:

curl -v -H "Content-Type: application/json" -X POST -s "http://localhost:3100/loki/api/v1/push" --data-raw "{\"streams\": [{ \"stream\": { \"foo\": \"bar2\" }, \"values\": [ [ \"1687280319000000000\", \"fizzbuzz\" ] ] }]}"

But no luck with the browser, it maybe that loki does not expose a swagger sort of interface? One where I can see the list of endpoints, and test from the browser?


Solution

  • Loki does not provide a HTML page or API endpoint on / or /loki/, therefore the 404 Not Found response. The HTTP API endpoints are documented here.