PHP Graphite feeder

Graphite Data Feeder is a library that collects and aggregates metric values and then sends batches of data directly to the Graphite data port.

The library acts like a daemon witch collects the data points and aggregates them. After the raw data was received and aggregated, the results are sent to the graphite data port (carbon relay daemon). The carbon relay will not alter the data points because they were already aggregated by the same retention settings.
graphite aggregator

How to install PHP Graphite feeder

composer require gavrila/graphite-feeder


Basic usage

Get the Carbon retention settings for your metric (Read more about Carbon storage schema here). Retentions are set in the file graphite/storage-schemas.conf and should look like this:

pattern = .*
retentions = 10s:7d
pattern = test.stats.process_name.elapsed_time
retentions = 15s:7d,1m:21d,15m:5y

Create a GraphiteFeeder client and then add data to its buffer.

Buffers will be created automatically according the retention settings. When you add metrics, the library will send the data to the corresponding buffer.

Each Buffer coresponds to a retention (Eg. : 15s:7d,1m:21d,15m:5y will generate three buffers).

Buffers will aggregate the data points continuously based on  resolution (Eg. 1m:21d means that will aggregate data at 1 minute intervals/resolutions). All data points should be ordered, older data should be added first !. Older intervals will be aggregated first, and the aggregation process will occurs when a new data point that belongs to the next interval is received .

You can make intermediary flushes if you are sure that all data from a custom period/buffer was added to the client.

use  Gavrila\GraphiteFeeder;
$retentions = '15s:7d,1m:21d,15m:5y';

$connector = new GraphiteFeeder\Connector\Fsock(

$client = new GraphiteFeeder\Client($connector, $retentions);

$data = [
    new GraphiteFeeder\Entity\Data(
    new GraphiteFeeder\Entity\Data(

foreach ($data as $item) {
$written = $client->flushAllData();