Added test for direct messsages with HTTP client

This commit is contained in:
Walter Dal Mut
2015-06-10 15:54:06 +02:00
parent 4f3fdcb543
commit 72b08569e9
2 changed files with 54 additions and 14 deletions
+24 -14
View File
@@ -7,6 +7,8 @@
Send metrics to InfluxDB and query for any data.
**For InfluxDB v0.8 checkout branch 0.3**
## Install it
Just use composer
@@ -34,6 +36,27 @@ $client->mark("app.search", [
]);
```
Or use InfluxDB direct messages
```php
$client->mark([
"database" => "mydb",
"tags" => [
"dc" => "eu-west-1",
],
"points" => [
[
"name" => "vm-serie",
"fields" => [
"cpu" => 18.12,
"free" => 712423,
],
],
]
]);
```
Retrieve existing points:
```php
@@ -61,7 +84,7 @@ php -m | grep sockets
If you don't have the `sockets` extension, you can proceed in two ways:
- Recompile your PHP whith the `--enable-sockets` flag
- Or just compile the `sockets` extension extracting it from the PHP source.
- Or just compile the `sockets` extension extracting it from the PHP source.
1. Download the source relative to the PHP version that you on from [here](https://github.com/php/php-src/releases)
2. Enter in the `ext/sockets` directory
3. Issue a `phpize && ./configure && make -j && sudo make install`
@@ -124,25 +147,12 @@ $client->mark("error.404", ["page" => "/a-missing-page"]);
Of course you can always use the DiC or your service manager in order to create
a valid client instance.
### Time Precision write/read queries
You can set the `time_precision` for query query
```php
$client->mark("app.search", $points, "s"); //points contains "time" that is in seconds
```
```php
$client->query("select * from app.search", "s"); // retrieve points using seconds for time column
```
### Query InfluxDB
You can query the time series database using the query method.
```php
$influx->query("select * from mine");
$influx->query("select * from mine", "s"); // with time_precision
```
You can query the database only if the adapter is queryable (implements
+30
View File
@@ -97,6 +97,36 @@ class ClientTest extends \PHPUnit_Framework_TestCase
$this->assertEquals("element", $body["results"][0]["series"][0]["values"][0][1]);
}
/**
* @group tcp
*/
public function testWriteDirectMessages()
{
$this->object->mark([
"database" => "tcp.test",
"tags" => [
"dc" => "eu-west-1",
],
"points" => [
[
"name" => "vm-serie",
"fields" => [
"cpu" => 18.12,
"free" => 712423,
],
],
]
]);
sleep(1);
$body = $this->object->query("select * from \"vm-serie\"");
$this->assertCount(1, $body["results"][0]["series"][0]["values"]);
$this->assertEquals("cpu", $body["results"][0]["series"][0]["columns"][1]);
$this->assertEquals(18.12, $body["results"][0]["series"][0]["values"][0][1]);
}
/**
* @group udp
*/