PHPackages                             troopers/metrics-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. [Logging &amp; Monitoring](/categories/logging)
4. /
5. troopers/metrics-bundle

AbandonedSymfony-bundle[Logging &amp; Monitoring](/categories/logging)

troopers/metrics-bundle
=======================

Symfony Bundle for Metrics management

1.2.3(8y ago)98.7k4MITPHPPHP &gt;=5.3.2

Since Jul 26Pushed 8y ago3 watchersCompare

[ Source](https://github.com/troopers/metricsbundle)[ Packagist](https://packagist.org/packages/troopers/metrics-bundle)[ Docs](http://www.doctrine-project.org)[ RSS](/packages/troopers-metrics-bundle/feed)WikiDiscussions master Synced today

READMEChangelog (3)Dependencies (5)Versions (10)Used By (0)

[![Troopers](https://cloud.githubusercontent.com/assets/618536/18787530/83cf424e-81a3-11e6-8f66-cde3ec5fa82a.png)](http://troopers.agency/?utm_source=MetricsBundle&utm_medium=github&utm_campaign=OpenSource)

[![License](https://camo.githubusercontent.com/a5f629d19f38120f200a9a1ff16c8e09b111bbe6858a62cf47405dd575c4d87e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f74726f6f706572732f6d6574726963732d62756e646c652e737667)](https://packagist.org/packages/troopers/metrics-bundle)[![Version](https://camo.githubusercontent.com/9e439d0c9401cbe28d5d209df9cb1c411be1a6d33c96cb20d8d06b501bd0c713/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f74726f6f706572732f6d6574726963732d62756e646c652e737667)](https://packagist.org/packages/troopers/metrics-bundle)[![Packagist DL](https://camo.githubusercontent.com/d1af6fa3bc73805b86011939263c73cf087f1f1e4ccad375742a52d8c95a382f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f74726f6f706572732f6d6574726963732d62756e646c652e737667)](https://packagist.org/packages/troopers/metrics-bundle)[![Build Status](https://camo.githubusercontent.com/e06461b1d978e14674736a6f17befdde4bc8e4e462bdd31367b0f1f7c5f404b5/68747470733a2f2f7472617669732d63692e6f72672f54726f6f706572732f4d65747269637342756e646c652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Troopers/MetricsBundle)[![SensioLabsInsight](https://camo.githubusercontent.com/b75629f40ac247dd8e2034f709e4ea2158a0ea27a7cd5582ae7571af6b02c9b3/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f31313331373162322d653764312d343265612d383664342d6130376265316334363862632f6d696e692e706e67)](https://insight.sensiolabs.com/projects/113171b2-e7d1-42ea-86d4-a07be1c468bc)[![Twitter Follow](https://camo.githubusercontent.com/59166962fed540cd620e598de1fd574503100e00b4bd601804f7ae222378f173/68747470733a2f2f696d672e736869656c64732e696f2f747769747465722f666f6c6c6f772f74726f6f706572736167656e63792e7376673f7374796c653d736f6369616c266c6162656c3d466f6c6c6f7725323054726f6f70657273)](https://twitter.com/troopersagency)

MetricsBundle
=============

[](#metricsbundle)

Synopsis
--------

[](#synopsis)

This bundle works with Monolog and is used to improve monitoring or metric logging process thanks to ELK (Elasticsearch, Logstash, Kibana).

Install
-------

[](#install)

`composer require troopers/metrics-bundle` and registrer in AppKernel

```
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            ...
            new Troopers\MetricsBundle\MetricsBundle(),
            ...
        );

        return $bundles
```

Be sure some serializer is enabled:

- [Symfony serializer](http://symfony.com/doc/current/cookbook/serializer.html#activating-the-serializer).
- [JMS serializer](http://jmsyst.com/libs/serializer).

Processors
----------

[](#processors)

### UserProcessor

[](#userprocessor)

This processor will automatically add user informations to every log. Among availables informations, we can know if the user is `authenticated` (*authenticated: true/false*), when appropriate his `id` and `username`. Furthermore, this processor will check if you defined some serializer groups in the `metrics.serializer_user_groups` config.

The config below will tell the symfony serializer to serialize the authenticated user by using the profile group:

```
metrics:
    serializer_user_groups:
      - profile
```

By default, this processor, is only available for the `app` channel, you can add an other or ovveride the service declaration to use on other handler or channel.

The results will be prefixed by `user_` (user\_id, user\_city...) and you don't need to give any additional context.

### ContextSerializerProcessor

[](#contextserializerprocessor)

This processor stands for serializing objects in order to avoid you to pass serializer every where you need to log something. To communicate with this processor and tell it to do its job, you'll need to wrap your objects in a `ContextSerializerProcessor`and give them to the contexts like below:

```
$logger->info('a log with some context object', [
    new SerializeContextItem($someObject, ['serializingGroupLambda'], 'myalias'),
    'a_different_simple_context_prop' => 42,
    new SerializeContextItem($anotherOne, ['serializingGroup1', 'serializingGroup2']),
]);
```

The processor'll handle the context and start to work when it'll find your SerializeContextItems and add the serialized objects to the context by using the groups given in 2nd constructor argument. If an alias is given, it will use it to store the property, else it will prefix with the class name.

### AlterDateTimeProcessor

[](#alterdatetimeprocessor)

For some reason, you may want to log an event in the past (or future why not ?). The `AlterDateTimeProcessor` will do it for you, all you need to do is to define the `@datetime` context property with the wanted \\DateTime value.

```
$logger->info('a test in the past', ['@datetime' => new \DateTime('10 days ago')]);
```

By default, this processor, is only available for the `app` channel, you can add an other or ovveride the service declaration to use on other handler or channel.

### DomainProcessor

[](#domainprocessor)

In some case, you need to add some extra information to improve your logs: application name, environment... You can add them in `extra_fields`

```
metrics:
    extra_fields:
        app: 'Acme App'
        env: 'preprod'
```

Only `scalar`values are allowed. (string, integer, boolean, float, null)

This processor also add request Uri when she his defined

By default, this processor is available for all channels.

### GitProcessor

[](#gitprocessor)

This processor try to find git revision with git command or in `REVISION` file at the root of application

By default, this processor is available for all channels.

Log sandbox
-----------

[](#log-sandbox)

Sometime, we just want to send log to test something, this log sandbox to help you to accomplish this small thing.

Check the metrics routes are registered (in your `app/config/routing.yml` or `routing_dev.yml`):

```
MetricsBundle:
    resource: "@MetricsBundle/Controller/"
    type:     annotation
    prefix:   /metrics
```

and go to `/metrics/sandbox/newLog` to get your console: [![Log console sandbox](https://camo.githubusercontent.com/54bf267657e4972d3006b8bbc30ccdc18eb729befb638d7ebf526cf4edf5daf3/687474703a2f2f6e65772e74696e79677261622e636f6d2f3039623636343364376434316364666537626538626163306263376435616332613863306234663731312e706e67)](https://camo.githubusercontent.com/54bf267657e4972d3006b8bbc30ccdc18eb729befb638d7ebf526cf4edf5daf3/687474703a2f2f6e65772e74696e79677261622e636f6d2f3039623636343364376434316364666537626538626163306263376435616332613863306234663731312e706e67)

Dashboard and time filter
-------------------------

[](#dashboard-and-time-filter)

Once you finished to build your dashboard in kibana, you'll be able to get an iframe to embed it in your website. To handle dashboard in your admin with a time filter, add a row in the database like this:

```
INSERT INTO `metrics_dashboard` (`id`, `name`, `url`, `height`, `width`)
VALUES (1, 'base', '', 768, 1200);
```

Then, embed the `MetricsBundle:Dashboard:show` and override (or not) the available blocks:

```
    {% embed 'MetricsBundle:Dashboard:show.html.twig' %}
        {% block body_title %}
            Some thing before the title
            {{ parent() }}
        {% endblock body_title %}
        {# disable the timeFilterForm #}
        {% block body_timeFilterForm %}{% endblock  %}
    {% endembed %}
```

### Time filters

[](#time-filters)

Kibana doesn't integrate its time filter in embed dashboard. The `TimeFilter` and `TimeFilterForm` is here to navigate into dashboards.

Although, TimeFilter is an entity, so you can add some relations between your user and some dashboard.

Here are the available time filters:

- Today
- This week
- This month
- This year
- Yesterday
- Day before yesterday
- Last 15 minutes
- Last 30 minutes
- Last 1 hour
- Last 4 hours
- Last 12 hours
- Last 24 hours
- Last 7 days
- Last 30 days
- Last 60 days
- Last 90 days
- Last 6 months
- Last 1 year
- Last 2 years
- Last 5 years

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 83.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~47 days

Total

9

Last Release

3252d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/bfae4f0954a577921be2539b40a1f1958376f5c7364505e1e238e232ba8066d9?d=identicon)[paulandrieux](/maintainers/paulandrieux)

---

Top Contributors

[![lenybernard](https://avatars.githubusercontent.com/u/618536?v=4)](https://github.com/lenybernard "lenybernard (15 commits)")[![gregumo](https://avatars.githubusercontent.com/u/11725078?v=4)](https://github.com/gregumo "gregumo (2 commits)")[![BFoucher](https://avatars.githubusercontent.com/u/16239924?v=4)](https://github.com/BFoucher "BFoucher (1 commits)")

---

Tags

elkmonologserializersymfonysymfony-bundletrooperselasticsearchMetricsELKlogstash

### Embed Badge

![Health badge](/badges/troopers-metrics-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/troopers-metrics-bundle/health.svg)](https://phpackages.com/packages/troopers-metrics-bundle)
```

###  Alternatives

[2lenet/crudit-bundle

The easy like Crud'it Bundle.

1615.6k12](/packages/2lenet-crudit-bundle)[nulpunkt/monolog-elasticsearch-logstashformat

Use the logstash formatter with elasticsearch

3470.9k](/packages/nulpunkt-monolog-elasticsearch-logstashformat)[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

1175.2k](/packages/rcsofttech-audit-trail-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
