Variable Type | Description | Effective Scope |
---|---|---|
Data source | A data source variable allows you to batch switch data sources of charts in the dashboard. It is suitable for scenarios where a dashboard is applied to multiple log topics, data on the dashboard is compared in blue and green, and more. | Charts that use the variable on the dashboard |
Quick filtering | A quick filtering variable allows you to filter data of all charts on the dashboard by specified fields, which is equivalent to adding filter criteria in chart query statements. | All charts on the dashboard |
Parameter | Description |
---|---|
Variable Type | Variable category. Different categories correspond to different configuration items and application scenarios. Here, select **Data Source**. |
Variable Name | Name of the variable in the query/search statement. The value can contain only letters and digits. |
Display Name | Name of the variable displayed on the dashboard. This parameter is optional. If it is empty, the system automatically uses the variable name as the display name. |
Data Source Scope | Value range of the variable. Currently, only option **All Log Topics** is supported, that is, there is no limit on the data source range. |
Default Log Topic | Log topic used by default. |
Note:If there are no charts on your dashboard, please add charts.
A data source variable does not apply directly to all charts on the dashboard. It applies only to those charts that use it on the chart editing page.
Parameter | Description |
---|---|
Variable Type | Variable category. Different categories correspond to different configuration items and application scenarios. Here, select **Quick Filtering**. |
Display Name | Name of the variable control on the UI. This parameter is optional. If it is empty, the system automatically uses the variable name as the display name. |
Log Topic | Source log topic of the variable field. |
Select Field | Filter field. |
Support Multiple-Selection | If this parameter is toggled on, you can select multiple variable values as filter conditions. |
Log topic A stores NGINX access logs of an application, and you are to use the dashboard to view the throughput, number of error requests, and response time of the entire application and a specified API. The following is the sample log information:
body_bytes_sent:1344
client_ip:127.0.0.1
host:www.example.com
http_method:POST
http_referer:www.example.com
http_user_agent:Mozilla/5.0
proxy_upstream_name:proxy_upstream_name_4
remote_user:example
req_id:5EC4EE87A478DA3436A79550
request_length:13506
request_time:1
http_status:201
time:27/Oct/2021:03:25:24
upstream_addr:219.147.70.216
upstream_response_length:406
upstream_response_time:18
upstream_status:200
interface:proxy/upstream/example/1
Throughput
* | select histogram( cast(__TIMESTAMP__ as timestamp),interval 1 minute) as analytic_time, count(*) as pv group by analytic_time order by analytic_time limit 1000
Number of error requests
http_status:>=400 | select histogram( cast(__TIMESTAMP__ as timestamp),interval 1 minute) as analytic_time, count(*) as pv_lost group by analytic_time order by analytic_time limit 1000
Average response time
* | select histogram( cast(__TIMESTAMP__ as timestamp),interval 1 minute) as analytic_time, avg(request_time) as response_time group by analytic_time order by analytic_time limit 1000
If API Name is not specified, data is not filtered, and the charts on the dashboard display all data, that is, the overall performance metrics of the application.
If API Name is specified, all charts on the dashboard use the specified API as the filter condition to filter data and display the performance metrics of the API.
An application has a production environment and a test environment, and logs are collected to Log topic A (production environment) and Log topic B (test environment). Therefore, during application development, testing, and Ops, you need to pay attention to the performance metrics of the two environments.
Add charts.
In the Log Topic drop-down list, select Use Data Source Variable and select the ${env}
variable created in the previous step. Then, charts will use the value of the variable as the data source, that is, Log topic A (production environment).
Repeat Step 3 to add other charts.
Go back to the dashboard details page, click the data source variable Application Environment at the top of the page, and switch the log topic in the drop-down list of the variable. Then, the charts that use the variable will switch the log topic accordingly.
Was this page helpful?