Skip to content

Laravel Configuration

Complete reference for all Laravel SDK configuration options.

Configuration File

After installation, the configuration file is located at config/nadi.php.

Environment Variables

VariableDescriptionDefault
NADI_ENABLEDEnable/disable Naditrue
NADI_DRIVERTransport driverlog
NADI_ENDPOINTAPI endpointhttps://nadi.pro/api/
NADI_STORAGE_PATHLog file directorystorage/nadi
NADI_SAMPLING_STRATEGYSampling strategyfixed_rate
NADI_SAMPLING_RATEFixed sampling rate0.1

Transport Drivers

Nadi supports three transport methods:

Writes monitoring data to local JSON files. The shipper binary forwards files to the Nadi API.

env
NADI_DRIVER=log
NADI_STORAGE_PATH=storage/nadi

HTTP Driver

Sends data directly to the Nadi API over HTTP. This is an alternative to the recommended log + Shipper approach.

env
NADI_DRIVER=http
NADI_API_KEY=your-sanctum-token
NADI_APP_KEY=your-application-key
NADI_ENDPOINT=https://nadi.pro/api/

HTTP Driver Only

NADI_API_KEY and NADI_APP_KEY in .env are only needed when using the HTTP driver. For the recommended log driver, credentials are configured in nadi.yaml for the Shipper agent.

OpenTelemetry Driver

Exports data using OpenTelemetry Protocol (OTLP).

env
NADI_DRIVER=opentelemetry
NADI_OTEL_ENDPOINT=http://localhost:4318
NADI_OTEL_SERVICE_NAME=my-app

Full Configuration Reference

php
<?php

return [
    /*
    |--------------------------------------------------------------------------
    | Enabled
    |--------------------------------------------------------------------------
    */
    'enabled' => env('NADI_ENABLED', true),

    /*
    |--------------------------------------------------------------------------
    | Driver
    |--------------------------------------------------------------------------
    |
    | Transport method: log, http, opentelemetry
    |
    */
    'driver' => env('NADI_DRIVER', 'log'),

    /*
    |--------------------------------------------------------------------------
    | Connections
    |--------------------------------------------------------------------------
    */
    'connections' => [
        'log' => [
            'path' => env('NADI_STORAGE_PATH', storage_path('nadi/')),
        ],
        'http' => [
            'apiKey' => env('NADI_API_KEY'),
            'appKey' => env('NADI_APP_KEY'),
            'endpoint' => env('NADI_ENDPOINT', 'https://nadi.pro/api/'),
            'version' => env('NADI_API_VERSION', 'v1'),
        ],
        'opentelemetry' => [
            'endpoint' => env('NADI_OTEL_ENDPOINT', 'http://localhost:4318'),
            'service_name' => env('NADI_OTEL_SERVICE_NAME', config('app.name')),
            'service_version' => env('NADI_OTEL_SERVICE_VERSION', '1.0.0'),
            'protocol' => env('NADI_OTEL_PROTOCOL', 'http/protobuf'),
        ],
    ],

    /*
    |--------------------------------------------------------------------------
    | Event Observation
    |--------------------------------------------------------------------------
    */
    'observe' => [
        \Illuminate\Log\Events\MessageLogged::class => [
            \Nadi\Laravel\Handler\HandleExceptionEvent::class,
        ],
        \Illuminate\Database\Events\QueryExecuted::class => [
            \Nadi\Laravel\Handler\HandleQueryExecutedEvent::class,
        ],
        \Illuminate\Queue\Events\JobFailed::class => [
            \Nadi\Laravel\Handler\HandleFailedJobEvent::class,
        ],
        \Illuminate\Foundation\Http\Events\RequestHandled::class => [
            \Nadi\Laravel\Handler\HandleHttpRequestEvent::class,
        ],
    ],

    /*
    |--------------------------------------------------------------------------
    | Query Monitoring
    |--------------------------------------------------------------------------
    */
    'query' => [
        'slow-threshold' => env('NADI_QUERY_SLOW_THRESHOLD', 500), // milliseconds
    ],

    /*
    |--------------------------------------------------------------------------
    | HTTP Request Filtering
    |--------------------------------------------------------------------------
    */
    'http' => [
        'hidden_request_headers' => [
            'authorization',
            'php-auth-pw',
        ],
        'hidden_parameters' => [
            'password',
            'password_confirmation',
        ],
        'ignored_status_codes' => [
            100, 101, 102, 103,
            200, 201, 202, 203, 204, 205, 206, 207,
            300, 302, 303, 304, 305, 306, 307, 308,
        ],
    ],

    /*
    |--------------------------------------------------------------------------
    | Sampling
    |--------------------------------------------------------------------------
    */
    'sampling' => [
        'strategy' => env('NADI_SAMPLING_STRATEGY', 'fixed_rate'),
        'config' => [
            'sampling_rate' => env('NADI_SAMPLING_RATE', 0.1),
            'base_rate' => env('NADI_SAMPLING_BASE_RATE', 0.05),
            'load_factor' => env('NADI_SAMPLING_LOAD_FACTOR', 1.0),
            'interval_seconds' => env('NADI_SAMPLING_INTERVAL_SECONDS', 60),
        ],
        'strategies' => [
            'dynamic_rate' => \Nadi\Sampling\DynamicRateSampling::class,
            'fixed_rate' => \Nadi\Sampling\FixedRateSampling::class,
            'interval' => \Nadi\Sampling\IntervalSampling::class,
            'peak_load' => \Nadi\Sampling\PeakLoadSampling::class,
        ],
    ],
];

Shipper Configuration

The shipper configuration file is located at storage/nadi/nadi.yaml. This file is created during installation.

Manual Configuration

If you skipped credentials during installation, update storage/nadi/nadi.yaml:

yaml
nadi:
  # Nadi API Endpoint
  endpoint: https://nadi.pro/api/

  # Your Nadi API key
  apiKey: your-api-key-here

  # Your application key
  appKey: your-app-key-here

  # Path to the log directory (must match SDK's storage_path)
  storage: /path/to/project/storage/nadi

  # Tracker file for tracking sent logs
  trackerFile: tracker.json

Shipper Options

OptionDescriptionDefault
endpointNadi API endpointhttps://nadi.pro/api/
apiKeyAPI authentication key-
appKeyApplication identifier-
storageDirectory to monitor for log files/var/log/nadi
checkIntervalHow often to check for new files5s
maxTriesMaximum retry attempts3
timeoutRequest timeout1m
workersConcurrent workers4
compressEnable gzip compressionfalse

Environment-Specific Configuration

Development

env
NADI_ENABLED=false
# Or enable with full capture
NADI_ENABLED=true
NADI_DRIVER=log
NADI_SAMPLING_RATE=1.0

Staging

env
NADI_ENABLED=true
NADI_DRIVER=log
NADI_SAMPLING_RATE=1.0

Production

env
NADI_ENABLED=true
NADI_DRIVER=log
NADI_SAMPLING_STRATEGY=fixed_rate
NADI_SAMPLING_RATE=0.1

Testing Configuration

Test the API connection:

bash
php artisan nadi:test

This command sends a test request to the Nadi API to confirm your API Key is valid and the connection is working.

Verify the App Key:

bash
php artisan nadi:verify

This command validates your App Key is correctly configured and recognized by Nadi.

Next Steps

Released under the MIT License.