nsmcp::LogCorrelation method configureAccessAnalytics (public)
<instance of nsmcp::LogCorrelation> configureAccessAnalytics \ section path
Defined in /usr/local/ns/tcl/nsmcp/log-traffic-unified.tcl
Configure access analytics for the selected log source. Read the module section and attach the available store-backed analytics implementation.
- Parameters:
- section (required)
- NaviServer module configuration section.
- path (required)
- Configured source or database path.
- Returns:
- The configured analytics setup result.
- Testcases:
- No testcase defined.
Source code: set settings [:accessRecordStoreSettings] if {$settings eq {}} { error "continuous access store requires a dedicated accessRecordPool" } set controlPool [ns_config $section databasePool {}] if {[dict get $settings pool] eq $controlPool || ($controlPool ne {} && [file normalize [ns_config ns/db/pool/$controlPool datasource {}]] eq [file normalize [ns_config ns/db/pool/[dict get $settings pool] datasource {}]])} { error "accessRecordPool must use a dedicated pool and datasource" } set legacyPeer [ns_baseunit -time [ns_config $section accessRetention 24h]] dict set settings ingestion [ns_config $section accessRecordIngestion tcl] if {[dict get $settings ingestion] ni {tcl c batch}} { error "accessRecordIngestion must be tcl or c (batch is a legacy alias for c)" } dict set settings lockWaitMs [:accessRecordLockWait $section] dict set settings peerRetention [ns_baseunit -time [ns_config $section accessPeerRetention [expr {min(86400,$legacyPeer)}]]] if {[dict get $settings peerRetention]<1 || [dict get $settings peerRetention]>[dict get $settings retention]} { error "accessPeerRetention must be positive and no longer than accessRecordRetention" } if {![nsf::object::exists ::nsmcp::unifiedRedactor]} { ::nsmcp::LogRedactor create ::nsmcp::unifiedRedactor } set settings [accessUnifiedPolicy $settings ::nsmcp::unifiedRedactor] set maintenance [ns_baseunit -time [ns_config $section accessRetentionInterval 30s]] if {$maintenance<1} { error "accessRetentionInterval must be at least 1s" } set sqliteSection $section/access-record/sqlite set cacheBytes [accessScanBudget [ns_config $sqliteSection retentionCacheBytes 32MiB]] if {$cacheBytes<1048576 || $cacheBytes>67108864} { error "$sqliteSection retentionCacheBytes must be 1MiB through 64MiB" } dict set settings retentionCacheBytes $cacheBytes set partition [ns_baseunit -time [ns_config $section accessRecordPartitionInterval 24h]] if {$partition<3600 || $partition!=int($partition) || int($partition)%60!=0 || int(ceil([dict get $settings retention]/double($partition)))+2>256} { error "accessRecordPartitionInterval must be minute-aligned, at least 1h, and retain at most 256 tables" } set bootstrap [ns_baseunit -time [ns_config $section accessRecordBootstrapWindow 2d]] if {$bootstrap<60} { error "accessRecordBootstrapWindow must be at least 60s" } dict set settings partitionInterval [expr {int($partition)}] dict set settings bootstrapSeconds [expr {int($bootstrap)}] dict set settings historicalBackfill [ns_config -bool $section accessRecordHistoricalBackfill false] dict set settings sourcePath [file normalize $path] nsv_set nsmcp:access-store:[ns_info server] settings $settings ::nsmcp::UnifiedAccessAnalytics create ::nsmcp::accessAnalytics -path $path -settings $settings -database ::nsmcp::database -ingestBytes [accessScanBudget [ns_config $section accessIngestMaxBytes 16MiB]] -ingestMilliseconds [expr {int(1000*[ns_baseunit -time [ns_config $section accessIngestMaxTime 2s]])}] -retentionInterval $maintenance -retentionRetryInterval [ns_baseunit -time [ns_config $section accessRetentionRetryInterval 5s]] -retentionBatchRows [ns_config -int $section accessRetentionBatchRows 1000] -retentionMilliseconds [expr {int(1000*[ns_baseunit -time [ns_config $section accessRetentionMaxTime 1s]])}] set interval [ns_baseunit -time [ns_config $section accessIngestInterval 5s]] if {$interval<1} { error "accessIngestInterval must be at least 1s" } ns_schedule_proc -thread $interval ::nsmcp::accessAnalytics refresh ns_schedule_proc -once -thread $maintenance ::nsmcp::accessAnalytics retentionTickXQL Not present: Generic, PostgreSQL, Oracle
![[i]](/resources/acs-subsite/ZoomIn16.gif)