Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InfluxDBClient: client.health() returns "...AttributeError: 'InfluxDBClient' object has no attribute 'health'..." #609

Closed
integraciones-tiagora opened this issue Sep 3, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@integraciones-tiagora
Copy link

Specifications

  • Client Version: influxdb 5.3.1 installed on Pycharm IDE
  • InfluxDB Version: I think it is 1.7.9 running on top of Linux
  • Platform: Python program runs on MacOS Ventura 13.5.1

Dear sirs:
I am running my Python script on PyCharm 2022.3.3 (Community Edition). My call to InfluxDB works OK, but I would like to add some checks to my program in case the connection fails.

I found that I should use the following sentences:

health = client.health()
if health.status == "pass":
print("Connection OK")
else:
print(f"Connection error: {health.message}!")

But my interpreter fails with the following error message:

health = client.health()
AttributeError: 'InfluxDBClient' object has no attribute 'health'

¿ Do I need to upgrade my client? ¿Or is there any other available way to check the health of my connection?

Your help will be greatly appreciated
Best regards
Rogelio

Code sample to reproduce problem

client = InfluxDBClient(host='10.235.2.19', port=8086, username='admin', password='nimda')
client.switch_database('telegraf')

health = client.health()
if health.status == "pass":
print("Conexión exitosa a InfluxDB.")
else:
print(f"Error de conexión a InfluxDB: {health.message}!")

Expected behavior

I expect client.health() to return a pass or the error code

Actual behavior

My program fails with the following error message:

health = client.health()
AttributeError: 'InfluxDBClient' object has no attribute 'health'

Additional info

No response

@integraciones-tiagora integraciones-tiagora added the bug Something isn't working label Sep 3, 2023
@bednar
Copy link
Contributor

bednar commented Sep 5, 2023

Hi @integraciones-tiagora,

¿ Do I need to upgrade my client? ¿Or is there any other available way to check the health of my connection?

You have to use the v2 client: https://github.com/influxdata/influxdb-client-python#pip-install. You are currently using the v1 client.

Regards

@integraciones-tiagora
Copy link
Author

Thanks! I will try it and let you know.

Best regards, Rogelio

@powersj powersj closed this as not planned Won't fix, can't repro, duplicate, stale May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants