0

I am new to InfluxDB and have been trying to store a datapoint with multiple fields having custom timestamp from a dictionary into the influxdb via the influxdb-client == 1.36.1

I followed the pypi documentation and tried to give custom timestamp using "time" key in the dictionary and even via the .time() method of the Point class but had no luck.

Here is the dictionary I make:

{
  'measurement': 'Chiller_02_hourly_',
  'tags': {'Page_Number': 1},
  'time': '2022-04-17T16:00:00.00', 
  'fields': {
    'Evaporator_Referigerant_Pressure': 40.0,
    'Evaporator_Inlet_Water_Temperature': 11.0,
    'Evaporator_Outlet_Water_Temperature': 6.7,
    'Evaporator_Saturation_Temperature': 4.4,
    'Evaporator_Approach': -2.3,
    'Evaporator_Flowrate': 239.3,
    'Condensor_Referigerant_Pressure': 153.1,
    'Condensor_Inlet_Water_Temperature': 33.0, 
    'Condensor_Outlet_Water_Temperature': 33.0,
    'Condensor_Saturation_Temperature': 39.6,
    'Condensor_Approach': 2.4, 
    'Condensor_Flowrate': 314.3,
    'Motor_Load': 94.0,
    'Motor_KW': 0.0,
    'Motor_Oil_Differential_Pressure': 274.4,
    'Motor_Oil_Temperature': 50.0,
    'Real_Power': 0.0,
    'Real_Energy': nan,
    'Consumption': nan
  }
}

Why is this dictionary wrong? it becomes the "data_point" in the code below.

I am using the async write to record data into database, it doesn't give any error, just stops and goes into the 'if' of this code segment. (st is streamlit)

    async def influx_db_async_writer(self, data_point: list) -> None:
        """ function to write into influxdb """
        async with InfluxDBClientAsync(
            url=f"http://{cfg.DATABASE_CONTAINER_NAME}:{cfg.INFLUXDB_PORT}",
            token=cfg.DATABASE_TOKEN, org=cfg.DATABASE_ORG
        ) as client:
            write_api = client.write_api()
            # print(data_point)
            success = await write_api.write(bucket=cfg.DATABASE_NAME, record=data_point)
            if not success:
                st.error("Could not write into database")

I tried to print "success" expecting some string like 400 "Bad request" as mentioned in troubleshooting docs of InfluxDB. But it prints nothing.

I notice that if I give the "time" key a string like "01:01:2022 00:00:00" or any random string but the one in the dictionary, it successfully writes into the db but gives "_time", 3 current system datetimes, 1 hr apart. I wonder if its the -3h in the query.

This was the query I wrote:

query = """
            from(bucket:"chillerdb")
                |> range(start: -3h, stop: now())
                |> filter(fn: (r) => r._measurement == "Chiller_02_hourly_")
                |> filter(fn: (r) => r._field == "Motor_Load" or r._field == "Evaporator_Approach")
                |> group(columns: ["Page_Number"])
        """

Am I missing some concepts of query? as providing required timestamps in start/stop that I provided in the dictionary return nothing.

0 Answers0