Skip to content

Check the correlation between two metrics

Use the correlation analysis function ts_similar(stamp, value, startStamp, endStamp, step, ds, metricType ). The stamp parameter specifies the time sequence. Points in time are sorted in ascending order. Each point in time is a UNIX timestamp. Unit: seconds. The value parameter specifies the sequence of numeric data at a specific point in time. The startStamp parameter specifies the start timestamp of the specified curve. The endStamp parameter specifies the end timestamp of the specified curve. The step parameter specifies the time interval between two adjacent points in a time series. The ds parameter specifies the numerical data on the specified curve. The metricType parameter specifies the type of metrics on the correlation curve.

SQL
* |
select
  request_uri,
  status,
  ts_similar(
    __time__,
    streamValue,
    1560911040,
    1560911065,
    5,
    array [5.1,4.0,3.3,5.6,4.0,7.2],
    'KENDALL'
  ) as "Correlation"
FROM  log
group by
  request_uri,
  status