Link Search Menu Expand Document


MadelineProto can expose many useful metrics, that can be visualized using the official MadelineProto Grafana dashboard.

grafana dashboard preview

Getting started

To get started, enable Prometheus stat collection in the MadelineProto settings:

use function Amp\Socket\SocketAddress\fromString;


// You can also enable collection of additional memory profiling metrics.
// Note: you must also set the MEMPROF_PROFILE=1 environment variable or GET parameter.
// $settings->getMetrics()->setEnableMemprofCollection(true);

// Metrics can be returned by an autoconfigured HTTP server.
// Endpoints:
// /metrics - Prometheus metrics
// /debug/pprof - PProf memory profile for pyroscope

// Metrics can also be returned by the current script via web, if called with a specific query string:
// ?metrics - Prometheus metrics
// ?pprof - PProf memory profile for pyroscope
// $settings->getMetrics()->setReturnMetricsFromStartAndLoop(true);

MyEventHandler::startAndLoop('bot.madeline', $settings);

This will expose Prometheus metrics on (if setMetricsBindTo is used) or (if setReturnMetricsFromStartAndLoop is used).

Configuring Grafana

The easiest way to get started using Prometheus and visualizing data via Grafana is by creating a free account on and using the hosted Grafana instance.

During this process, you’ll install the Grafana agent, which will read the metrics either on either or, and push them to

Once your account has been created, you’ll be on your account dashboard. There, you should launch your Grafana instance by clicking the “Launch” button. dashboard

At this point, you’ll be redirected to your Grafana instance. There, you must go to “Connections” and add a new connection of type “Hosted prometheus Metrics”. new connection

When creating a new connection, choose “Via Grafana Agent”. agent.

Next, follow the wizard, install the agent, and create a new config. config.

Follow, the steps to create the config file, and start the agent on your server.

In the scrape_configs key of the config, you should add a job to scrape the /metrics endpoint of your Laravel application. For example:

      scrape_interval: 10s
      - name: hosted-prometheus
            - job_name: MadelineProto
              scrape_interval: 10s
              metrics_path: /metrics
              # metrics_path: /bot.php?metrics
                  - targets:
                    - ''
                    # - ''
            - url: <filled in by the wizard>
                  username: <filled in by the wizard>
                  password: <filled in by the wizard>

Creating a dashboard

Once you’ve configured the agent, you can create a new dashboard. Head over to “Dashboards”, click on “+” and “Import dashboard”.

On the import screen, insert the ID of the MadelineProto dashboard, 21168.


Next, click your hosted prometheus instance as the source. visualization

And you’re done!

grafana dashboard preview

Enjoy detailed MadelineProto metrics, powered by MadelineProto & Grafana!

Next section