Skip to content

Obtain a curve similar to a specific curve

Use a hierarchical clustering method to cluster multiple time series. Syntax: select ts_similar_instance(x, y, z, instance_name). The x parameter specifies the time sequence. Points in time are sorted in ascending order. Each point in time is a UNIX timestamp. Unit: seconds. The y parameter specifies the sequence of numeric data at a specific point in time. The z parameter specifies the name of the curve corresponding to the data at a specific point in time. The value is of the string type. Example: machine01.cpu_usr. The instance_name parameter specifies the name of a curve to be searched.

SQL
*
and (
  request_uri: "/url1"
  OR request_uri: "/url2"
  OR request_uri: "/url3"
) |
select
  ts_similar_instance(stamp, metric_value, metric_name, '/url3')
FROM  (
    select
      __time__-__time__ % 600 as stamp,
      sum(status) as metric_value,
      request_uri as metric_name
    FROM      log
    GROUP BY
      stamp,
      metric_name
    order BY
      metric_name,
      stamp
  )