PHPackages                             jmonitor/jmonitor-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. jmonitor/jmonitor-bundle

ActiveSymfony-bundle[Database &amp; ORM](/categories/database)

jmonitor/jmonitor-bundle
========================

Symfony bundle to collect server metrics (PHP, MySQL, PostgreSQL, Redis, Apache, Nginx, Caddy) and send them to jmonitor.io.

v1.4.0(1mo ago)11.9k↑90.5%MITPHPPHP ^8.1CI passing

Since Mar 20Pushed 1w agoCompare

[ Source](https://github.com/jmonitor/jmonitor-bundle)[ Packagist](https://packagist.org/packages/jmonitor/jmonitor-bundle)[ Docs](https://jmonitor.io)[ RSS](/packages/jmonitor-jmonitor-bundle/feed)WikiDiscussions 1.x Synced 2d ago

READMEChangelog (6)Dependencies (30)Versions (11)Used By (0)

Jmonitor Bundle
===============

[](#jmonitor-bundle)

### Simple monitoring for PHP &amp; Symfony stacks

[](#simple-monitoring-for-php--symfony-stacks)

Jmonitor is a **monitoring service for PHP web stacks**. It collects server and application metrics and turns them into **readable, premade dashboards and alerts**.

This bundle integrates the [*jmonitor/collector*](https://github.com/jmonitor/collector) PHP library into **Symfony**.
It ships a **Symfony-specific collector** and a **console command** that runs the collectors in a **long-lived PHP worker process**.

[![Packagist Version](https://camo.githubusercontent.com/7eeb4ce8c7f577a698f4cf5d5bcdfe0de4357062e1a7477c6a01cfd5703b850b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a6d6f6e69746f722f6a6d6f6e69746f722d62756e646c653f7374796c653d666c61742d737175617265)](https://packagist.org/packages/jmonitor/jmonitor-bundle)[![Tests](https://camo.githubusercontent.com/485db6c1c44a14d92fbda23c1e4a09079462b7286230d863538a3c9d43a33125/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6a6d6f6e69746f722f6a6d6f6e69746f722d62756e646c652f74657374732e796d6c3f6272616e63683d312e78266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/jmonitor/jmonitor-bundle/actions)[![License](https://camo.githubusercontent.com/3767978ef4d37d1331120bc84e7c7c401157c4a5f61c6da738bbab84e5550259/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6a6d6f6e69746f722f6a6d6f6e69746f722d62756e646c653f7374796c653d666c61742d737175617265)](LICENSE)[![Last Commit](https://camo.githubusercontent.com/6015b44a12888ceb4aa2c1b964a05b327fdf273334bd8a51bd82f4740ecd8b70/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6173742d636f6d6d69742f6a6d6f6e69746f722f6a6d6f6e69746f722d62756e646c653f7374796c653d666c61742d737175617265)](https://github.com/jmonitor/jmonitor-bundle/commits)

[**https://jmonitor.io**](https://jmonitor.io)

[![Jmonitor symfony dashboard](.github/assets/hero-dashboard.png)](.github/assets/hero-dashboard.png)

Supported components
--------------------

[](#supported-components)

CategoryComponentsRuntime[![PHP](https://camo.githubusercontent.com/cd416bc64c2939adf96d88a43d33b32b520e9273e25d3897fd48164f23fc42d5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d3737374242343f7374796c653d666c61742d737175617265266c6f676f3d706870266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/cd416bc64c2939adf96d88a43d33b32b520e9273e25d3897fd48164f23fc42d5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d3737374242343f7374796c653d666c61742d737175617265266c6f676f3d706870266c6f676f436f6c6f723d7768697465) [![FrankenPHP](https://camo.githubusercontent.com/70bae5a1e9015b7d1f229d91250afdac16da34d8376b5f918507136fcc7a6572/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4672616e6b656e5048502d3434343434343f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/70bae5a1e9015b7d1f229d91250afdac16da34d8376b5f918507136fcc7a6572/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4672616e6b656e5048502d3434343434343f7374796c653d666c61742d737175617265)Framework[![Symfony](https://camo.githubusercontent.com/d7ef2eec22d3acd2a4548041b9a9a9db5ceba221b0e98010710396e68f0ccd35/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53796d666f6e792d3030303030303f7374796c653d666c61742d737175617265266c6f676f3d73796d666f6e79266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/d7ef2eec22d3acd2a4548041b9a9a9db5ceba221b0e98010710396e68f0ccd35/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53796d666f6e792d3030303030303f7374796c653d666c61742d737175617265266c6f676f3d73796d666f6e79266c6f676f436f6c6f723d7768697465)Web servers[![Apache](https://camo.githubusercontent.com/aa95cc8e2d42568971ea9738092c1f8c2cc293152659867173953aa98c58ffde/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4170616368652d4432323132383f7374796c653d666c61742d737175617265266c6f676f3d617061636865266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/aa95cc8e2d42568971ea9738092c1f8c2cc293152659867173953aa98c58ffde/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4170616368652d4432323132383f7374796c653d666c61742d737175617265266c6f676f3d617061636865266c6f676f436f6c6f723d7768697465) [![Nginx](https://camo.githubusercontent.com/ec80f452ca8fcdadc211dfcf3aa7a77bc0b2929679b74033d6e751a6a839c6ba/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4e67696e782d3030393633393f7374796c653d666c61742d737175617265266c6f676f3d6e67696e78266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/ec80f452ca8fcdadc211dfcf3aa7a77bc0b2929679b74033d6e751a6a839c6ba/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4e67696e782d3030393633393f7374796c653d666c61742d737175617265266c6f676f3d6e67696e78266c6f676f436f6c6f723d7768697465) [![Caddy](https://camo.githubusercontent.com/ff05360a62a9b889e2c08714f37f94da165f6c4780aeb5de612081a42ccc1560/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f43616464792d3146383843303f7374796c653d666c61742d737175617265266c6f676f3d6361646479266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/ff05360a62a9b889e2c08714f37f94da165f6c4780aeb5de612081a42ccc1560/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f43616464792d3146383843303f7374796c653d666c61742d737175617265266c6f676f3d6361646479266c6f676f436f6c6f723d7768697465)Databases &amp; cache[![MySQL](https://camo.githubusercontent.com/c49132f37ac3f2f1b7c9a8fa2352e3f5874c6393039371b6fa4c9f405a7d8c94/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4d7953514c2d3434373941313f7374796c653d666c61742d737175617265266c6f676f3d6d7973716c266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/c49132f37ac3f2f1b7c9a8fa2352e3f5874c6393039371b6fa4c9f405a7d8c94/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4d7953514c2d3434373941313f7374796c653d666c61742d737175617265266c6f676f3d6d7973716c266c6f676f436f6c6f723d7768697465) [![PostgreSQL](https://camo.githubusercontent.com/846c4b3a2b443fb600a2ea333b76fe1802d763ce2f598c48e480eea57acbe1d7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f506f737467726553514c2d3431363945313f7374796c653d666c61742d737175617265266c6f676f3d706f737467726573716c266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/846c4b3a2b443fb600a2ea333b76fe1802d763ce2f598c48e480eea57acbe1d7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f506f737467726553514c2d3431363945313f7374796c653d666c61742d737175617265266c6f676f3d706f737467726573716c266c6f676f436f6c6f723d7768697465) [![Redis](https://camo.githubusercontent.com/fc6217c33fd96cb661479aa6c24181c1c66dcb0c8038212c5ce40622602b3d6e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f52656469732d4646343433383f7374796c653d666c61742d737175617265266c6f676f3d7265646973266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/fc6217c33fd96cb661479aa6c24181c1c66dcb0c8038212c5ce40622602b3d6e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f52656469732d4646343433383f7374796c653d666c61742d737175617265266c6f676f3d7265646973266c6f676f436f6c6f723d7768697465)System[![Linux](https://camo.githubusercontent.com/0b365552cd3bb51ca3c1d46962eda39e19244def29cd3d287f3045e4350957c6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f43505525323025433225423725323052414d2532302543322542372532304469736b2d4643433632343f7374796c653d666c61742d737175617265266c6f676f3d6c696e7578266c6f676f436f6c6f723d626c61636b)](https://camo.githubusercontent.com/0b365552cd3bb51ca3c1d46962eda39e19244def29cd3d287f3045e4350957c6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f43505525323025433225423725323052414d2532302543322542372532304469736b2d4643433632343f7374796c653d666c61742d737175617265266c6f676f3d6c696e7578266c6f676f436f6c6f723d626c61636b)Requirements
------------

[](#requirements)

- [![PHP Version](https://camo.githubusercontent.com/eccd48e4a484ac16e80cc3c25a4d18d92e4bd89a095cc5516e32d03bf143d6ca/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6a6d6f6e69746f722f6a6d6f6e69746f722d62756e646c653f7374796c653d666c61742d737175617265266c6162656c3d504850)](https://packagist.org/packages/jmonitor/jmonitor-bundle)
- [![Symfony Version](https://camo.githubusercontent.com/62985d4c630a0b43c96ed003dea0437e4fa002d2ac93d2f63adb229b8e537d7b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f6a6d6f6e69746f722f6a6d6f6e69746f722d62756e646c652f73796d666f6e792532466672616d65776f726b2d62756e646c653f7374796c653d666c61742d737175617265266c6162656c3d53796d666f6e79)](https://packagist.org/packages/jmonitor/jmonitor-bundle)

Quick Start
-----------

[](#quick-start)

1. Install the bundle:

```
composer require jmonitor/jmonitor-bundle
```

2. Create a project on  and copy your Project API key.
3. Configure your API key and collectors.

```
# .env
JMONITOR_API_KEY=
```

```
# .env.prod
JMONITOR_API_KEY=your_api_key
```

```
# config/packages/jmonitor.yaml
jmonitor:
    # project_api_key can be empty to disable sending data to Jmonitor
    # useful for testing purposes in non-production environments
    project_api_key: '%env(JMONITOR_API_KEY)%'

when@prod:
    jmonitor:
        # Optional (recommended): use a specific logger service (Symfony's default is "logger").
        # See "Debugging" section below for more information.
        logger: 'logger'

        # Optional: provide a custom HTTP client service
        # http_client: 'http_client'

        # Enable the collectors you want to use (remove the unused ones).
        # Refer to the collector library for deeper collector-specific doc: https://github.com/jmonitor/collector
        collectors:
            # Cpu, Ram, Disk... Linux only.

            # You can use a RandomAdapter on Windows for testing purpose.
            # system:
            #     adapter: 'Jmonitor\\Collector\\System\\Adapter\\RandomAdapter'
            system: ~

            # Apache via mod_status module.
            # for more information, see https://github.com/jmonitor/collector?tab=readme-ov-file#apache
            apache:
                server_status_url: 'http://localhost/server-status'

            # Nginx via stub_status module.
            # for more information, see https://github.com/jmonitor/collector?tab=readme-ov-file#nginx
            nginx:
                endpoint: 'http://localhost/nginx_status'

            # MySQL - multiple sub-collectors available : status, variables, slow_queries, information_schema
            # all sub-collectors are enabled by default, disable some of them by setting them to false
            # Queries run through a Doctrine DBAL connection (default: doctrine.dbal.default_connection).
            # SlowQueries collector is configurable:
            # mysql:
            #     db_name: 'your_db_name'
            #     connection: 'doctrine.dbal.default_connection' # Doctrine DBAL connection service id
            #     slow_queries:
            #         limit: 5 # Maximum number of results to return (1-10)
            #         min_exec_count: 1 # Minimum number of executions required to include a query
            #         min_avg_time_ms: 0 # Minimum average execution time in ms for a query to be included.
            #         order_by: 'avg' # Allowed values: sum, avg, max
            mysql:
                db_name: 'your_db_name'

            # PostgreSQL - multiple sub-collectors available : activity, settings, database, slow_queries
            # all sub-collectors are enabled by default, disable some of them by setting them to false.
            # Queries run through a Doctrine DBAL connection (default: doctrine.dbal.default_connection).
            # The slow_queries sub-collector relies on the pg_stat_statements extension.
            # postgresql:
            #     connection: 'doctrine.dbal.default_connection' # Doctrine DBAL connection service id
            #     schema: 'public'                               # schema inspected by the database sub-collector
            #     slow_queries:
            #         limit: 5                  # Maximum number of results to return (1-10)
            #         min_exec_count: 1         # Minimum number of executions (calls) required to include a query
            #         min_avg_time_ms: 0        # Minimum mean execution time in ms for a query to be included
            #         order_by: 'avg'           # Allowed values: avg, total, max
            #         auto_create_extension: false # CREATE EXTENSION IF NOT EXISTS pg_stat_statements when missing
            postgresql:
                connection: 'doctrine.dbal.default_connection'

            # PHP : some ini keys, apcu, opcache, loaded extensions...
            # /!\ See below for more informations about CLI vs Web-context metrics
            # CLI only:
            # php: ~
            # web metrics:
            php:
                endpoint: 'http://localhost/jmonitor/php-metrics'

            # symfony: some infos, loaded bundles, flex recipes, schedules...
            # Components are auto-detected based on installed packages.
            # You can disable a component by setting it to false, or configure it:
            # symfony:
            #     flex: false       # disable
            #     scheduler: false  # disable
            #     messenger: false  # disable
            #
            #     flex:
            #         command: "composer.phar recipes -o"  # default: "composer recipes -o"
            #         timeout: 10                          # default: 5 (seconds)
            #     Note: flex recipes are checked once per day and cached for the rest of the worker process lifetime.
            #
            #     messenger:
            #         command: "php bin/console messenger:stats --format=json"  # default: auto
            #         timeout: 5                                                # default: 3 (seconds)
            symfony: ~

            # Redis metrics via INFO command
            # you can use either DSN or a service name (adapter).
            # redis:
            #     dsn: '%env(SOME_REDIS_DSN)%'
            #     adapter: 'some_redis_service_name'
            redis:

            # Metrics from Caddy / FrankenPHP
            # see https://caddyserver.com/docs/metrics and https://frankenphp.dev/docs/metrics/
            caddy:
                endpoint: 'http://localhost:2019/metrics'
                frankenphp: true # default is false
```

4. Run a collection manually to verify. It may be easier to do this in the production environment, since configuring the bundle (or certain collectors) in development is not always possible.

```
php bin/console jmonitor:collect -vvv --dry-run
```

PHP metrics: CLI vs Web context
-------------------------------

[](#php-metrics-cli-vs-web-context)

- PHP settings and extensions can differ significantly between CLI and your web server context.
- If you want metrics that reflect your web runtime, you must expose a tiny HTTP endpoint that returns PHP metrics from within that web context.

To do that, create a route config file:

```
# config/routes/jmonitor.yaml
jmonitor_expose_php_metrics:
    path: '/jmonitor/php-metrics'
    controller: Jmonitor\JmonitorBundle\Controller\JmonitorPhpController

# Secured route in production with localhost host restriction
# Refer to symfony docs for more information about security
when@prod:
    jmonitor_expose_php_metrics:
        path: '/jmonitor/php-metrics'
        controller: Jmonitor\JmonitorBundle\Controller\JmonitorPhpController
        host: localhost
```

Set up a firewall for this route **before** the main firewall to prevent your app from interfering with it:

```
# config/packages/security.yaml
security:
    firewalls:
        jmonitor:
            pattern: ^/jmonitor/php-metrics$
            security: false
            # instead of disabling security, you can use a stateless firewall if you plan to use ip security or something
            # stateless: true
        main:
        # ...
```

Wire it in your bundle config

```
# config/packages/jmonitor.yaml
jmonitor:
    # ...
    collectors:
        php:
            endpoint: 'http://localhost/jmonitor/php-metrics'
```

Running the collector
---------------------

[](#running-the-collector)

```
php bin/console jmonitor:collect [-vv|-vvv] [--dry-run]
```

This command runs as a long-lived worker: it periodically collects metrics from the enabled collectors and sends them to Jmonitor.io.

You can also limit how long it runs:

- `--memory-limit`: stop when the process memory usage exceeds the given limit (e.g. `128M`)
- `--time-limit`: stop after the given number of seconds

    ```
    php bin/console jmonitor:collect --vv --memory-limit=32M --time-limit=3600
    ```

You can pass a collector name as an argument to run only that collector — useful for debugging a specific integration:

```
php bin/console jmonitor:collect mysql -vvv --dry-run
```

In production, it is recommended to run this command under a process manager (e.g. Supervisor or systemd) to ensure it is kept running and restarted if necessary. For practical guidance, you can follow Symfony Messenger's recommendations:

Logging and Debugging
---------------------

[](#logging-and-debugging)

- The command is resilient: individual collector failures do not crash the whole run; errors are logged (logging must be enabled in config).
- Symfony component collectors (flex, scheduler, messenger) that fail at worker startup are disabled for the lifetime of that worker process and an error is logged. Restart the worker to re-enable them.
- Log levels:
    - Errors (collector exceptions, HTTP responses with status &gt;= 400): error
    - Collected metrics: debug
    - Summary: info

Useful commands:

```
# Verbose with debug logs
php bin/console jmonitor:collect -vvv

# Dry-run (collect but do not send)
php bin/console jmonitor:collect -vvv --dry-run

# Only summary
php bin/console jmonitor:collect -vv
```

Troubleshooting
---------------

[](#troubleshooting)

### Apache

[](#apache)

> mod\_status is enabled, but my endpoint is not reachable.

Don't forget to let the request pass through your index.php.
For example, if you use .htaccess :

```
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !=/server-status
