0

ポイントを 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'}

部分的な書き込みエラーが発生する理由について何か考えはありますか?

4

1 に答える 1