Aodh Client Library

raw JSON →
3.10.1 verified Fri May 01 auth: no python

Python client library for the OpenStack Aodh alarming service. Provides programmatic access to alarm management (create, update, delete, list) and alarm evaluation history. Current version is 3.10.1, released for Python >=3.10. Maintained as part of the OpenStack project.

pip install aodhclient
error AttributeError: module 'aodhclient' has no attribute 'client'
cause Importing from the wrong module; using from aodhclient import client instead of from aodhclient.v2 import client
fix
Use 'from aodhclient.v2 import client'
error keystoneauth1.exceptions.http.Unauthorized: The request you have made requires authentication.
cause Invalid or missing authentication credentials, or incorrect auth URL/domain.
fix
Double-check environment variables: OS_AUTH_URL, OS_USERNAME, OS_PASSWORD, OS_PROJECT_NAME, OS_USER_DOMAIN_NAME, OS_PROJECT_DOMAIN_NAME.
error aodhclient.exceptions.AodhClientException: Bad Request
cause The alarm data provided to create or update is missing required fields or has invalid values.
fix
Ensure all required fields (e.g., 'name', 'type', 'threshold_rule' with 'meter_name'/'threshold') are present and correct.
breaking In version 3.x, the aodhclient.v2.client.Client is the correct entry point. Version 2.0.0 dropped Python 2 support and v1 client. Always use v2.
fix Import from aodhclient.v2.client instead of aodhclient.client.
gotcha The aodhclient uses request bodies as dicts but expects proper formatting. A common mistake is forgetting to pass the correct project ID in the alarm payload, leading to 'Bad request' errors.
fix Always include required fields like 'name', 'type', 'threshold_rule', etc. Check official Aodh documentation for valid alarm schemas.
deprecated Using password authentication directly (Password auth plugin) is deprecated in favor of application credentials or token-based authentication for long-running services.
fix Consider using keystoneauth1.identity.v3.ApplicationCredential instead.

Authenticate using Keystone v3 and list all alarms.

from aodhclient.v2 import client
from keystoneauth1.identity import v3
from keystoneauth1 import session

auth = v3.Password(auth_url=os.environ.get('OS_AUTH_URL', 'http://localhost:5000/v3'),
                   username=os.environ.get('OS_USERNAME', 'admin'),
                   password=os.environ.get('OS_PASSWORD', 'password'),
                   project_name=os.environ.get('OS_PROJECT_NAME', 'admin'),
                   user_domain_name='Default',
                   project_domain_name='Default')
sess = session.Session(auth=auth)
cli = client.Client(session=sess)
try:
    alarms = cli.alarm.list()
    print(alarms)
except Exception as e:
    print(f'Error: {e}')