ondram / graphite-graph
Graphite graph DSL to build URL query string for a graph (PSR-4 and PHP7 compatible)
Requires
- php: ^5.5 || ^7.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.0
- phpunit/phpunit: ^4.8
This package is auto-updated.
Last update: 2024-11-24 05:33:29 UTC
README
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/.