Select the Prometheus data type and enter the PromQL expression. For example, the following shows how to query the CPU utilization of the server:
Below are several commonly used functions.
Using the rate function, which takes the average per second increment of a counter over the specified time period. The following query shows the change rate of the eth0 network card of the host per minute:
Using the increase function, which is used for counter data types to capture the total increment over a certain period. The following query shows the increment of the eth0 network card of the host over one minute:
Using the topk function, which retrieves the highest values. This function is generally used for instantaneous alerts rather than for observing curve graphs. The following example shows the CPU utilization rate changes per second within one minute, only displaying the top 2 results.
Using the count function, which outputs the cumulative count of values that meet certain conditions. It is often used for monitoring judgments in certain scenarios. For example, in a company with 100 servers, if only 10 servers have a CPU utilization rate above 80%, no alarm is needed. However, if the number exceeds 70, an alarm is necessary. The following expression shows the alarm for the number of hosts with CPU utilization above 20% being greater than 1.
Table View and Graph View
Table View: Used to view raw data, reflecting the original data on the collection reporting frequency. By viewing the Table view data, you can see the raw data results, reporting time, and reporting interval. The Table is generally used to query the raw values of metrics and verify whether the reporting time of the metrics has deviated from expectations (delay). By comparing the reporting data time and the reporting data interval, you can determine whether there are anomalies in the reported data values and states. The following figure illustrates this:
Graph View: Typically used for viewing trends in time series data. An important parameter in the query conditions for the Graph view is the step parameter, which can be automatically calculated (or manually entered). If it is inconsistent with the collection frequency in the configuration file, the values queried by the Graph will not be raw data. The following example illustrates this.
Specifying the step parameter value as 15 seconds will lead to significant differences in the query results compared to the raw data results.