Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f029677

Browse files
committed
the timestamp field is called 'time'
1 parent ca10f5e commit f029677

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

influxdb/line_protocol.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ def make_lines(data):
9494
lines = lines[:-1] # strip the trailing comma
9595

9696
# add timestamp
97-
if 'timestamp' in point:
97+
if 'time' in point:
9898
lines += " " + _force_text(str(int(
99-
_convert_timestamp(point['timestamp'])
99+
_convert_timestamp(point['time'])
100100
)))
101101

102102
lines += "\n"

tests/influxdb/client_test.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def setUp(self):
8888
"host": "server01",
8989
"region": "us-west"
9090
},
91-
"timestamp": "2009-11-10T23:00:00Z",
91+
"time": "2009-11-10T23:00:00Z",
9292
"fields": {
9393
"value": 0.64
9494
}
@@ -149,7 +149,7 @@ def test_write(self):
149149
"points": [{"measurement": "cpu_load_short",
150150
"tags": {"host": "server01",
151151
"region": "us-west"},
152-
"timestamp": "2009-11-10T23:00:00Z",
152+
"time": "2009-11-10T23:00:00Z",
153153
"fields": {"value": 0.64}}]}
154154
)
155155

@@ -206,18 +206,18 @@ def test_write_points_toplevel_attributes(self):
206206
def test_write_points_batch(self):
207207
dummy_points = [
208208
{"measurement": "cpu_usage", "tags": {"unit": "percent"},
209-
"timestamp": "2009-11-10T23:00:00Z", "fields": {"value": 12.34}},
209+
"time": "2009-11-10T23:00:00Z", "fields": {"value": 12.34}},
210210
{"measurement": "network", "tags": {"direction": "in"},
211-
"timestamp": "2009-11-10T23:00:00Z", "fields": {"value": 123.00}},
211+
"time": "2009-11-10T23:00:00Z", "fields": {"value": 123.00}},
212212
{"measurement": "network", "tags": {"direction": "out"},
213-
"timestamp": "2009-11-10T23:00:00Z", "fields": {"value": 12.00}}
213+
"time": "2009-11-10T23:00:00Z", "fields": {"value": 12.00}}
214214
]
215215
expected_last_body = {"tags": {"host": "server01",
216216
"region": "us-west"},
217217
"database": "db",
218218
"points": [{"measurement": "network",
219219
"tags": {"direction": "out"},
220-
"timestamp": "2009-11-10T23:00:00Z",
220+
"time": "2009-11-10T23:00:00Z",
221221
"fields": {"value": 12.00}}]}
222222
with requests_mock.Mocker() as m:
223223
m.register_uri(requests_mock.POST,

0 commit comments

Comments
 (0)