The time series clustering function is used to automatically cluster input time series data into different curve shapes. After that, the function quickly finds the corresponding clustering centers and curves with shapes that are different from the existing curve shapes.

Function list

Function Description
ts_density_cluster This function clusters time series data by using the density-based clustering method.
ts_hierarchical_cluster This function clusters time series data by using the hierarchical clustering method.
ts_similar_instance This function queries curves that are similar to a specified curve.

ts_density_cluster

Function format:
select ts_density_cluster(x, y, z) 
The following table describes the parameters.
Parameter Description Value
x Time column in ascending order Unixtime timestamp in seconds
y Numeric column corresponding to the data at a specified time point -
z Metric name corresponding to the data at a specified time point String type values, for example, machine01.cpu_usr
Example:
  • Statement for query and analysis:
    * and (h: "machine_01" OR h: "machine_02" OR h : "machine_03") | select ts_density_cluster(stamp, metric_value,metric_name ) from ( select __time__ - __time__ % 600 as stamp, avg(v) as metric_value, h as metric_name from log GROUP BY stamp, metric_name order BY metric_name, stamp ) 
  • Result:



The following table describes the display items.
Display item Description
cluster_id Clustering type. The value -1 indicates that the clustering cannot be categorized into any clustering centers.
rate Proportion of instances in the clustering
time_series Timestamp sequence of the clustering center
data_series Data sequence of the clustering center
instance_names Set of instances included in the clustering center
sim_instance Name of an instance in the clustering

ts_hierarchical_cluster

Function format:
select ts_hierarchical_cluster(x, y, z) 
The following table describes the parameters.
Parameter Description Value
x Time column in ascending order Unixtime timestamp in seconds
y Numeric column corresponding to the data at a specified time point -
z Metric name corresponding to the data at a specified time point String type values, for example, machine01.cpu_usr
Example:
  • Statement for query and analysis:
    * and (h: "machine_01" OR h: "machine_02" OR h : "machine_03") | select ts_hierarchical_cluster(stamp, metric_value, metric_name) from ( select __time__ - __time__ % 600 as stamp, avg(v) as metric_value, h as metric_name from log GROUP BY stamp, metric_name order BY metric_name, stamp )
  • Result:



The following table describes the display items.
Display item Description
cluster_id Clustering type. The value -1 indicates that the clustering cannot be categorized into any clustering centers.
rate Proportion of instances in the clustering
time_series Timestamp sequence of the clustering center
data_series Data sequence of the clustering center
instance_names Set of instances included in the clustering center
sim_instance Name of an instance in the clustering

ts_similar_instance

Function format:
select ts_similar_instance(x, y, z, instance_name) 
The following table describes the parameters.
Parameter Description Value
x Time column in ascending order Unixtime timestamp in seconds
y Numeric column corresponding to the data at a specified time point -
z Metric name corresponding to the data at a specified time point String type values, for example, machine01.cpu_usr
instance_name Name of a specified metric to be queried String values in the z set, for example, machine01.cpu_usr
Note The metric must be an existing one.
Statement example for query and analysis:
* and (h: "machine_01" OR h: "machine_02" OR h : "machine_03") | select ts_similar_instance(stamp, metric_value, metric_name, 'nu4e01524.nu8' ) from ( select __time__ - __time__ % 600 as stamp, avg(v) as metric_value, h as metric_name from log GROUP BY stamp, metric_name order BY metric_name, stamp )
The following table describes the display items.
Display item Description
instance_name Result list containing metrics that are similar to the specified metric
time_series Timestamp sequence of the clustering center
data_series Data sequence of the clustering center