我正在尝试向 influxDB TSDB 写入点,但是在写入过程中它给出了一个错误:
File "/home/lab/prometheus-clients-env/lib/python3.5/site-packages/influxdb/client.py", line 271, in request
raise InfluxDBClientError(response.content, response.status_code)
influxdb.exceptions.InfluxDBClientError: 400: {"error":"partial write: unable to parse 'Cisco-IOS-XR-cdp-oper-cdp,address-type=ipv4,capabilities=R,device-id=ASR9006-LER1,duplex=cdp-dplx-full,interface-name=TenGigE0/0/0/0,ipv4-address=100.8.44.1,node-name=0/0/CPU0,platform=cisco\\ ASR9K\\ Series,port-id=TenGigE0/1/0/7,receiving-interface-name=TenGigE0/0/0/0,system-name=ASR9006-LER1,version=Cisco\\ IOS\\ XR\\ Software\\,\\ Version\\ 6.2.3[Default]': missing fields\nunable to parse 'Cisco-IOS-XR-cdp-oper-cdp,address-type=ipv4,capabilities=R,device-id=ASR9006-LER1,duplex=cdp-dplx-full,interface-name=TenGigE0/0/0/2,ipv4-address=100.8.44.1,node-name=0/0/CPU0,platform=cisco\\ ASR9K\\ Series,port-id=TenGigE0/1/0/8,receiving-interface-name=TenGigE0/0/0/2,system-name=ASR9006-LER1,version=Cisco\\ IOS\\ XR\\ Software\\,\\ Version\\ 6.2.3[Default]': missing fields\nunable to parse 'Cisco-IOS-XR-cdp-oper-cdp,address-type=ipv4,capabilities=R,device-id=ASR9006-LER1,duplex=cdp-dplx-full,interface-name=TenGigE0/0/0/3,ipv4-address=100.8.44.1,node-name=0/0/CPU0,platform=cisco\\ ASR9K\\ Series,port-id=TenGigE0/1/0/9,receiving-interface-name=TenGigE0/0/0/3,system-name=ASR9006-LER1,version=Cisco\\ IOS\\ XR\\ Software\\,\\ Version\\ 6.2.3[Default]': missing fields\nunable to parse 'Cisco-IOS-XR-cdp-oper-cdp,address-type=ipv4,capabilities=R,device-id=ASR9006-LER1,duplex=cdp-dplx-full,interface-name=TenGigE0/0/0/4,ipv4-address=100.8.44.1,node-name=0/0/CPU0,platform=cisco\\ ASR9K\\ Series,port-id=TenGigE0/1/0/11,receiving-interface-name=TenGigE0/0/0/4,system-name=ASR9006-LER1,version=Cisco\\ IOS\\ XR\\ Software\\,\\ Version\\ 6.2.3[Default]': missing fields\nunable to parse 'Cisco-IOS-XR-cdp-oper-cdp,address-type=ipv4,capabilities=R,device-id=ASR9006-LER1,duplex=cdp-dplx-full,interface-name=TenGigE0/0/0/5,ipv4-address=100.8.44.1,node-name=0/0/CPU0,platform=cisco\\ ASR9K\\ Series,port-id=TenGigE0/1/0/18,receiving-interface-name=TenGigE0/0/0/5,system-name=ASR9006-LER1,version=Cisco\\ IOS\\ XR\\ Software\\,\\ Version\\ 6.2.3[Default]': missing fields\nunable to parse 'Cisco-IOS-XR-cdp-oper-cdp,address-type=ipv4,capabilities=R,device-id=ASR9006-LER1,duplex=cdp-dplx-full,interface-name=TenGigE0/0/0/6,ipv4-address=100.8.44.1,node-name=0/0/CPU0,platform=cisco\\ ASR9K\\ Series,port-id=TenGigE0/1/0/10,receiving-interface-name=TenGigE0/0/0/6,system-name=ASR9006-LER1,version=Cisco\\ IOS\\ XR\\ Software\\,\\ Version\\ 6.2.3[Default]': missing fields\nunable to parse 'Cisco-IOS-XR-cdp-oper-cdp,address-type=ipv4,capabilities=R,device-id=ASR9006-LER1,duplex=cdp-dplx-full,interface-name=TenGigE0/0/0/7,ipv4-address=100.8.44.1,node-name=0/0/CPU0,platform=cisco\\ ASR9K\\ Series,port-id=TenGigE0/1/0/19,receiving-interface-name=TenGigE0/0/0/7,system-name=ASR9006-LER1,version=Cisco\\ IOS\\ XR\\ Software\\,\\ Version\\ 6.2.3[Default]': missing fields\nunable to parse 'Cisco-IOS-XR-cdp-oper-cdp,address-type=ipv4,capabilities=R,device-id=ASR9006-LER1,duplex=cdp-dplx-full,interface-name=TenGigE0/0/0/7,ipv4-address=100.8.44.1,node-name=0/0/CPU0,platform=cisco\\ ASR9K\\ Series,port-id=TenGigE0/1/0/7,receiving-interface-name=TenGigE0/0/0/0,system-name=ASR9006-LER1,version=Cisco\\ IOS\\ XR\\ Software\\,\\ Version\\ 6.2.3[Default]': missing fields dropped=0"}
我有以下 JSON 点:
{'fields': {'native-vlan': 0, 'header-version': 2, 'hold-time': 132}, 'tags': {'address-type': 'ipv4', 'platform': 'cisco ASR9K Series', 'duplex': 'cdp-dplx-full', 'port-id': 'TenGigE0/1/0/7', 'system-name': 'ASR9006-LER1', 'interface-name': 'TenGigE0/0/0/0', 'ipv4-address': '100.8.44.1', 'node-name': '0/0/CPU0', 'device-id': 'ASR9006-LER1', 'capabilities': 'R', 'version': 'Cisco IOS XR Software, Version 6.2.3[Default]\nCopyright (c) 2017 by Cisco Systems, Inc.', 'receiving-interface-name': 'TenGigE0/0/0/0'}, 'measurement': 'Cisco-IOS-XR-cdp-oper-cdp'}
我有以下代码:
client = InfluxDBClient('server', 8086)
tags = {}
fields = {}
points = []
for key in raw_metric.keys():
if isinstance(raw_metric[key], int):
fields[key] = raw_metric[key]
else:
tags[key] = raw_metric[key]
post_data = {"measurement" : 'Cisco-IOS-XR-cdp-oper-cdp',
"fields" : fields,
"tags" : tags
}
points.append(post_data)
if not client.write_points(points):
exit(1)
raw_metric 看起来像这样:
{'interface-name': 'TenGigE0/0/0/0', 'node-name': '0/0/CPU0', 'version': 'Cisco IOS XR Software, Version 6.2.3[Default]\nCopyright (c) 2017 by Cisco Systems, Inc.', 'port-id': 'TenGigE0/1/0/7', 'address-type': 'ipv4', 'header-version': 2, 'platform': 'cisco ASR9K Series', 'hold-time': 137, 'duplex': 'cdp-dplx-full', 'ipv4-address': '100.8.44.1', 'system-name': 'ASR9006-LER1', 'native-vlan': 0, 'receiving-interface-name': 'TenGigE0/0/0/0', 'device-id': 'ASR9006-LER1', 'capabilities': 'R'}
字段如下所示:
{'hold-time': 137, 'header-version': 2, 'native-vlan': 0}
标签看起来像这样:
{'interface-name': 'TenGigE0/0/0/0', 'node-name': '0/0/CPU0', 'version': 'Cisco IOS XR Software, Version 6.2.3[Default]\nCopyright (c) 2017 by Cisco Systems, Inc.', 'address-type': 'ipv4', 'receiving-interface-name': 'TenGigE0/0/0/0', 'platform': 'cisco ASR9K Series', 'port-id': 'TenGigE0/1/0/7', 'duplex': 'cdp-dplx-full', 'ipv4-address': '100.8.44.1', 'system-name': 'ASR9006-LER1', 'device-id': 'ASR9006-LER1', 'capabilities': 'R'}
关于为什么我收到部分写入错误的任何想法?