---
title: "Configuration — Metrics for Laravel | Roundly"
description: "Every config key and its default — reporting timezone, default range, unit and precision, result caching, the partition label and trend drivers."
url: https://roundly-consulting.com/open-source/docs/metrics-for-laravel/configuration
language: en
---

[All packages](https://roundly-consulting.com/open-source.md)

[Metrics for Laravel](https://roundly-consulting.com/open-source/docs/metrics-for-laravel.md)

# Configuration

The package works with zero configuration. The published config/metrics.php in full:

```php
use RoundlyConsulting\Metrics\Types\Trend\QueryExpressions\Mysql;
use RoundlyConsulting\Metrics\Types\Trend\QueryExpressions\Postgres;
use RoundlyConsulting\Metrics\Types\Trend\QueryExpressions\Sqlite;

return [
    'timezone' => env('METRICS_TIMEZONE'),

    'default_range' => 'ALL',
    'default_unit' => 'DAY',
    'precision' => 0,

    'cache' => [
        'enabled' => env('METRICS_CACHE_ENABLED', false),
        'store' => env('METRICS_CACHE_STORE'),
        'ttl' => env('METRICS_CACHE_TTL', 300),
        'prefix' => 'metrics',
    ],

    'partition' => [
        'other_label' => 'Other',
    ],

    'trend_drivers' => [
        'mysql' => Mysql::class,
        'mariadb' => Mysql::class,
        'pgsql' => Postgres::class,
        'sqlite' => Sqlite::class,
    ],
];
```

## Every key

| Key | Default | Env | Purpose |
| --- | --- | --- | --- |
| `timezone` | null | `METRICS_TIMEZONE` | Reporting timezone — ranges resolve in it and trend buckets are labelled in it; null or blank (not set) uses the app timezone. Override per metric with timezone(). Otherwise a string. |
| `default_range` | ALL | — | Period value (ALL, TODAY, 30, MTD, …) applied to every metric before setup(); an unknown value throws. |
| `default_unit` | DAY | — | Unit value (MINUTE … YEAR, exact case) used by trend metrics before setup(); an unknown value throws. |
| `precision` | 0 | — | Default rounding precision for every value — an integer (digit strings accepted). |
| `cache.enabled` | false | `METRICS_CACHE_ENABLED` | Master switch for result caching: true/false, 1/0, on/off or yes/no; anything else throws. |
| `cache.store` | null | `METRICS_CACHE_STORE` | Cache store name; null or blank (not set) uses the default store, otherwise a string. |
| `cache.ttl` | 300 | `METRICS_CACHE_TTL` | Seconds a cached result is remembered — a whole number from 1 to 31536000; digit strings from .env are accepted. |
| `cache.prefix` | metrics | — | Prefix for generated cache keys — a string; blank is not set, so metrics applies. |
| `partition.other_label` | Other | — | Translatable label of the rolled-up bucket when a partition is capped with limit() — a string; blank is not set, so Other applies. |
| `trend_drivers` | mysql, mariadb, pgsql, sqlite | — | Maps a database driver to the QueryExpression that builds trend date-grouping SQL; every entry must name a QueryExpression class. |

Every key is read strictly and throws RoundlyConsulting\\Metrics\\Exceptions\\InvalidConfigurationException naming it when present but unusable; a key that is not set — absent, null or blank (a host’s KEY=) — takes its default. default\_range must be a Period value (ALL, TODAY, 30, …) and default\_unit a Unit value (MINUTE … YEAR, exact case); precision must be an integer (digit strings accepted); timezone, cache.store, cache.prefix and partition.other\_label must be strings; every trend\_drivers entry must name a QueryExpression class. A typo is never silently ignored.

## Defaults applied to every metric

default\_range, default\_unit and precision are read in the metric constructor, before setup() runs — so anything you set in setup() or through a fluent call overrides them:

```php
// config/metrics.php
'default_range' => 'MTD',   // every metric defaults to month-to-date
'default_unit' => 'WEEK',   // trends bucket weekly unless told otherwise
'precision' => 2,           // values round to 2 decimals
```

## Environment

The reporting timezone and the cache switches are env-driven:

```bash
METRICS_TIMEZONE=Europe/Bratislava
METRICS_CACHE_ENABLED=true
METRICS_CACHE_STORE=redis
```

## Show your open-source love

This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.

[More ways to support, including crypto](https://roundly-consulting.com/support-us.md)

By donating, you agree to our [donation terms](https://roundly-consulting.com/donation-terms.md).

[Support our open source work (opens in a new tab)](https://donate.stripe.com/dRmeVe8FX5PF1Qd9pXcEw00) [Join us on Patreon (opens in a new tab)](https://www.patreon.com/cw/roundly)

## Want this built into your product?

We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.

[Get a quote in 48 hours](https://roundly-consulting.com/contact.md) [Browse all packages](https://roundly-consulting.com/open-source/docs/metrics-for-laravel.md)
