Sviatoslav Pikh
Sviatoslav Pikh

Reputation: 45

Can I set specific time for a point in Influxdb using Python?

Is it possible to set time for an InfluxDB point instead of relying on the default "now" option?

Upvotes: 1

Views: 702

Answers (1)

Sviatoslav Pikh
Sviatoslav Pikh

Reputation: 45

Yes, you can. You can specify a "time" field value for every point you want to write to influx. Like this:

json_body = [
    {
        "measurement": "cpu_load_short",
        "tags": {
            "host": "server01",
            "region": "us-west"
        },
        "time": "2009-11-10T23:00:00Z",
        "fields": {
            "Float_value": 0.64,
            "Int_value": 3,
            "String_value": "Text",
            "Bool_value": True
        }
    }
]

client = InfluxDBClient(host, port, user, password, dbname)
client.write_points(json_body)

Upvotes: 1

Related Questions