What do `|=`, `|~`, `!=`, `!~` cost in LogQL compared with label filters after a parser?
AdvancedConceptLogging: ELK/EFK, Loki & Log Shippers
Answer
Line filters run directly on raw log bytes and are the cheapest operation after stream selection; |= (substring) is faster than |~ (regex). Label filters after | json require parsing every line first, which is much more CPU.
So we write:
{app="api"} |= "checkout" | json | status >= 500
instead of {app="api"} | json | path="/checkout" | status >= 500. The pre-filter discards most lines before the expensive parser. Loki 3.x bloom filters can also accelerate |= searches on structured metadata.
More on Logging: ELK/EFK, Loki & Log Shippers
What is the ELK stack, and what is EFK?BeginnerHow does Elasticsearch store and search logs?IntermediateWhat is ILM (Index Lifecycle Management) and why do log clusters need it?IntermediateWhat is an Elasticsearch data stream?AdvancedWhat is an index template and mapping, and what is a mapping explosion?AdvancedWhat does Logstash do compared with Beats?Intermediate