algatux / influxdb-bundle Goto Github PK
View Code? Open in Web Editor NEWBundle service integration of official influxdb/influxdb-php client
License: MIT License
Bundle service integration of official influxdb/influxdb-php client
License: MIT License
Find a way to give users access to \InfluxDB\Client to make usage of Client functions
In same philosophy as #88, we can bump Symfony sypport to ^3.4
as it's the last LTS.
This can be done on a new minor if we don't change our public API.
Ideally, with a transitional versions supporting both v1 and v2.
Hi
I got the following error when tried to remove DB.
The code:
$this->influxConnection->query('Drop Database ....');
DB is removed, but as a result, I got the following error (see below full output).
I can not find any mentions in the documentation on how to change the mode for the connection or query.
influxdb-bundle: 2.4.0
unfortunately can not find the influx version, but should be latest or very close to the latest (I have access only via SQL or via Chronograf)
Full error message:
object(InfluxDB\ResultSet)#1067 (2) {
["parsedResults":protected]=>
array(1) {
["results"]=>
array(1) {
[0]=>
array(2) {
["statement_id"]=>
int(0)
["messages"]=>
array(1) {
[0]=>
array(2) {
["level"]=>
string(7) "warning"
["text"]=>
string(128) "deprecated use of 'DROP DATABASE XXXXX' in a read only context, please use a POST request instead"
}
}
}
}
}
["rawResults":protected]=>
string(204) "{"results":[{"statement_id":0,"messages":[{"level":"warning","text":"deprecated use of 'DROP DATABASE XXXXX' in a read only context, please use a POST request instead"}]}]}
"
}
Will be great to give out of the box a simple environment for devs that want to contribute.
Also will be a standard env for us.
@soullivaneuh please add your info to composer.json authors property
You use them (udp and tcp) as strings, but according to the Client
class: https://github.com/influxdata/influxdb-php/blob/1.4.1/src/InfluxDB/Client.php#L101
They should be integers.
But, because you are using strict typing, changing that would be BC break.
So this issue need to be solved on next major.
We need to update the local dev environment
If using this bundle with Symfony Flex, the established approach is to support a DSN for connection strings instead of having each individual part be separate, as is currently the case.
This allow to pass the connection string as one variable instead of several (up to 5) which significantly simplifies secrets management for containerized apps, you just put the entire DSN in the secret.
Here's an example usage by Doctrine Bundle in a Symfony Flex recipe:
https://github.com/symfony/recipes/blob/master/doctrine/doctrine-bundle/1.6/config/packages/doctrine.yaml#L18
It would be great to have a create and drop commands for databases.
This is particularly useful for deploy script and integration tests.
Currently, both http and upd client/database instances are created, even if we don't needed.
Maybe we could make it optional with the config:
influx_db:
connections:
telegraf:
host: '%influxdb_host%'
database: '%influxdb_telegraf_db%'
udp: false # Disable UDP
Both udp
and http
port would be false
by default and a configuration validation could check if at least one of them is enabled.
Edit: Only udp will be optional: #36 (comment)
What do you think?
Currently the bundle can't be used on PHP 8 because of the version constraint. Please consider supporting PHP 8 as well.
From a quick check your dependencies all support PHP 8, so they won't stop you from upgrading. Not sure about the actual code though.
I suggest you to setup Coveralls: https://coveralls.io/
With this tools, you will get PR status for coverage.
Example:
Symfony 7 support will be more tricky because of the removal of the container aware trait.
It make the needed refactor a bit more complex because of the called of services named "on the fly" like this:
influxdb-bundle/src/Command/AbstractConnectionCommand.php
Lines 42 to 43 in aa23312
I'll update this MR for Symfony 6 support only in order to have a quick release and support LTS.
Symfony 7 support will be the object of a separated work.
Originally posted by @soullivaneuh in #102 (comment)
Hi guys,
Do you know if you will continue to maintain bundle?
PHP8 and Symfony 6 not supported
No release since 2 years
Thx for your anwer
If we request and need a response from InfluxDB but we may want to have a timeout to stop InfluxDB request instead letting them running indefinitely.
It would be great to be able to set a timeout directly inside Influx connection config, for example :
influx_db:
connections:
default:
host: '%influxdb_host%'
database: '%influxdb_db%'
username: '%influxdb_user%'
password: '%influxdb_password%'
timeout: 2
InfluxDbEvent::$points
and InfluxDbEvent::$precision
should be private. They are not used by children classes.
InfluxDbEventListener uses deprecated services, must be refactored using the new services
According to the Symfony Coding Standards:
Prefix abstract classes with Abstract. Please note some early Symfony classes do not follow this convention and have not been renamed for backward compatibility reasons. However all new abstract classes must follow this naming convention;
Do you want to follow this rule?
We can take profit of the next major to rename the concerned class.
Before tag the next major, it would be great to make some class final
.
Some class should not be extended. Making them final
would allow us more flexibility on code change without BC break.
I suggest you an interesting article about the final
keyword: http://ocramius.github.io/blog/when-to-declare-classes-final/
Does the use_events
configuration very useful? Why did you make the listener optional?
The "if not exists" syntax in Database::create was defaulted and deprecated before 1.0 release, and crashes with syntax error if used now. The parameter should be removed.
Use the @internal
tag on some class.
The @internal
tag means that the class should not be used except for internal stuff.
In a nutshell, you can do BC break change on this class without have to push a new major! ๐
For example, the ClientFactory
should not be used by the end user. It could be internal.
It should be AlgatuxInfluxDbBundle
and not just InfluxDbBundle
to reduce possible bundle conflicts.
This is the adopted way for 99% of external bundles as you can see on this AppKernel
extract:
new FOS\UserBundle\FOSUserBundle(),
new FOS\OAuthServerBundle\FOSOAuthServerBundle(),
new FOS\RestBundle\FOSRestBundle(),
new FOS\JsRoutingBundle\FOSJsRoutingBundle(),
new Nelmio\ApiDocBundle\NelmioApiDocBundle(),
new Gregwar\ImageBundle\GregwarImageBundle(),
new Sonata\CoreBundle\SonataCoreBundle(),
new Sonata\BlockBundle\SonataBlockBundle(),
new Sonata\DoctrineORMAdminBundle\SonataDoctrineORMAdminBundle(),
new Sonata\AdminBundle\SonataAdminBundle(),
new Sonata\IntlBundle\SonataIntlBundle(),
new Ornicar\GravatarBundle\OrnicarGravatarBundle(),
new Lexik\Bundle\JWTAuthenticationBundle\LexikJWTAuthenticationBundle(),
new Rollerworks\Bundle\PasswordStrengthBundle\RollerworksPasswordStrengthBundle(),
new Hackzilla\Bundle\PasswordGeneratorBundle\HackzillaPasswordGeneratorBundle(),
new A2lix\TranslationFormBundle\A2lixTranslationFormBundle(),
new Browscap\BrowscapBundle\BrowscapBundle(),
new Hautelook\AliceBundle\HautelookAliceBundle(),
new Algatux\InfluxDbBundle\InfluxDbBundle(),
new Greg0ire\Enum\Bridge\Symfony\Bundle\Greg0ireEnumBundle(),
This can be done on a BC way by deprecating the old bundle class name.
Including phpunit ad dev dependency causes CI to broke when the --prefer-lowest composer flag is applied
see dependecies_update branch
With lasts commits the overral code quality has decreased.
Hi, when I use your bundle in my project I get always this deprecation notice:
User Deprecated: Calling the "Symfony\Component\EventDispatcher\EventDispatcherInterface::dispatch()" method with the event name as the first argument is deprecated since Symfony 4.3, pass it as the second argument and provide the event object as the first argument instead.
Do you know how to adjust it? I checked your code and InfluxDbEventListener is subscribed to the event with name influxdb.points_collected
and it's impossible to use EventDispatcherInterface in a new way like this:
$this->eventDispatcher->dispatch(new UdpEvent([$point], Database::PRECISION_SECONDS));
Do you have any suggestions?
Enforce usage of php 7.1 inside composer.json and release a new major
I want to remove phpunit from composer.json require-dev packages as suggested by @soullivaneuh in comment
What is the goal of PointCollection
The implementation looks superfluous IMHO.
From your doc, you have to do this:
$time = new \DateTime();
$points = new PointsCollection([new Point(
'test_metric', // name of the measurement
0.64, // the measurement value
['host' => 'server01', 'region' => 'italy'], // optional tags
['cpucount' => rand(1,100), 'memory' => memory_get_usage(true)], // optional additional fields
$time->getTimestamp()
)],Database::PRECISION_SECONDS);
$container
->get('algatux_influx_db.client.http.writer_client')
->write($points);
But from influxdb-php documentation:
// create an array of points
$points = array(
new Point(
'test_metric', // name of the measurement
0.64, // the measurement value
['host' => 'server01', 'region' => 'us-west'], // optional tags
['cpucount' => 10], // optional additional fields
1435255849 // Time precision has to be set to seconds!
),
new Point(
'test_metric', // name of the measurement
0.84, // the measurement value
['host' => 'server01', 'region' => 'us-west'], // optional tags
['cpucount' => 10], // optional additional fields
1435255849 // Time precision has to be set to seconds!
)
);
// we are writing unix timestamps, which have a second precision
$result = $database->writePoints($points, Database::PRECISION_SECONDS);
This is basically the same.
Plus, since #10, we will directly get an access to the Database
instance. So PointCollection
would not be used at all.
What do you think?
It would be great to allow multiple databases in configuration.
I have an idea of how to do it, I'll PR that soon. ๐
Currently, if we use your bundle, we can only write points.
I know this is the goal of this bundle, but it's a little bit disappointing to have a bundle for influxdb and having to use directly the library outside the Symfony services scope:
$database = \InfluxDB\Client::fromDSN(sprintf(
'influxdb://:@%s:%s/%s',
$this->getParameter('influx_db.host'),
$this->getParameter('influx_db.http.port'),
$this->getParameter('influx_db.database')
));
$result = $database->getQueryBuilder()
->select('*')
->from('cpu')
->limit(10)
->orderBy('time', 'DESC')
->where([
"cpu = 'cpu-total'",
"host = '".$server->getCompleteName()."'",
])
->getResultSet()
->getPoints();
dump($result);
I'll look at your code and make a proposition.
like title
When creating measurement field inside a form, the current query to get fieldKey
seem to be broken
cf : https://github.com/Algatux/influxdb-bundle/blob/master/src/Form/Type/FieldKeyType.php#L26
Then we get this error :
unable to use system source '_fieldKeys': use SHOW FIELD KEYS instead
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.