Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I delete points? #62

Closed
skillbox-koutja opened this issue Jan 26, 2021 · 1 comment · Fixed by #63
Closed

How can I delete points? #62

skillbox-koutja opened this issue Jan 26, 2021 · 1 comment · Fixed by #63
Milestone

Comments

@skillbox-koutja
Copy link

Give me advice. How can I delete points? Which type of api I should use: write or query?

@bednar
Copy link
Contributor

bednar commented Jan 26, 2021

Hi @skillbox-koutja,

thanks for using our client.

The DefaultService.php supports deletes points from an InfluxDB bucket. You could use something like:

<?php
/**
 * Shows how to delete data from InfluxDB by client
 */
use InfluxDB2\Client;
use InfluxDB2\Model\DeletePredicateRequest;
use InfluxDB2\Service\DefaultService;

$url = 'http://localhost:8086';
$token = 'my-token';
$org = 'my-org';
$bucket = 'my-bucket';

$client = new Client([
    "url" => $url,
    "token" => $token,
    "bucket" => $bucket,
    "org" => $org,
    "precision" => InfluxDB2\Model\WritePrecision::S
]);

//
// Delete data by measurement and tag value
//
/** @var DefaultService $service */
$service = $client->createService(DefaultService::class);

$predicate = new DeletePredicateRequest();
$predicate->setStart(DateTime::createFromFormat('Y', '2020'));
$predicate->setStop(new DateTime());
$predicate->setPredicate("_measurement=\"mem\" AND host=\"host1\"");

$service->deletePost($predicate, null, $org, $bucket);

$client->close();

Regards

@bednar bednar added this to the 1.10.0 milestone Jan 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants