You can monitor the queries per second (QPS), response time (RT), and pod scaling
trends of a Knative application. This topic describes how to collect these metrics
and view the collected statistics.
Prerequisites
Log Service and Knative are enabled for an ASK cluster. For more information, see
Enable Knative.
Create and configure a Logstore
- Log on to the Log Service console.
- In the Projects section, click the Log Service project that is created for the ASK cluster.
- On the Logstores tab of the Log Storage page, click the + icon.
- In the Create Logstore panel, set the parameters and click OK. For more information about the parameters that are required to create a Logstore, see Manage a Logstore.
- In the Created. dialog box, click Data Import Wizard.
- In the Data Import section, click Docker Standard Output.

- In the Create Machine Group step, click Use Existing Machine Group.
- In the Machine Group Settings step, select an existing machine group and click Next.
- In the Specify Data Source step, set log collection rules by using the following template and click Next.
{
"inputs": [
{
"detail": {
"IncludeEnv": {
"QUEUE_SERVING_PORT": "8012"
},
"ExcludeLabel": {}
},
"type": "service_docker_stdout"
}
]
}
- In the Configure Query and Analysis step, keep the default settings and click Next.
- In the End step, click Search in the Log Query section.
- Click the Search & Analysis icon to view the collected log data.

- Click Index Attributes and select Attributes from the drop-down list.

- In the Search & Analysis panel, click Automatic Index Generation. In the Automatically Generate Index Attributes dialog box, click Append and add the following parameters to the content field.
Parameter |
Type |
Alias |
httpRequest.latency |
text |
latency |
httpRequest.status |
long |
status |
httpRequest.revisionName |
text |
revision |

Create a QPS chart
- Log on to the Log Service console.
- In the Projects section, click the Log Service project that is created for the ASK cluster.
- On the Logstores tab of the Log Storage page, click the Logstore that you want to manage.
- Enter the following SQL statement into the Search & Analyze field.

httpRequest | select date_trunc('minute' , __time__) as stamp, count(*) as num, revision from log group by stamp,revision order by stamp
- Click the Flow Chart icon. Set the parameters on the Properties tab and click Add to New Dashboard.
Create an RT chart
- Log on to the Log Service console.
- In the Projects section, click the Log Service project that is created for the ASK cluster.
- On the Logstores tab of the Log Storage page, click the Logstore that you want to manage.
- Enter the following SQL statement into the Search & Analyze field.
httpRequest|select stamp as timestamp, trt as rt, revision from (select date_trunc('minute' , __time__) as stamp, round (avg(cast(replace(latency,'s') as double)), 6) as trt, revision from log group by stamp, revision
order by stamp
limit 100000)
- Click the Flow Chart icon. Set the parameters on the Properties tab and click Add to New Dashboard.
Create a pod scaling trend chart
- Log on to the Log Service console.
- In the Projects section, click the Log Service project that is created for the ASK cluster.
- On the Logstores tab of the Log Storage page, click the Logstore whose name starts with audit.
- Click Index Attributes and select Attributes from the drop-down list.
- In the Search & Analysis panel, add the following parameters to the responseObject field in the Field Search section.
Parameter |
Type |
Alias |
metadata.labels.serving.knative.dev/revision |
text |
revision |
metadata.labels.serving.knative.dev/service |
text |
service |
status.readyReplicas |
long |
readyReplicas |
status.replicas |
long |
replicas |
- Enter the following SQL statement into the Search & Analyze field.
objectRef.resource: deployments and responseStatus.code: 200 and ( verb: update or verb: get)| select case when "revision" is null then 'none' else "revision" end as "revision", "t" as timestamp, total,concat('total:', cast(total AS varchar), ', ready: ', cast(ready AS varchar), ', notReady',cast((total-ready) AS varchar)) as detail from (select date_trunc('minute' , __time__) as t, max(replicas) as total, max(readyReplicas) as ready, revision from log where service='event-display-common' group by t, revision order by t)
- Click the Flow Chart icon. Set the parameters on the Properties tab and click Add to New Dashboard.
Monitor the application status
To monitor the application status, you can add the preceding charts to one dashboard
by using the following methods: