We have some code in python that we are unable to get running due to some odd errors that I cannot make out.
This is the snippet of code:
INFLUX_CONFIG_ASR920 = '/opt/light_prophet/influx_config_snmp_asr920_optical.yml'
with open(INFLUX_CONFIG_ASR920) as f:
config_asr920 = yaml.load(f, Loader=yaml.FullLoader)
def get_influx_client_asr920():
influx_client_asr920 = influxdb_client.InfluxDBClient(
bucket=config_asr920['bucket'],
org=config_asr920['org'],
token=config_asr920['token'],
url=config_asr920['url'],
)
return(influx_client_asr920)
def query_agent_hosts():
query_asr920 = 'import "influxdata/influxdb/schema"\
|> schema.tagValues (\
|> bucket: "bucket_snmp_asr920_optical"\
|> tag: "ASR920-Hostname"\
)'
influx_client_asr920 = get_influx_client_asr920()
result = influx_client_asr920.query(query_asr920, epoch='m').get_points()
influx_client_asr920.close()
agent_hosts = [i['value'].split('.')[0] for i in result]
We get an error when running this .py script per following:
Traceback (most recent call last):
File "full_analysis.py", line 57, in <module>
feed = make_feed()
File "full_analysis.py", line 27, in make_feed
hosts = optical_dataframe.list_reachable_hosts()
File "/opt/light_prophet/optical_dataframe.py", line 302, in list_reachable_hosts
agent_hosts = query_agent_hosts()
File "/opt/light_prophet/optical_dataframe.py", line 211, in query_agent_hosts
result = influx_client_asr920.query(query_asr920, epoch='m').get_points()
AttributeError: 'InfluxDBClient' object has no attribute 'query'
I am not sure how this is true as that is what is references in the influxdb python api guide when running a query. per these articles.
Use the InfluxDB Python client library | InfluxDB Cloud (TSM) Documentation (influxdata.com)
and
API Documentation — InfluxDB 5.3.1 documentation (influxdb-python.readthedocs.io)
Any help or recommendations would be greatly appreicated.
Thank you all.