Hands-On: Using Centralised Logging
Grafana Labs started working on the project Loki somewhere around mid-2019. It describes itself as “like Prometheus, but for Logs.” Indexing a massive amount of data is very compute intensive and tends to create issues when running at scale. By using labels instead of indexing logs, Loki made itself compute-efficient. But that’s not the only benefit.
Having the same set of labels on application logs and metrics helps immensely in correlating those two during investigations. On top of that, logs are queried with the same PromQL as metrics stored in Prometheus. To be more precise, Loki uses LogQL, which is a subset of PromQL. Given that querying metrics tend to need reacher query language, the decision to use a subset makes sense.
Further on, the UI for exploring logs is based on Grafana, which happens to be the de-facto standard in the observability world. The Explore screen allows us to query and correlate both logs from Loki and metrics from Prometheus in the same view.