Skip to main content

Folder

Checks the contents of a folder for size, age and count. Folder based checks are useful in a number of scenarios:

  • Verifying that backups have been uploaded and are the appropriate size
  • Checking that logs or other temporary files are being cleaned up
  • For batch processes:
    • Checking if files are being processed (and/or produced)
    • Checking the size of queue processing backlog
    • Checking if any error (.err or .log) files have been produced.
folder-check.yaml
apiVersion: canaries.flanksource.com/v1
kind: Canary
metadata:
name: folder-check
spec:
interval: 30
folder:
- path: /etc/
name: folder-check-min
description: Checks if there are at least 10 files in the folder
minCount: 10
FieldDescriptionSchemeRequired
pathA local folder path or a remote folder (SMB, SFTP, S3, GCS)stringYes
filterFilter objects out before checking if they are validFolderFilter
minCountThe minimum number of files inside the pathint
maxCountThe maximum number of files inside the path, can be used in conjunction with filter.regex to detect error filesint
minAgeThe youngest age a file can beDuration
maxAgeThe oldest age a file can be, often used to check for unprocessed files or files that have not been cleaned upDuration
minSizeThe minimum file size, can be used to detect backups that did not upload successfullySize
maxSizeThe maximim file sizeSize
nameName of the check, must be unique within the canarystringYes
descriptionDescription for the checkstring
iconIcon for overwriting default icon on the dashboardstring
labelsLabels for checkmap[string]string
testEvaluate whether a check is healthyExpression
displayExpression to change the formatting of the displayExpression
transformTransform data from a check into multiple individual checksExpression
metricsMetrics to export from[]Metrics

Duration

Durations are strings with an optional fraction and unit e.g. 300ms, 1.5h or 2h45m. Valid time units are ms, s, m, h.

Size

Sizes are string with a unit suffix e.g. 100 / 100b, 10mb, Valid size units are kb, mb, gb, tb

FolderFilter

FieldDescriptionSchemeRequired
maxAgeMaxAge the latest object should be younger than defined ageDuration
maxSizeMaxSize of the files inside the searchPathSize
minAgeMinAge the latest object should be older than defined ageDuration
minSizeMinSize of the files inside the searchPathSize
regexFilter files based on regular expressionregex

e.g. to verify that database backups are being performed

postgres-backup-check.yaml
apiVersion: canaries.flanksource.com/v1
kind: Canary
metadata:
name: folder-check
spec:
interval: 30
folder:
- path: /data/backups
filter:
regex: "pg-backups-.*.zip"
maxAge: 1d # require a daily backup
minSize: 10mb # the backup should be at least 10mb

Result Variables

The following fields are available in test, display and transform expressions

FieldScheme
Oldestos.FileInfo
Newestos.FileInfo
MinSizeos.FileInfo
MaxSizeos.FileInfo
SupportsTotalSize (Only true for SMB folders)bool
SupportsAvailableSize (Only true for SMB folders)bool
TotalSizeint64
AvailableSizeint64
Files[]os.FileInfo

FolderFilter

FieldDescriptionSchemeRequired
minAgeDuration
maxAgeDuration
minSizeSize
maxSizeSize
regexstring