devops-kb icon indicating copy to clipboard operation
devops-kb copied to clipboard

Logs not getting ingested in Loki.

Open sourav-py opened this issue 11 months ago • 3 comments

Hi, I was trying the following library to send logs to loki using python.

push-to-loki

I am getting the 204 response as expected, but I am not seeing any logs in grafana when using that Loki instance as the data source.

Am I missing anything? I mean is there anything else that I have to do too apart from setting up lgrafana, loki, loki data source and running this script?

Thanks, and best regards, Sourav.

sourav-py avatar Mar 05 '24 16:03 sourav-py

Hi! Please try again, today I approved pr with fix in path. Or provide more details "step by step" for reproduce this issue if its actual

sleleko avatar Mar 17 '24 17:03 sleleko

The new endpoint uses a new format of payload, See https://grafana.com/docs/loki/latest/reference/loki-http-api/#ingest-logs

{
  "streams": [
    {
      "stream": {
        "label": "value"
      },
      "values": [
          [ "<unix epoch in nanoseconds>", "<log line>" ],
          [ "<unix epoch in nanoseconds>", "<log line>" ]
      ]
    }
  ]
}

But the code still uses the old format. https://github.com/sleleko/devops-kb/blob/bddda7ef12185db94907f078384c26777a4b7df8/python/push-to-loki.py#L17-L29

xieyuguang avatar Aug 01 '24 07:08 xieyuguang

The new endpoint uses a new format of payload, See https://grafana.com/docs/loki/latest/reference/loki-http-api/#ingest-logs

{
  "streams": [
    {
      "stream": {
        "label": "value"
      },
      "values": [
          [ "<unix epoch in nanoseconds>", "<log line>" ],
          [ "<unix epoch in nanoseconds>", "<log line>" ]
      ]
    }
  ]
}

But the code still uses the old format.

https://github.com/sleleko/devops-kb/blob/bddda7ef12185db94907f078384c26777a4b7df8/python/push-to-loki.py#L17-L29

Hi! Thank you! I will update my example soon.

sleleko avatar Aug 06 '24 09:08 sleleko