Description

You can access all active Contrail alarms from the analytics node by using the curl command and directly querying the Contrail-API server.

The curl command can be run from any system that has direct access to the controller nodes. Therefore, it is mandatory to have direct access to the controllers to access all active Contrail alarms.

In this article, we have tried to explain how to access the alarms by using the curl command from the director because the director has direct access to the VIP of the controller's cluster.

Solution

Access Contrail alarms by using the Director node

  1. Log in to the Director node and generate a token that can be used in the curl command for accessing the alarms through the Contrail-API server.

[stack@queensa ~]$ source overcloudrc
(overcloud) [stack@queensa ~]$ openstack token issue
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field      | Value                                                                                                                                                                                   |
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| expires    | 2022-12-06T14:35:12+0000                                                                                                                                                                |
| id         | gAAAAABjj0UQapGcYU7im-kF-rZB2cvWaY9r54zGRl1CZZz7p_iUmzixYdrc18Bm07Bx5UsvnBHUkWZzEe7RSmKTfCo5rFNMWNFgvBenEbXYXqng8exUwIcfYClIjBQGeXbjJDZ5JMDrgfdnOH-vwfFERin5NFete_tLW-u2k1jZU6YR6X_ZdO0 |
| project_id | b2b51817422a4ff698a6ae630df25b30                                                                                                                                                        |
| user_id    | a574b467c4114d3fbe02ec1d46b851a8                                                                                                                                                        |
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
(overcloud) [stack@queensa ~]$ 
  1. Use the token generated above to fetch the alarms by using the following curl command:

[stack@queensa ~]$ curl -X GET -H "X-Auth-Token:gAAAAABjj0UQapGcYU7im-kF-rZB2cvWaY9r54zGRl1CZZz7p_iUmzixYdrc18Bm07Bx5UsvnBHUkWZzEe7RSmKTfCo5rFNMWNFgvBenEbXYXqng8exUwIcfYClIjBQGeXbjJDZ5JMDrgfdnOH-vwfFERin5NFete_tLW-u2k1jZU6YR6X_ZdO0" http://Controller-VIP-IP:8081/analytics/alarms | python -mjson.tool
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  5981  100  5981    0     0  11528      0 --:--:-- --:--:-- --:--:-- 11568
{
    "config-database-node": [
        {
            "name": "overcloud-contrailcontroller-0.localdomain",
            "value": {
                "UVEAlarms": {
                    "__T": 1666158931723292,
                    "alarms": [
                        {
                            "ack": false,
                            "alarm_rules": {
                                "or_list": [
                                    {
                                        "and_list": [
                                            {
                                                "condition": {
                                                    "operand1": "NodeStatus.process_status.state",
                                                    "operand2": {
                                                        "json_value": "\"Functional\""
                                                    },
                                                    "operation": "!=",
                                                    "variables": [
                                                        "NodeStatus.process_status.module_id",
                                                        "NodeStatus.process_status.instance_id"
                                                    ]
                                                },
                                                "match": [
                                                    {
                                                        "json_operand1_value": "\"Non-Functional\"",
                                                        "json_variables": {
                                                            "NodeStatus.process_status.instance_id": "0",
                                                            "NodeStatus.process_status.module_id": "\"contrail-config-database-nodemgr\""
                                                        }
                                                    }
                                                ]
                                            }
                                        ]
                                    }
                                ]
                            },
                            "description": "Process(es) reporting as non-functional.",
                            "severity": 0,
                            "timestamp": 1662820034329115,
                            "token": "eyJ0aW1lc3RhbXAiOiAxNjYyODIwMDM0MzI5MTE1LCAiaHR0cF9wb3J0IjogNTk5NSwgImhvc3RfaXAiOiAiMTAuMS4wLjEwNiJ9",
                            "type": "default-global-system-config:system-defined-process-connectivity"
                        }
                    ]
                }
            }
        },

The response to the curl command includes all the alarms that are present on the Analytics node. In the example output above, we see only one alarm. "ack": false tells us that the alarm is active and the "description" field gives us the alarm detail.

Note: Outputs can be different based on the system and the number of alarms.

Modification History

2022-12-19: Initial version

Related Information

The controller-VIP IP address can be determined from the overcloudrc file. Look at the parameter defined as below:
export OS_AUTH_URL=http://Controller-VIP:5000//v3