writePoints() public method

Write points into InfluxDB using the current driver. This is the recommended method for inserting data into InfluxDB.
public writePoints ( array $points, string $precision = self::PRECISION_NANOSECONDS, string | null $retentionPolicy = null ) : boolean
$points array Array of Point objects
$precision string The timestamp precision (defaults to nanoseconds).
$retentionPolicy string | null Specifies an explicit retention policy to use when writing all points. If not set, the default retention period will be used. This is only applicable for the Guzzle driver. The UDP driver utilizes the endpoint configuration defined in the server's influxdb configuration file.
return boolean
 public function testWritePointsInASingleCall()
 {
     $point1 = new Point('cpu_load_short', 0.64, array('host' => 'server01', 'region' => 'us-west'), array('cpucount' => 10), 1435222310);
     $point2 = new Point('cpu_load_short', 0.84);
     $payloadExpected = "{$point1}\n{$point2}";
     $this->mockClient->expects($this->once())->method('write')->with($this->equalTo($this->db->getName()), $this->equalTo($payloadExpected))->will($this->returnValue(true));
     $this->db->writePoints(array($point1, $point2));
 }
 /**
  * @param Point[] $points
  * @param string  $precision
  */
 private function writeHttpPoints(array $points, string $precision)
 {
     $this->httpDatabase->writePoints($points, $precision);
 }
Example #3
0
 public function testWritePointsInASingleCall()
 {
     $point1 = new Point('cpu_load_short', 0.64, array('host' => 'server01', 'region' => 'us-west'), array('cpucount' => 10), 1435222310);
     $point2 = new Point('cpu_load_short', 0.84);
     $this->assertEquals(true, $this->db->writePoints(array($point1, $point2)));
 }