{"id":17122910,"url":"https://github.com/algatux/influxdb-bundle","last_synced_at":"2025-08-20T18:33:03.597Z","repository":{"id":56590714,"uuid":"50687578","full_name":"Algatux/influxdb-bundle","owner":"Algatux","description":"Bundle service integration of official influxdb/influxdb-php client","archived":false,"fork":false,"pushed_at":"2024-02-21T09:44:08.000Z","size":252,"stargazers_count":24,"open_issues_count":4,"forks_count":14,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-10T02:10:36.049Z","etag":null,"topics":["bundle","database","influxdb","php","symfony"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Algatux.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.MD","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-01-29T19:55:26.000Z","updated_at":"2024-02-19T17:00:08.000Z","dependencies_parsed_at":"2024-02-19T12:29:50.595Z","dependency_job_id":"175748d3-eb4b-4289-a38d-ac41b67ebe18","html_url":"https://github.com/Algatux/influxdb-bundle","commit_stats":{"total_commits":175,"total_committers":15,"mean_commits":"11.666666666666666","dds":0.6114285714285714,"last_synced_commit":"c357c245daacc798badd646cec81be2e40625271"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Algatux%2Finfluxdb-bundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Algatux%2Finfluxdb-bundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Algatux%2Finfluxdb-bundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Algatux%2Finfluxdb-bundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Algatux","download_url":"https://codeload.github.com/Algatux/influxdb-bundle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230445926,"owners_count":18227060,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bundle","database","influxdb","php","symfony"],"created_at":"2024-10-14T18:24:12.210Z","updated_at":"2024-12-19T14:07:21.626Z","avatar_url":"https://github.com/Algatux.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# influxdb-bundle\n\nBundle service integration of official [influxdb/influxdb-php](https://github.com/influxdata/influxdb-php) client\n\n[![SensioLabsInsight](https://insight.sensiolabs.com/projects/ecdd3130-abb1-4e63-bb92-20c52838aade/mini.png)](https://insight.sensiolabs.com/projects/ecdd3130-abb1-4e63-bb92-20c52838aade)\n\n[![PHP Version](https://img.shields.io/badge/PHP-%5E7.0-blue.svg)](https://img.shields.io/badge/PHP-%5E7.0-blue.svg) [![Latest Stable Version](https://poser.pugx.org/algatux/influxdb-bundle/v/stable)](https://packagist.org/packages/algatux/influxdb-bundle) [![Latest Unstable Version](https://poser.pugx.org/algatux/influxdb-bundle/v/unstable)](https://packagist.org/packages/algatux/influxdb-bundle) [![Dependency Status](https://www.versioneye.com/user/projects/57a33e821dadcb004272cfc0/badge.svg?style=flat-square)](https://www.versioneye.com/user/projects/57a33e821dadcb004272cfc0) [![Total Downloads](https://poser.pugx.org/algatux/influxdb-bundle/downloads)](https://packagist.org/packages/algatux/influxdb-bundle)\n\n[![Build Status](https://travis-ci.com/Algatux/influxdb-bundle.svg?branch=master)](https://travis-ci.com/Algatux/influxdb-bundle) [![StyleCI](https://styleci.io/repos/50687578/shield)](https://styleci.io/repos/50687578) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/Algatux/influxdb-bundle/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/Algatux/influxdb-bundle/?branch=master) [![Code Coverage](https://scrutinizer-ci.com/g/Algatux/influxdb-bundle/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/Algatux/influxdb-bundle/?branch=master)\n[![Coverage Status](https://coveralls.io/repos/github/Algatux/influxdb-bundle/badge.svg?branch=master)](https://coveralls.io/github/Algatux/influxdb-bundle?branch=master) [![License](https://poser.pugx.org/algatux/influxdb-bundle/license)](https://packagist.org/packages/algatux/influxdb-bundle) \n\n### Installation\n\nFirst of all, you need to require this library through composer:\n\n```bash\ncomposer require algatux/influxdb-bundle\n```\n\nThen, enable the bundle on the `AppKernel` class:\n\n```php\n// app/AppKernel.php\n\npublic function registerBundles()\n{\n    $bundles = array(\n        // ...\n        new Algatux\\InfluxDbBundle\\AlgatuxInfluxDbBundle(),\n    );\n\n    // ...\n\n    return $bundles\n}\n```\n\n### Configuration\n\nHere is the configuration reference:\n\n```yaml\nalgatux_influx_db:\n\n    # If not defined, the first connection will be taken.\n    default_connection:   ~\n    connections:\n\n        # Prototype\n        name:\n\n            # Your InfluxDB host address\n            host:                 ~ # Required\n\n            # Your InfluxDB database name\n            database:             ~ # Required\n\n            # Set it to true to activate the UDP connection\n            udp:                  false\n            \n            # Set it to true to enable SSL over HTTP (required for Influx Cloud)\n            ssl:                  false\n            # Set it to true to activate the ssl verification\n            ssl_verification:            false\n            \n            udp_port:             4444\n            http_port:            8086\n            username:             ''\n            password:             ''\n\n            # Setup timeout or connection timeout (seconds) for your requests\n            timeout:              0.0\n            connect_timeout:      0.0\n            \n            # Set it to false to disable the event listener configuration\n            listener_enabled:     true\n\n            # Simple override for the default event listener class (constructor args and methods must match)\n            listener_class:       Algatux\\InfluxDbBundle\\Events\\Listeners\\InfluxDbEventListener\n```\n\nIf you have only one connection to configure, this can be simplified to this:\n\n```yaml\nalgatux_influx_db:\n    # Your InfluxDB host address\n    host:                 ~ # Required\n\n    # Your InfluxDB database name\n    database:             ~ # Required\n\n    # Set it to true to activate the UDP connection\n    udp:                  false\n    \n    # Set it to true to enable SSL over HTTP (required for Influx Cloud)\n    ssl:                  false\n    # Set it to true to activate the ssl verification\n    ssl_verification:     false\n    \n    udp_port:             4444\n    http_port:            8086\n    username:             ''\n    password:             ''\n\n    # Setup timeout or connection timeout (seconds) for your requests\n    timeout:              0.0\n    connect_timeout:      0.0\n            \n    # Set it to false to disable the event listener configuration\n    listener_enabled:     true\n\n    # Simple override for the default event listener class (constructor args and methods must match)\n    listener_class:       Algatux\\InfluxDbBundle\\Events\\Listeners\\InfluxDbEventListener\n```\n\n### Services\n\nYou can directly access to the `InfluxDB\\Database` through UDP or HTTP with those services:\n\n```php\n$httpDatabase = $this-\u003eget('algatux_influx_db.connection.http'); // Default HTTP connection\n$udpDatabase = $this-\u003eget('algatux_influx_db.connection.udp');   // Default UDP connection\n\n// Same as before.\n$httpDatabase = $this-\u003eget('algatux_influx_db.connection.default.http');\n$udpDatabase = $this-\u003eget('algatux_influx_db.connection.default.udp');\n```\n\nYou can also retrieve them thanks to the registry:\n\n```php\n$database = $this-\u003eget('algatux_influx_db.connection_registry')-\u003egetDefaultHttpConnection();\n$database = $this-\u003eget('algatux_influx_db.connection_registry')-\u003egetDefaultUdpConnection();\n\n// Same as before.\n$database = $this-\u003eget('algatux_influx_db.connection_registry')-\u003egetHttpConnection('default');\n$database = $this-\u003eget('algatux_influx_db.connection_registry')-\u003egetUdpConnection('default');\n```\n\nTo manipulate the database, please read the official documentation\nfor [reading](https://github.com/influxdata/influxdb-php#reading)\nand [writing](https://github.com/influxdata/influxdb-php#writing-data).\n\n### Sending data to influx db through events\n\nAssuming this collection to send:\n\n```php\n$time = new \\DateTime();\n\n$points = [new Point(\n    'test_metric', // name of the measurement\n    0.64, // the measurement value\n    ['host' =\u003e 'server01', 'region' =\u003e 'italy'], // optional tags\n    ['cpucount' =\u003e rand(1,100), 'memory' =\u003e memory_get_usage(true)], // optional additional fields\n    $time-\u003egetTimestamp()\n)];\n```\n\nDispatch the event instance according to the chosen writing protocol:\n\n```php\n// UDP\n$container\n    -\u003eget('event_dispatcher')\n    -\u003edispatch(InfluxDbEvent::NAME, new UdpEvent($points, Database::PRECISION_SECONDS));\n\n// HTTP\n$container\n    -\u003eget('event_dispatcher')\n    -\u003edispatch(InfluxDbEvent::NAME, new HttpEvent($points, Database::PRECISION_SECONDS));\n```\n\nOr, if you prefer to defer the event:\n\n```php\n// Deferred Events\n// Collect your measurements during the request and make only one write to influxdb.\n// Deferred events are catched and \"stored\". Than on the kernel.terminate event one write per\n// event type and precision will be fired.\n\n// UDP\n$container\n    -\u003eget('event_dispatcher')\n    -\u003edispatch(InfluxDbEvent::NAME, new DeferredUdpEvent($points, Database::PRECISION_SECONDS));\n\n// HTTP\n$container\n    -\u003eget('event_dispatcher')\n    -\u003edispatch(InfluxDbEvent::NAME, new DeferredHttpEvent($points, Database::PRECISION_SECONDS));\n```\n\nIf you want to write to another connection than the default, you must specify it:\n\n```php\n// UDP\n$container\n    -\u003eget('event_dispatcher')\n    -\u003edispatch(InfluxDbEvent::NAME, new UdpEvent($points, Database::PRECISION_SECONDS, 'other_connection'));\n\n// HTTP\n$container\n    -\u003eget('event_dispatcher')\n    -\u003edispatch(InfluxDbEvent::NAME, new HttpEvent($points, Database::PRECISION_SECONDS, 'other_connection'));\n```\n\n### Commands\n\nSome commands are provided:\n\n* `algatux:influx:database:create`: To create the database.\n* `algatux:influx:database:drop`: To drop the database.\n\nTo get more information, run:\n\n```bash\n./app/console help \u003ccommand\u003e\n```\n\n### Form types\n\nThis bundle provides several pre-defined form types. They are useful but optional.\n\nIf you want to use them, you have to require the `symfony/form` package.\n\nDescription of each of them is on the class doc block. Here is a short usage example:\n\n```php\n$form\n    -\u003eadd('measurement', MeasurementType::class, [\n        'connection' =\u003e 'default' // Optional: The connection you want to use.\n    ])\n    -\u003eadd('fields', FieldKeyType::class, [\n        'measurement' =\u003e 'cpu', // The concerned measurement.\n        'multiple' =\u003e true, // Parent type is ChoiceType. You can use parent option like multiple.\n    ])\n    -\u003eadd('tags', TagKeyType::class, [\n        'measurement' =\u003e 'cpu',\n        'exclude_host' =\u003e false, // True by default. Excludes the 'host' choice value.\n        'multiple' =\u003e true,\n    ])\n    -\u003eadd('tag_value', TagValueType::class, [\n        'measurement' =\u003e 'disk',\n        'tag_key' =\u003e 'fstype', // The related tag key.\n    ])\n;\n```\n\n### Custom event listeners\n\nIn order to make it more flexible, you can override or even completely disable the default event listener and implement your own.\n\nIt is useful i.e. if you want to add additional logging or error handling around the actual database calls.\n\n### Contributing\n\nFeel free to contribute by opening a pull request, if you find a bug or to suggest a new feature.\nIf you like docker, this repository is provided with a dev environment with some scripts to prepare and use it.\nAll you need is docker and docker-compose installed on your system.\n\n```\n make setup  # will build the needed containers and setup the project\n```\n\n```\n make start  # will start the needed containers and put you inside the php-cli container\n```\n\n```\n make test  # will launch the test suite\n```\n\nNote: All these scripts are meant to be used outside the containers.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falgatux%2Finfluxdb-bundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falgatux%2Finfluxdb-bundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falgatux%2Finfluxdb-bundle/lists"}