How to Analyze Query Metrics Using HAR Files
When working with applications, it can be useful to analyze the performance of queries and requests. One way to do this is by examining HAR (HTTP Archive) files, which capture network traffic and can provide insights into query metrics. Here’s a step-by-step guide on how to check query metrics in a HAR file.
Steps to Analyze Query Metrics in a HAR File
Step 1: Generate a HAR File
- Open your web browser (e.g., Chrome, Firefox).
- Access the Developer Tools by right-clicking on the page and selecting “Inspect”.
- Navigate to the “Network” tab.
- Perform the actions on the application that you want to analyze.
- Once the actions are completed, right-click in the Network tab and export the HAR file.
Please refer to the documentation on How to Download a HAR File from Your Browser
Step 2: Open the HAR File
- Use a HAR viewer tool or a text editor to open the HAR file. There are several online HAR viewers available that can help visualize the data.
Step 3: Analyze the Query Metrics
1) Locate Relevant Entries:
- Look for the entries that correspond to the queries you are interested in.
- Query metrics will appear under the designerAction property referred to as FetchWidgetData method.
- The widget name can be found in the widgetDetails property.
2) Navigate to Metrics:
- Click on the PostDesignerAction method.
- Navigate to the preview tab -> any widget -> DashboardMetrics -> QueryMetrics.
3) Review Metrics:
- In the QueryMetrics, you will get Query, RowsRetrieved, QueryStatus, QueryStartTime, QueryEndTime, QueryPreparationTime.
- Query: The actual query executed.
- Rows Retrieved: The number of rows returned by the query or total row count in the grid widget.
- Query Status: The status of the query execution.
- Query Start Time: The timestamp when the query execution started.
- Query End Time: The timestamp when the query execution finished.
- Query Preparation Time: The time taken to prepare the query.
Before checking the query metrics in the HAR file, you first need to enable the EnableQueryMetricsWithQueryInHAR property in the appsettings.json file.
This property allows you to enable the widget query in the network tab of Inspect element and HAR file. Supported version: 7.8.18 and above
As a security measure, the query will initially be set to an empty state by default. This configuration is intended to prevent unauthorized access or potential vulnerabilities. It is strongly recommended that the query should only be activated or populated for the purpose of debugging or troubleshooting specific issues.