Druid Php Save

Druid driver for PHP

Project README

Druid PHP driver

This library provider a Druid PHP Driver.



Installation of this library uses composer. For composer documentation, please refer to getcomposer.org.

Put the following into your composer.json

    "require": {
        "pixelfederation/druid-php": "dev-master"

Current State

Currently this driver supports GroupBy, TopN and Timeseries aggregation types, and Search query type. Everybody is welcome to create pull requests to implement some of the missing things.

Also, some unit tests are bound to running on our internal Druid instance, there is plan to change it to docker container with some testing data.


Average aggregation


use Druid\Druid;
use Druid\Driver\Guzzle\Driver;
use Druid\Query\AbstractQuery;
use Druid\Query\Component\Granularity\PeriodGranularity;

$druid = new Druid(
    new Driver(),
        'scheme' => 'http',
        'host' => 'localhost',
        'port' => '9999',
        'path' => '/druid/v2',
        'proxy' => 'tcp://', // default null
        'timeout' => 3.7, // in seconds - default null

$queryBuilder = $druid->createQueryBuilder(AbstractQuery::TYPE_GROUP_BY); // or AbstractQuery::TYPE_TIMESERIES

$queryBuilder->addInterval(new \DateTime('2000-01-01'), new \DateTime());

$granularity = new PeriodGranularity('P1D', 'UTC');

$queryBuilder->addAggregator($queryBuilder->aggregator()->doubleSum('sum_rows', 'event_count_metric'));
$queryBuilder->addAggregator($queryBuilder->aggregator()->hyperUnique('registrations', 'registrations'));

// Only include for GroupBy queries
$queryBuilder->addDimension('project', 'project');

            $queryBuilder->postAggregator()->fieldAccessPostAggregator('sum_rows', 'sum_rows'),
            $queryBuilder->postAggregator()->fieldAccessPostAggregator('count_rows', 'count_rows')

$response = $druid->send($queryBuilder->getQuery());


If you'd like to contribtue, we strongly recommend to run


from the project directory. This script will set up a commit hook, which checks the PSR/2 coding standards using PHPCS and also runs PHP linter and PHP Mess Detector PHPMD


  1. Query types
    • Metadata Queries
      • Time Boundary
      • Segment Metadata
      • Datasource Metadata
  2. Components
    • Data source
      • query
    • Aggregations
      • Cardinality aggregator
Open Source Agenda is not affiliated with "Druid Php" Project. README Source: pixelfederation/druid-php
Open Issues
Last Commit
6 years ago

Open Source Agenda Badge

Open Source Agenda Rating