How to Send Python and PHP App Logs Directly to Loki via HTTP API
A hands-on guide demonstrates how to push application logs from Python and PHP mini-apps to Grafana Loki using its HTTP API endpoint POST /loki/api/v1/push. Unlike Prometheus, which pulls metrics, Loki receives logs actively from applications in a JSON payload containing stream labels and timestamped log lines. Loki deliberately indexes only a small set of low-cardinality labels rather than full log content, keeping storage costs low compared to tools like Elasticsearch. Log text is stored as compressed chunks and scanned at query time, making label-based filtering fast but free-text searches slower at high volumes. The article also warns that high-cardinality labels, such as unique user IDs per request, undermine Loki's efficiency in the same way they do in Prometheus.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in