Skip to content

Commit 08d7f3d

Browse files
author
shivam
committed
Fixed the csv_to_influx : no attribute RecordInflux error and InfluxRequest needs time in utc format and not in string format
Signed-off-by: shivam <[email protected]>
1 parent 93cee54 commit 08d7f3d

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

py-dashboard/InfluxRequest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import os
99

1010
import pandas as pd
11+
from influxdb_client import WritePrecision
1112

1213
if sys.version_info[0] != 3:
1314
print("This script requires Python 3")
@@ -61,7 +62,7 @@ def post_to_influx(self, key, value, tags, time):
6162
for tag_key, tag_value in tags.items():
6263
p.tag(tag_key, tag_value)
6364
print(tag_key, tag_value)
64-
p.time(time)
65+
p.time(datetime.datetime.strptime(time, '%Y-%m-%dT%H:%M:%S.%f').utcnow(), WritePrecision.NS)
6566
p.field("value", value)
6667
self.write_api.write(bucket=self.influx_bucket, org=self.influx_org, record=p)
6768

py-scripts/csv_to_influx.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from pathlib import Path
66
import argparse
77

8-
98
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
109

1110
cv_test_manager = importlib.import_module("py-json.cv_test_manager")
@@ -15,6 +14,7 @@
1514
RecordInflux = InfluxRequest.RecordInflux
1615
influx_add_parser_args = InfluxRequest.influx_add_parser_args
1716

17+
1818
class CSVtoInflux:
1919
def __init__(self,
2020
influx_host,
@@ -34,7 +34,7 @@ def glob(self):
3434
path = Path(self.path)
3535
self.kpi_list = list(path.glob('**/kpi.csv'))
3636
for kpi in self.kpi_list:
37-
self.influxdb.RecordInflux.csv_to_influx(kpi)
37+
self.influxdb.csv_to_influx(kpi)
3838

3939

4040
def main():

0 commit comments

Comments
 (0)