Grafana Loki Query Best Practices with LogQL (Loki Community Call December 2024)

Grafana Loki Query Best Practices with LogQL (Loki Community Call December 2024)

Dec 6, 2024

In this December's Loki Community Call, Cyril Tovena, Senior Principal Engineer and LogQL guru walks us through a Grafana Loki query tutorial with LogQL, the Log Query Language used for Loki. He talks about the key "Dos and Don'ts" of LogQL, offering practical tips to help you write better queries, boost performance, and sidestep common mistakes.

Whether you’re tuning up your current setup or just diving into LogQL, Cyril’s got you covered. Bring your questions, connect with the Loki community, and pick up insights that’ll make your log-querying life easier. See you there!

Make sure you leave your questions here: https://forms.gle/nm7TGX2EeWnRLmbs6

Cyril is joined by Senior Developer Advocates Jay Clifford and Nicole van der Hoeven.

Community Calls are monthly meetings that are open to everyone interested in the development of Loki. They are an opportunity for software engineers working on Loki to discuss new features as well as for open-source users of Loki to ask questions. To participate in the next Community Call, subscribe to the calendar here: https://gra.fan/lokicccal

HELPFUL LINKS:
Loki Community Call Agenda: https://gra.fan/lokicc
Loki GitHub repo: https://gra.fan/lokirepo
Loki docs: https://gra.fan/lokidocs
(docs) LogQL - Log Query Language: https://gra.fan/lokiquery
(docs) Query best practices: https://gra.fan/lokiquerybp
(demo) Grafana Play: https://gra.fan/play
(docs) LogQL simulator: https://gra.fan/lokisimulator
(video) Loki Community Call: All About Explore Logs: https://gra.fan/lccexplorelogs
(docs) Label best practices: https://gra.fan/lokilabelbp

TIMESTAMPS:
00:00:00 Introductions
00:01:47 History of LogQL and schema at query
00:07:17 What are metrics queries?
00:12:20 Demo of LogQL on Grafana Play
00:19:06 Q - Can you prevent users from running inefficient queries?
00:20:33 Q - Can you query multiple tenants of Loki?
00:21:48 Filter operators
00:26:30 Pattern filter
00:29:03 What is a good query?
00:31:27 Q - Is chunks per query a good metric to track for cost?
00:34:11 Top mistakes in LogQL
00:39:49 Q - How do you query structured metadata in Loki?
00:42:05 Q - Any plans to support nested queries?
00:43:15 Ways to assess the performance of queries
00:48:23 Q - Can you remove detected_level and service_name? Do they increase cardinality?
00:50:08 Q - What changes can we expect for OTLP in Loki?
00:51:55 Factors that affect Loki performance
00:54:13 Q - How does the results cache work?
00:59:12 Q - Simple scalable or distributed?
01:00:00 Q - What do we do when a regex query times out?
01:00:51 Q - How can I get my most expensive queries and see if they're efficient?
01:02:40 Q - How do I scale Loki?
01:04:23 Q - How can you test and benchmark Loki queries?

☁️ Grafana Cloud is the easiest way to get started with Grafana dashboards, metrics, logs, and traces. Our forever-free tier includes access to 10k metrics, 50GB logs, 50GB traces and more. We also have plans for every use case. Sign up: https://grafana.com/get/

❓ Have a question that isn't related to this video? Check out the Official Grafana Community Forums and ask your question or find your answer: https://community.grafana.com/

👍 If you found this video useful, be sure to give it a thumbs up and subscribe to our channel for more helpful Grafana videos.

📱 Follow us for the latest and greatest on all things Grafana and our other OSS projects.

X: https://twitter.com/grafana
LinkedIn: https://www.linkedin.com/company/grafana-labs/mycompany
Facebook: https://www.facebook.com/grafana

#Grafana #Observability #loki