Monitoring
Show how the server is doing in Prometheus and Grafana, with figures that hold no names of people or files.
On this page
Turning it on
Open Control panel › Monitoring. Make a token: it is shown once, and only a fingerprint of it is kept, so copy it now. Then switch on Answer requests for the metrics. The figures are at /metrics on your site, and only a request that sends Authorization: Bearer <token> gets them. Switched off, the address doesn't exist.
You can list the addresses or networks that may ask (203.0.113.7, 10.1.0.0/16); a request from another address is refused before the token is looked at. Without a list, any address may ask with the token. A new token replaces the old one at once. A wrong token counts against the address like a wrong password: after 20 in a row it has to wait. Making and changing the token asks for your password, and is in the activity log.
In Prometheus
Add a scrape job with the token as its credentials:
scrape_configs:
- job_name: thirtyfile
scheme: https
authorization:
credentials: tfm_…
static_configs:
- targets: ["files.example.com"]
An example of alert rules:
groups:
- name: thirtyfile
rules:
- alert: ThirtyFileDown
expr: up{job="thirtyfile"} == 0
for: 5m
- alert: ThirtyFileLocationDown
expr: thirtyfile_storage_location_up == 0
for: 5m
- alert: ThirtyFileDiskNearlyFull
expr: thirtyfile_disk_free_bytes / thirtyfile_disk_total_bytes < 0.1
for: 15m
- alert: ThirtyFileBackupOverdue
expr: thirtyfile_backup_last_complete_age_seconds > 2 * 86400
- alert: ThirtyFileBackgroundLoopStuck
expr: time() - thirtyfile_background_last_success_timestamp_seconds{job="maintenance"} > 3 * 3600
- alert: ThirtyFileCertificateEnds
expr: thirtyfile_ftps_certificate_expiry_seconds < 14 * 86400
What the figures are
Every name starts with thirtyfile_. A name that has been released isn't changed; a new version may add figures.
| Name | Labels | What it is |
|---|---|---|
thirtyfile_build_info | version | The version; the value is always 1 |
thirtyfile_process_start_time_seconds | When the server started | |
thirtyfile_process_uptime_seconds | Seconds since it started | |
thirtyfile_process_resident_memory_bytes | Memory held in RAM (Linux) | |
thirtyfile_process_open_files | Files and connections open (Linux) | |
thirtyfile_process_threads | Threads (Linux) | |
thirtyfile_http_requests_total | method, code | Requests answered, by method and class of status |
thirtyfile_http_request_duration_seconds | Seconds from a request to the start of its answer (a histogram) | |
thirtyfile_http_requests_in_flight | Requests being answered now | |
thirtyfile_sign_in_events_total | event | Sign-in events as the sign-in log names them: login, bad_password, locked, 2fa_failed… |
thirtyfile_sessions | Sign-in sessions that have not ended | |
thirtyfile_accounts | state | Accounts, active or disabled |
thirtyfile_storage_operations_total | location, op, outcome | Operations on storage locations, by how they ended: ok, error, timeout |
thirtyfile_storage_bytes_total | location, op | Bytes read from and written to storage locations |
thirtyfile_storage_operation_duration_seconds | location, op | How long storage operations took (a histogram) |
thirtyfile_storage_location_up | location | 1 when the location can be used, 0 when it can't |
thirtyfile_storage_location_live_bytes, _trash_bytes, _version_bytes | location | Bytes of the files in spaces on a location: live, in the trash, earlier versions |
thirtyfile_storage_location_disk_free_bytes, _disk_total_bytes | location | Free and total bytes of the disk a location is on |
thirtyfile_disk_free_bytes, thirtyfile_disk_total_bytes | volume | Free and total bytes of the disk of the data folder and of the storage folder (data, storage) |
thirtyfile_database_size_bytes, thirtyfile_database_wal_size_bytes | Size of the database and of its write-ahead log | |
thirtyfile_tasks_running | kind | Tasks running now (compressing, extracting, copying, moving…) |
thirtyfile_tasks_finished_total | kind, outcome | Tasks that ended, done or failed |
thirtyfile_background_last_success_timestamp_seconds | job | When a background loop last did its work (maintenance, usage_sampler, location_checks, backup_jobs, replica_jobs, space_moves) |
thirtyfile_backup_last_complete_age_seconds | policy | Seconds since a policy that is on last made a complete snapshot; missing when it has made none |
thirtyfile_backup_policies | snapshot | Policies that are on, with or without a complete snapshot |
thirtyfile_replica_sync_age_seconds | policy | Seconds since every target of a replica policy was up to date; missing when one never was |
thirtyfile_content_search_queue, thirtyfile_content_search_failed | Files waiting to be read for search, and those that couldn't be read | |
thirtyfile_alert_deliveries_pending, thirtyfile_alert_deliveries_failed | Alert messages (email, webhook) waiting to be sent, and given up on | |
thirtyfile_alerts_firing | kind | Administrator alerts firing now, by kind |
thirtyfile_ftps_certificate_expiry_seconds | Seconds until the FTPS certificate ends (negative once it has) | |
thirtyfile_emails_total | outcome | Emails sent, sent or failed |
thirtyfile_metrics_requests_total | outcome | Requests for these figures: ok, unauthorized, forbidden, too_many |
Grafana
Import thirtyfile-grafana.json (Dashboards › New › Import) and choose your Prometheus. It shows requests and how long they take, sign-ins, storage operations, disks, tasks, backups and what is firing.
The dashboard
Control panel › Dashboard needs no Prometheus. It says whether the server is well (the same check as /api/health, with the reasons), what administrator alerts are firing, how many people are signed in and active, tasks, uploads and free disk space, and charts of the last 24 hours or 7 days: requests and server errors, how long answers take, people and work, storage operations, failed sign-ins and free disk space. It also lists the latest server errors and failed sign-ins, with a link to the Activity log. The charts are made of a figure for each five minutes that the server keeps for eight days, whether or not /metrics is turned on; a stretch with no figures is the server having been off.
What is not in them
No name of a person or a file, no address of a visitor and no path: labels are fixed words (a method, a kind of task, a kind of event), and the names of the storage locations and backup policies that administrators chose. A name of a location or a policy that holds a quote or a line break is written as the format asks.
The counters start again at zero when the server restarts, as Prometheus expects (rate() and increase() deal with it). The figures that have to be looked up (sessions, accounts, disks, the database, backups) are looked at every 15 seconds while monitoring is on, and are kept in memory: a request for the metrics takes no lock and reads no disk, so asking often costs nothing. The memory, open files and threads are shown on Linux only.