nsmcp::AccessAnalytics method slowTimeline (protected)
<instance of nsmcp::AccessAnalytics> slowTimeline options
Defined in /usr/local/ns/tcl/nsmcp/log-peer-context.tcl
Opt-in, short indexed window. This uses the same read transaction as access_summary and never reparses the source access log.
- Parameters:
- options (required)
- Testcases:
- No testcase defined.
Source code: set queryStarted [clock clicks -milliseconds] set db ${:db} set from [dict get $options from] set to [dict get $options to] set size [dict get $options bucketSeconds] set baselineFrom [expr {$from-600}] set selected "r.start >= $from AND r.start < $to" set baseline "start >= $baselineFrom AND start < $from" foreach key {path status pool peer authenticationState} { if {[dict exists $options $key]} { set value [ns_dbquotevalue [dict get $options $key]] append selected " AND r.$key=$value" append baseline " AND $key=$value" } } set buckets {} for {set slot [expr {($from/$size)*$size}]} {$slot<$to} {incr slot $size} { dict set buckets $slot [dict create from $slot completed 0 timed 0 over1s 0 over2s 0 runMax 0.0 queueOver100ms 0 queueMax 0.0 baselineComparable 0 over3x 0 over5x 0] } foreach row [$db execute " WITH baseline AS MATERIALIZED ( SELECT path, count(*) AS n, avg(run) AS meanRun FROM nsmcp_access_requests WHERE $baseline AND run IS NOT NULL AND path<>'' GROUP BY path ) SELECT cast(r.start/$size AS INTEGER)*$size AS slot, count(*) AS completed, count(r.run) AS timed, coalesce(sum(r.run>=1.0),0) AS over1s, coalesce(sum(r.run>=2.0),0) AS over2s, coalesce(max(r.run),0) AS runMax, coalesce(sum(r.queue>=0.1),0) AS queueOver100ms, coalesce(max(r.queue),0) AS queueMax, coalesce(sum(b.n>=5 AND r.run IS NOT NULL),0) AS baselineComparable, coalesce(sum(b.n>=5 AND r.run>=max(0.1,3*b.meanRun)),0) AS over3x, coalesce(sum(b.n>=5 AND r.run>=max(0.1,5*b.meanRun)),0) AS over5x FROM nsmcp_access_requests r LEFT JOIN baseline b ON r.path=b.path WHERE $selected GROUP BY slot ORDER BY slot "] { dict set buckets [dict get $row slot] $row dict set buckets [dict get $row slot] from [dict get $row slot] dict unset buckets [dict get $row slot] slot } set topPaths [$db execute " SELECT path, count(*) AS over1s, coalesce(sum(run>=2.0),0) AS over2s, max(run) AS runMax FROM nsmcp_access_requests r WHERE $selected AND run>=1.0 GROUP BY path ORDER BY over1s DESC,path LIMIT 10 "] set rows {} set firstElevated {} set previousElevated {} set firstRelativeElevated {} set previousRelativeElevated {} set over1s 0 set shown 0 foreach row $topPaths {incr shown [dict get $row over1s]} foreach slot [lsort -integer [dict keys $buckets]] { set row [dict get $buckets $slot] incr over1s [dict get $row over1s] set timed [dict get $row timed] set elevated [expr {$timed>=20 && [dict get $row over1s]>=5 && 20*[dict get $row over1s]>=$timed}] if {$firstElevated eq {} && $elevated && $previousElevated ne {}} { set firstElevated $previousElevated } set previousElevated [expr {$elevated ? $slot : {}}] set comparable [dict get $row baselineComparable] set relativeElevated [expr {$comparable>=5 && [dict get $row over3x]>=3 && 5*[dict get $row over3x]>=$comparable}] if {$firstRelativeElevated eq {} && $relativeElevated && $previousRelativeElevated ne {}} { set firstRelativeElevated $previousRelativeElevated } set previousRelativeElevated [expr {$relativeElevated ? $slot : {}}] lappend rows $row } return [dict create from $from to $to bucketSeconds $size baselineFrom $baselineFrom baselineTo $from queryMilliseconds [expr {[clock clicks -milliseconds]-$queryStarted}] baselineMinimumSamples 5 relativeRunFloorSeconds 0.1 firstElevatedBucket $firstElevated onsetRule {two adjacent buckets, each with at least 20 timed requests and at least 5 requests over 1s comprising 5% or more} firstRelativeElevatedBucket $firstRelativeElevated relativeOnsetRule {two adjacent buckets, each with at least 5 baseline-comparable requests and at least 3 requests over 3x comprising 20% or more} baselineWindowRetained false timingScope {Completed requests with worker phase timing; buckets use request start time. Baseline is the mean run time for the same path in the preceding 10 minutes; at least 5 timed samples are required.} buckets $rows topPaths $topPaths topPathsOmittedSlowRecords [expr {$over1s-$shown}]]XQL Not present: Generic, PostgreSQL, Oracle
![[i]](/resources/acs-subsite/ZoomIn16.gif)