|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// * configuring/loki-query-performance-troubleshooting.adoc |
| 4 | + |
| 5 | +:_newdoc-version: 2.18.4 |
| 6 | +:_template-generated: 2025-10-24 |
| 7 | +:_mod-docs-content-type: PROCEDURE |
| 8 | + |
| 9 | +[id="analyzing-loki-query-performance_{context}"] |
| 10 | += Analyzing Loki query performance |
| 11 | + |
| 12 | +Every query and subquery in Loki generates a `metrics.go` log line with performance statistics. Subqueries emit the log line in the queriers. |
| 13 | +Every query has an associated single summary `metrics.go` line emitted by the query-front end. |
| 14 | +Use these statistics to calculate the query performance metrics. |
| 15 | + |
| 16 | +.Prerequisites |
| 17 | +* You have administrator permissions. |
| 18 | +* You have access to the {ocp-product-title} web console. |
| 19 | +* You installed and configured {loki-op}. |
| 20 | + |
| 21 | +.Procedure |
| 22 | +. In the {ocp-product-title} web console, navigate to the *Metrics* -> *Observe* tab. |
| 23 | + |
| 24 | +. Note the following values: |
| 25 | + |
| 26 | +* *duration*: Denotes the amount of time a query took to run. |
| 27 | +* *queue_time*: Denotes the time a query spent in the queue before being processed. |
| 28 | +* *chunk_refs_fetch_time*: Denotes the amount of time spent in getting chunk information from the index. |
| 29 | +* *store_chunks_download_time*: Denotes the amount of time in getting chunks from cache or storage. |
| 30 | + |
| 31 | +. Calculate the following performance metrics: |
| 32 | + |
| 33 | +** total query time as `total_duration`: |
| 34 | ++ |
| 35 | +[subs=+quotes] |
| 36 | +---- |
| 37 | +total_duration = *duration* + *queue_time* |
| 38 | +---- |
| 39 | + |
| 40 | +** Percentage of the total duration that a query spent in the queue as `Queue Time`: |
| 41 | ++ |
| 42 | +[subs=+quotes] |
| 43 | +---- |
| 44 | +Queue Time = *queue_time* / total_duration * 100 |
| 45 | +---- |
| 46 | + |
| 47 | +** Calculate the percentage of the total duration that was spent in getting chunk information from the index as `Chunk Refs Fetch Time`: |
| 48 | ++ |
| 49 | +[subs=+quotes] |
| 50 | +---- |
| 51 | +Chunk Refs Fetch Time = *chunk_refs_fetch_time* / total_duration * 100 |
| 52 | +---- |
| 53 | + |
| 54 | +** Calculate the percentage of the total duration that was spent in getting chunks from cache or storage: |
| 55 | ++ |
| 56 | +[subs=+quotes] |
| 57 | +---- |
| 58 | +Chunks Download Time = *store_chunks_download_time* / total_duration * 100 |
| 59 | +---- |
| 60 | + |
| 61 | +** Calculate the percentage of the total duration that was spent in executing the query: |
| 62 | ++ |
| 63 | +[subs=+quotes] |
| 64 | +---- |
| 65 | +Execution Time = (*duration* - *chunk_refs_fetch_time* - *store_chunks_download_time*) / total_duration * 100 |
| 66 | +---- |
| 67 | + |
| 68 | +. Refer to https://docs.redhat.com/en/documentation/red_hat_openshift_logging/latest/html/about_openshift_logging/index/analyze-query-performance_loki-query-performance-troubleshooting[Query performance analysis] to understand the reason for each metric and how each metric affects query performance. |
0 commit comments