Compare commits

...

8 Commits

Author SHA1 Message Date
Taylor McKinnon 808d24e92b f 2022-01-06 11:43:51 -08:00
Taylor McKinnon 7086510792 ensure endTimestamp doesn't exceed passed timestamp 2022-01-06 11:30:51 -08:00
Taylor McKinnon 0114cd74b7 (drop) enable debug logging 2022-01-06 10:46:55 -08:00
Taylor McKinnon 57a5044b31 comment LOGMSG 2022-01-06 10:33:13 -08:00
Taylor McKinnon 1cd9d68adb make size configurable 2022-01-06 10:30:29 -08:00
Taylor McKinnon 0170eddccd cleanup 2022-01-06 10:05:12 -08:00
Taylor McKinnon 2098de65c1 f 2022-01-06 09:20:25 -08:00
Taylor McKinnon 3433cfe15f f 2022-01-05 15:30:11 -08:00
2 changed files with 44 additions and 4 deletions

View File

@ -34,6 +34,8 @@ spec:
value: '10000000' value: '10000000'
- name: ENABLE_SENSISION - name: ENABLE_SENSISION
value: 't' value: 't'
- name: warpscript.extension.logEvent
value: io.warp10.script.ext.logging.LoggingWarpScriptExtension
resources: resources:
requests: requests:
cpu: 300m cpu: 300m

View File

@ -1,3 +1,4 @@
{ {
'name' 'utapi/createSnapshot' 'name' 'utapi/createSnapshot'
'desc' 'desc'
@ -40,15 +41,54 @@
'utapi.checkpoint' 'checkpoint_class' STORE 'utapi.checkpoint' 'checkpoint_class' STORE
'utapi.repair.correction' 'correction_class' STORE 'utapi.repair.correction' 'correction_class' STORE
// will read the key `max_snapshot_size@utapi/createSnapshot` from warp 10 config
'max_snapshot_size' 'P6H' MACROCONFIGDEFAULT DURATION 'max_snapshot_size' STORE
// Fetch latest master snapshot // Fetch latest master snapshot
$read_token $master_snapshot_class $filterLabels $endTimestamp @utapi/fetchFirstRecordBefore $read_token $master_snapshot_class $filterLabels $endTimestamp @utapi/fetchFirstRecordBefore
FIRSTTICK FIRSTTICK
// If we found a snapshot, increment its timestamp so we start at the tick immediatly after // If we found a snapshot, increment its timestamp so we start at the tick immediatly after
<% DUP 0 > %> <% DUP 0 > %>
<% 1 + %> IFT <% 1 + %> IFT
'masterSnapshotTimestamp' STORE // Grab our ending timestamp from the last master snapshot (0 if no snapshots) 'masterSnapshotTimestamp' STORE // Grab our ending timestamp from the last master snapshot (0 if no snapshots)
// If snapshot is longer than 6 hours change endTimestamp to be masterSnapshotTimestamp + 6 hours
<% $endTimestamp $masterSnapshotTimestamp - $max_snapshot_size > %>
<%
// If there are no preceding snapshots
<% $masterSnapshotTimestamp 0 == %>
<%
// Find the oldest checkpoint
// 'No previous snapshots found, detecting start of checkpoints.' LOGMSG
$auth_info ->JSON
{ 'class' $checkpoint_class 'labels' $filterLabels } ->JSON
@utapi/findOldestRecord 'oldestTimestamp' STORE
// If no checkpoints are found
<% $oldestTimestamp -1 == %>
<%
// 'No checkpoints found. Looking for corrections' LOGMSG
$auth_info ->JSON
{ 'class' $correction_class 'labels' $filterLabels } ->JSON
@utapi/findOldestRecord 'oldestTimestamp' STORE
<% $oldestTimestamp -1 == %>
<%
// 'No corrections or checkpoints found. Nothing to snapshot' LOGMSG
STOP
%> IFT
%> IFT
<% $oldestTimestamp $max_snapshot_size + $endTimestamp < %>
<%
$oldestTimestamp $max_snapshot_size + 'endTimestamp' STORE
%> IFT
%>
<%
$masterSnapshotTimestamp $max_snapshot_size + 'endTimestamp' STORE
%> IFTE
// 'Oversize snapshot detected using ' $endTimestamp TOSTRING + ' as end' + LOGMSG
%> IFT
[ [
"node" "node"
".app" ".app"
@ -91,6 +131,8 @@
$endTimestamp $endTimestamp
@utapi/fetchFirstRecordBefore @utapi/fetchFirstRecordBefore
VALUES 0 GET @utapi/decodeRecord 'record' STORE VALUES 0 GET @utapi/decodeRecord 'record' STORE
<% $record 'ops' GET ISNULL %>
<% $record {} 'ops' PUT DROP %> IFT
$fieldSnapshots $record $value PUT DROP $fieldSnapshots $record $value PUT DROP
%> FOREACH %> FOREACH
$previousSnapshots $fieldSnapshots $field PUT DROP $previousSnapshots $fieldSnapshots $field PUT DROP
@ -163,9 +205,6 @@
$labelSnapshots $created $labelValue PUT DROP $labelSnapshots $created $labelValue PUT DROP
%> FOREACH %> FOREACH
// $createdSnapshots ->JSON LOGMSG
// $endTimestamp TOSTRING LOGMSG
// Fetch all checkpoints since last master snapshot til passed time // Fetch all checkpoints since last master snapshot til passed time
{ {
'token' $read_token 'token' $read_token
@ -236,7 +275,6 @@
$labelSnapshots $created $labelValue PUT DROP $labelSnapshots $created $labelValue PUT DROP
%> FOREACH %> FOREACH
// $createdSnapshots ->JSON LOGMSG
0 'snapshots' STORE 0 'snapshots' STORE
// For each of our indexed fields // For each of our indexed fields
$createdSnapshots KEYLIST $createdSnapshots KEYLIST