Counts
The frontline_meter_counts table holds counts of requests per minute, key sheet, key, route,
operation and outcome, the operation only on a route that declares operations. A key appears only as
its id, the public part the gateway sends as Frontline-Key, and the table holds no address, no
secret and no content of a request. The counts of a minute older than
frontline-api.meter.retention_days, 90 days by default, are pruned once a day: the package
adds php artisan model:prune for its model to your schedule while it runs its own migrations, or
while your application migrates them and says so with ignoreMigrations(tablesExist: true).
The job keeps a key's id only once the gateway has authenticated the key, which a request with it shows when it was forwarded, answered from the cache or refused for an ability the key lacks, in observe mode as well. A request with any other key, such as one on no sheet, is counted without key and key sheet, in one row per minute, route and outcome, so key ids a client makes up cannot grow the table. Requests of a key read before its first authenticated one can stay in that row.
Reading the meter stream
The gateways add their counts to the meter stream in the store, a batch every one to five seconds.
While frontline-api.product and frontline-api.environment are set, the package reads that
stream every minute on one server with
the queued job Pushery\FrontlineApi\Jobs\IngestMeter, and adds the counts of every batch exactly
once: a batch read a second time, after a failure or by a second run, adds nothing. Run a queue
worker and the scheduler, as for publishing the sheets. A run the queue loses before a worker
starts it, as to php artisan queue:clear, holds up the next one for five minutes at most. The job
keeps two tables of its own:
frontline_meter_readsholds how far the stream has been read, and the entries the job discarded because they were no meter batch it reads, such as one of a newer protocol, with the time and the reason of the last one. The reason names the rule the entry breaks, and of its content no more than its protocol as a whole number.frontline_meter_bootsholds the highest batch number read since each start of a gateway. A gap in those numbers means batches the stream lost before the job read them, as when it was trimmed while no run read it, and the job records them as lost with the time it found the gap. A start of a gateway that began before the job first read the stream counts the batches the stream no longer held as lost as well. A start not read within the retention is forgotten.
A run reads up to 5,000 batches and leaves the rest to the next one.
A model of your own
To give the model relations or scopes of your own, extend \Pushery\FrontlineApi\Models\MeterCount
and name your class in the published config:
'models' => [
\Pushery\FrontlineApi\Models\MeterCount::class => \App\Models\MeterCount::class,
],
A class there that does not extend the package's model is ignored.
The model reads minute as the start of the minute in UTC, whatever zone your application runs
in, which is how the job writes it.