Skip to content

PHP Graphite graph DSL to build URL query string for a graph - version 2 (namespaced)

License

Notifications You must be signed in to change notification settings

OndraM/graphite-graph-php

 
 

Repository files navigation

Graphite GraphBuilder

Latest Stable Version Build Status License

GraphBuilder is a DSL and ini-based templating language for PHP to assist in constructing URL query strings for use with Graphite graphs.

This is version 2 of the library (introducing eg. PSR-4 namespaces), based on original version by Bryan Davis.

About

Graphite provides several interfaces for creating graphs and dashboards, but one of its powerful features is an render API for generating graphs and retrieving raw data. This allows easy embedding of graphs in custom dashboards and other applications.

The process of describing complex graphs is however cumbersome at best. GraphBuilder attempts to reduce the complexity of embedding Graphite graphs in PHP based applications by providing a fluent API for describing graphs and a facility for loading full or partial graph descriptions from ini files.

Installation

Install using Composer:

$ composer require ondram/graphite-graph

Examples

<?php

$graphUrl = Graphite\GraphBuilder::builder()
    ->title('Memory')
    ->vtitle('MiB')
    ->width(800)
    ->height(600)
    ->from('-2days')
    ->buildSeries('memory-free')
        ->cactiStyle()
        ->color('green')
        ->alias('Free')
        ->scale(1 / (1024 * 1024)) // B to MiB
        ->build()
    ->build()
    ;

echo '<img src="http://graphite.example.com/render?' . $graphUrl . '">';

For more usage examples see files in examples/ directory.

Credits

Originally written by Bryan Davis with support from Keynetics.

Updated to use PHP namespaces etc. by Ondrej Machulda.

Inspired by https://github.com/ripienaar/graphite-graph-dsl/.

About

PHP Graphite graph DSL to build URL query string for a graph - version 2 (namespaced)

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 79.4%
  • Smarty 16.8%
  • CSS 3.8%