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:// or gcs://stringYes
sftpConnectionConnection detailsSFTPConnectionYes
gcpConnectionConnection details for GCPGCPConnection
awsConnectionAWS Access credentialsAWSConnection
smbConnectionSMB connection detailsSMBConnection
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

Connection Types

SFTP

sftp-check.yaml
# ...
kind: Canary
spec:
folder:
- path: folder
sftpConnection:
host: 192.168.1.9
# ...
FieldDescriptionScheme
connectionPath of existing connection e.g. connection://sftp/instance
Mutually exclusive with username
Connection
usernameutually exclusive with connectionEnvVar
password Mutually exclusive with connection EnvVar
hostCustom AWS Cloudwatch endpointstring
portDefault to 22int

S3

s3-check.yaml
        # ...
kind: Canary
spec:
folder:
- path: s3://bucket/folder
awsConnection:
# ...

SMB

smb-check.yaml
# ...
kind: Canary
spec:
folder:
- path: smb:\\192.168.1.9\Some Public Folder\somedir
smbConnection:
#...
FieldDescriptionScheme
connectionPath of existing connection e.g. connection://windows/svc-account
Mutually exclusive withusername and password
Connections
username Mutually exclusive with connection EnvVar
password Mutually exclusive with connection EnvVar
domainWindows domain namestring
portDefault to 445int

GCS

gcs-check.yaml
# ...
kind: Canary
spec:
folder:
- path: gcs://bucket/folder
gcpConnection:
# ...