gh05tpl/messenger-prometheus-bundle

Symfony bundle exposing Messenger worker metrics for Prometheus.

Maintainers

Package info

github.com/Gh05t-PL/messenger-prometheus-bundle

Homepage

Issues

Type:symfony-bundle

pkg:composer/gh05tpl/messenger-prometheus-bundle

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

dev-main 2026-06-12 06:27 UTC

This package is auto-updated.

Last update: 2026-06-12 06:59:10 UTC


README

Symfony bundle exposing Messenger worker metrics for Prometheus.

It integrates with artprima/prometheus-metrics-bundle and increments counters when Symfony Messenger workers receive, handle, fail, or retry messages.

Installation

composer require gh05tpl/messenger-prometheus-bundle

If your application does not use Symfony Flex auto-registration, enable both bundles manually:

// config/bundles.php

return [
    Artprima\PrometheusMetricsBundle\ArtprimaPrometheusMetricsBundle::class => ['all' => true],
    Gh05tPL\MessengerPrometheusBundle\Gh05tPLMessengerPrometheusBundle::class => ['all' => true],
];

Configure Prometheus Metrics Bundle

For Messenger worker metrics, use shared storage so the worker process and the HTTP process exposing metrics can see the same counters. Redis is the safest default.

# config/packages/artprima_prometheus_metrics.yaml
artprima_prometheus_metrics:
  namespace: app
  storage:
    type: redis
    host: '%env(default:redis:REDIS_HOST)%'
    port: '%env(int:default:6379:REDIS_PORT)%'
    prefix: app_prometheus

For a quick local smoke test only, you can use in-memory storage:

# config/packages/artprima_prometheus_metrics.yaml
artprima_prometheus_metrics:
  namespace: app
  storage:
    type: in_memory

In-memory storage is not recommended for real Messenger worker metrics because workers and web requests usually run in different PHP processes.

Expose Metrics Endpoint

Import the route provided by artprima/prometheus-metrics-bundle:

# config/routes/prometheus.yaml
prometheus_metrics:
  resource: '@ArtprimaPrometheusMetricsBundle/Resources/config/routing.yaml'

The endpoint is available at:

/metrics/prometheus

Point Prometheus at that endpoint, for example:

scrape_configs:
  - job_name: symfony
    metrics_path: /metrics/prometheus
    static_configs:
      - targets:
          - app.example.com

Run Messenger Workers

No extra code is required. Once the bundle is enabled, it subscribes to Symfony Messenger worker events automatically.

php bin/console messenger:consume async -vv

The bundle records these counters:

app_messenger_worker_messages_total{event,message_class,receiver_name}
app_messenger_worker_failures_total{message_class,receiver_name,exception_class,will_retry}

The event label can be one of:

received
handled
failed
retried

The metric prefix comes from artprima_prometheus_metrics.namespace. If you set namespace: my_app, the counters will be named:

my_app_messenger_worker_messages_total
my_app_messenger_worker_failures_total

Development

This repository includes a Docker-based development environment.

make build
make install
make test
make validate