Monitoring

Show how the server is doing in Prometheus and Grafana, with figures that hold no names of people or files.

On this page
  1. Turning it on
  2. In Prometheus
  3. What the figures are
  4. Grafana
  5. The dashboard
  6. What is not in them

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.

NameLabelsWhat it is
thirtyfile_build_infoversionThe version; the value is always 1
thirtyfile_process_start_time_secondsWhen the server started
thirtyfile_process_uptime_secondsSeconds since it started
thirtyfile_process_resident_memory_bytesMemory held in RAM (Linux)
thirtyfile_process_open_filesFiles and connections open (Linux)
thirtyfile_process_threadsThreads (Linux)
thirtyfile_http_requests_totalmethod, codeRequests answered, by method and class of status
thirtyfile_http_request_duration_secondsSeconds from a request to the start of its answer (a histogram)
thirtyfile_http_requests_in_flightRequests being answered now
thirtyfile_sign_in_events_totaleventSign-in events as the sign-in log names them: login, bad_password, locked, 2fa_failed…
thirtyfile_sessionsSign-in sessions that have not ended
thirtyfile_accountsstateAccounts, active or disabled
thirtyfile_storage_operations_totallocation, op, outcomeOperations on storage locations, by how they ended: ok, error, timeout
thirtyfile_storage_bytes_totallocation, opBytes read from and written to storage locations
thirtyfile_storage_operation_duration_secondslocation, opHow long storage operations took (a histogram)
thirtyfile_storage_location_uplocation1 when the location can be used, 0 when it can't
thirtyfile_storage_location_live_bytes, _trash_bytes, _version_byteslocationBytes of the files in spaces on a location: live, in the trash, earlier versions
thirtyfile_storage_location_disk_free_bytes, _disk_total_byteslocationFree and total bytes of the disk a location is on
thirtyfile_disk_free_bytes, thirtyfile_disk_total_bytesvolumeFree 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_bytesSize of the database and of its write-ahead log
thirtyfile_tasks_runningkindTasks running now (compressing, extracting, copying, moving…)
thirtyfile_tasks_finished_totalkind, outcomeTasks that ended, done or failed
thirtyfile_background_last_success_timestamp_secondsjobWhen a background loop last did its work (maintenance, usage_sampler, location_checks, backup_jobs, replica_jobs, space_moves)
thirtyfile_backup_last_complete_age_secondspolicySeconds since a policy that is on last made a complete snapshot; missing when it has made none
thirtyfile_backup_policiessnapshotPolicies that are on, with or without a complete snapshot
thirtyfile_replica_sync_age_secondspolicySeconds since every target of a replica policy was up to date; missing when one never was
thirtyfile_content_search_queue, thirtyfile_content_search_failedFiles waiting to be read for search, and those that couldn't be read
thirtyfile_alert_deliveries_pending, thirtyfile_alert_deliveries_failedAlert messages (email, webhook) waiting to be sent, and given up on
thirtyfile_alerts_firingkindAdministrator alerts firing now, by kind
thirtyfile_ftps_certificate_expiry_secondsSeconds until the FTPS certificate ends (negative once it has)
thirtyfile_emails_totaloutcomeEmails sent, sent or failed
thirtyfile_metrics_requests_totaloutcomeRequests 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.