| 1 |
================= |
| 2 |
Using monasca CLI |
| 3 |
================= |
| 4 |
|
| 5 |
The **monasca** shell utility interacts with OpenStack Monitoring API from the |
| 6 |
command-line. It supports the entire features of OpenStack Monitoring API. |
| 7 |
|
| 8 |
Basic Usage |
| 9 |
----------- |
| 10 |
|
| 11 |
In order to use the CLI, you must provide your OpenStack username, password, |
| 12 |
project, domain information for both user and project, and auth endpoint. Use |
| 13 |
the corresponding configuration options (``--os-username``, ``--os-password``, |
| 14 |
``--os-project-name``, ``--os-user-domain-id``, ``os-project-domain-id``, and |
| 15 |
``--os-auth-url``), but it is easier to set them in environment variables. |
| 16 |
|
| 17 |
.. code-block:: shell |
| 18 |
|
| 19 |
export OS_USERNAME=mini-mon |
| 20 |
export OS_PASSWORD=password |
| 21 |
export OS_PROJECT_NAME=mini-mon |
| 22 |
export OS_USER_DOMAIN_ID=default |
| 23 |
export OS_PROJECT_DOMAIN_ID=default |
| 24 |
export OS_AUTH_URL=http://keystone:5000/v3 |
| 25 |
|
| 26 |
If you are using Identity v2.0 API (DEPRECATED), you don't need to pass domain |
| 27 |
information. |
| 28 |
|
| 29 |
.. code-block:: shell |
| 30 |
|
| 31 |
export OS_USERNAME=mini-mon |
| 32 |
export OS_PASSWORD=password |
| 33 |
export OS_TENANT_NAME=mini-mon |
| 34 |
export OS_AUTH_URL=http://keystone:5000/v2.0 |
| 35 |
|
| 36 |
Once you've configured your authentication parameters, you can run **monasca** |
| 37 |
commands. All commands take the form of: |
| 38 |
|
| 39 |
.. code-block:: text |
| 40 |
|
| 41 |
monasca <command> [arguments...] |
| 42 |
|
| 43 |
Run **monasca help** to get a full list of all possible commands, and run |
| 44 |
**monasca help <command>** to get detailed help for that command. |
| 45 |
|
| 46 |
Using with os-client-config |
| 47 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 48 |
|
| 49 |
`os-client-config <https://docs.openstack.org/os-client-config/latest/>`_ |
| 50 |
provides more convenient way to manage a collection of client configurations |
| 51 |
and you can easily switch multiple OpenStack-based configurations. |
| 52 |
|
| 53 |
To use os-client-config, you first need to prepare |
| 54 |
``~/.config/openstack/clouds.yaml`` like the following. |
| 55 |
|
| 56 |
.. code-block:: yaml |
| 57 |
|
| 58 |
clouds: |
| 59 |
monitoring: |
| 60 |
auth: |
| 61 |
auth_url: http://keystone:5000 |
| 62 |
password: password |
| 63 |
project_domain_id: default |
| 64 |
project_name: mini-mon |
| 65 |
user_domain_id: default |
| 66 |
username: mini-mon |
| 67 |
identity_api_version: '3' |
| 68 |
region_name: RegionOne |
| 69 |
|
| 70 |
Then, you need to specify a configuration name defined in the above |
| 71 |
clouds.yaml. |
| 72 |
|
| 73 |
.. code-block:: shell |
| 74 |
|
| 75 |
export OS_CLOUD=monitoring |
| 76 |
|
| 77 |
For more detail information, see the |
| 78 |
`os-client-config <https://docs.openstack.org/os-client-config/latest/>`_ |
| 79 |
documentation. |
| 80 |
|
| 81 |
Using with keystone token |
| 82 |
~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 83 |
|
| 84 |
The command-line tool will attempt to re-authenticate using your provided |
| 85 |
credentials for every request. You can override this behavior by manually |
| 86 |
supplying an auth token using ``--os-url`` and ``--os-auth-token``. You can |
| 87 |
alternatively set these environment variables. |
| 88 |
|
| 89 |
.. code-block:: shell |
| 90 |
|
| 91 |
export OS_URL=http://monasca.example.org:8070/ |
| 92 |
export OS_TOKEN=3bcc3d3a03f44e3d8377f9247b0ad155 |
| 93 |
|
| 94 |
Usage Examples |
| 95 |
---------------- |
| 96 |
|
| 97 |
metric-create:: |
| 98 |
|
| 99 |
monasca metric-create cpu1 123.40 |
| 100 |
monasca metric-create metric1 1234.56 --dimensions instance_id=123,service=ourservice |
| 101 |
monasca metric-create metric1 2222.22 --dimensions instance_id=123,service=ourservice |
| 102 |
monasca metric-create metric1 3333.33 --dimensions instance_id=222,service=ourservice |
| 103 |
monasca metric-create metric1 4444.44 --dimensions instance_id=222 --value-meta rc=404 |
| 104 |
|
| 105 |
metric-list:: |
| 106 |
|
| 107 |
monasca metric-list |
| 108 |
+---------+--------------------+ |
| 109 |
| name | dimensions | |
| 110 |
+---------+--------------------+ |
| 111 |
| cpu1 | | |
| 112 |
| metric1 | instance_id:123 | |
| 113 |
| | service:ourservice | |
| 114 |
+---------+--------------------+ |
| 115 |
|
| 116 |
measurement-list:: |
| 117 |
|
| 118 |
monasca measurement-list metric1 2014-01-01T00:00:00Z |
| 119 |
+---------+--------------------+----------------+----------------------+--------------+-------------+ |
| 120 |
| name | dimensions | measurement_id | timestamp | value | value_meta | |
| 121 |
+---------+--------------------+----------------+----------------------+--------------+-------------+ |
| 122 |
| metric1 | instance_id:123 | 723885 | 2014-05-08T21:46:32Z | 1234.56 | | |
| 123 |
| | service:ourservice | 725951 | 2014-05-08T21:48:50Z | 2222.22 | | |
| 124 |
| metric1 | instance_id:222 | 726837 | 2014-05-08T21:49:47Z | 3333.33 | | |
| 125 |
| | service:ourservice | 726983 | 2014-05-08T21:50:27Z | 4444.44 | rc: 404 | |
| 126 |
+---------+--------------------+----------------+----------------------+--------------+-------------+ |
| 127 |
|
| 128 |
monasca measurement-list metric1 2014-01-01T00:00:00Z --dimensions instance_id=123 |
| 129 |
+---------+--------------------+----------------+----------------------+--------------+-------------+ |
| 130 |
| name | dimensions | measurement_id | timestamp | value | value_meta | |
| 131 |
+---------+--------------------+----------------+----------------------+--------------+-------------+ |
| 132 |
| metric1 | instance_id:123 | 723885 | 2014-05-08T21:46:32Z | 1234.56 | | |
| 133 |
| | service:ourservice | 725951 | 2014-05-08T21:48:50Z | 2222.22 | | |
| 134 |
+---------+--------------------+----------------+----------------------+--------------+-------------+ |
| 135 |
|
| 136 |
|
| 137 |
Notifications Examples |
| 138 |
~~~~~~~~~~~~~~~~~~~~~~ |
| 139 |
Note: To see complete usage: 'monasca help' and 'monasca help <command>' |
| 140 |
|
| 141 |
notification-create:: |
| 142 |
|
| 143 |
monasca notification-create cindyemail1 EMAIL [email protected] |
| 144 |
monasca notification-create myapplication WEBHOOK http://localhost:5000 |
| 145 |
monasca notification-create mypagerduty PAGERDUTY nzH2LVRdMzun11HNC2oD |
| 146 |
|
| 147 |
notification-list:: |
| 148 |
|
| 149 |
monasca notification-list |
| 150 |
+---------------+--------------------------------------+-------+----------------------+ |
| 151 |
| name | id | type | address | |
| 152 |
+---------------+--------------------------------------+-------+----------------------+ |
| 153 |
| cindyemail1 | 5651406c-447d-40bd-b868-b2b3e6b59e32 | EMAIL |[email protected] | |
| 154 |
| myapplication | 55905ce2-91e3-41ce-b45a-de7032f8d718 | WEBHOOK |http://localhost:5000 |
| 155 |
| mypagerduty | 5720ccb5-6a3d-22ba-545g-ce467a5b41a2 | PAGERDUTY |nzH2LVRdMzun11HNC2oD |
| 156 |
+---------------+--------------------------------------+-------+----------------------+ |
| 157 |
|
| 158 |
|
| 159 |
Alarms Examples |
| 160 |
~~~~~~~~~~~~~~~ |
| 161 |
Note: To see complete usage: 'monasca help' and 'monasca help <command>' |
| 162 |
|
| 163 |
alarm-definition-create:: |
| 164 |
|
| 165 |
monasca alarm-definition-create alarmPerHost "max(cpu.load_avg_1_min) > 0" --match-by hostname |
| 166 |
|
| 167 |
alarm-definition-list:: |
| 168 |
|
| 169 |
+--------------+--------------------------------------+-----------------------------+----------+-----------------+ |
| 170 |
| name | id | expression | match_by | actions_enabled | |
| 171 |
+--------------+--------------------------------------+-----------------------------+----------+-----------------+ |
| 172 |
| alarmPerHost | 4bf6bfc2-c5ac-4d57-b7db-cf5313b05412 | max(cpu.load_avg_1_min) > 0 | hostname | True | |
| 173 |
+--------------+--------------------------------------+-----------------------------+----------+-----------------+ |
| 174 |
|
| 175 |
alarm-definition-show:: |
| 176 |
|
| 177 |
monasca alarm-definition-show 4bf6bfc2-c5ac-4d57-b7db-cf5313b05412 |
| 178 |
+----------------------+----------------------------------------------------------------------------------------------------+ |
| 179 |
| Property | Value | |
| 180 |
+----------------------+----------------------------------------------------------------------------------------------------+ |
| 181 |
| actions_enabled | true | |
| 182 |
| alarm_actions | [] | |
| 183 |
| description | "" | |
| 184 |
| expression | "max(cpu.load_avg_1_min) > 0" | |
| 185 |
| id | "4bf6bfc2-c5ac-4d57-b7db-cf5313b05412" | |
| 186 |
| links | href:http://192.168.10.4:8070/v2.0/alarm-definitions/4bf6bfc2-c5ac-4d57-b7db-cf5313b05412,rel:self | |
| 187 |
| match_by | [ | |
| 188 |
| | "hostname" | |
| 189 |
| | ] | |
| 190 |
| name | "alarmPerHost" | |
| 191 |
| ok_actions | [] | |
| 192 |
| severity | "LOW" | |
| 193 |
| undetermined_actions | [] | |
| 194 |
+----------------------+----------------------------------------------------------------------------------------------------+ |
| 195 |
|
| 196 |
alarm-definition-delete:: |
| 197 |
|
| 198 |
monasca alarm-definition-delete 4bf6bfc2-c5ac-4d57-b7db-cf5313b05412 |
| 199 |
|
| 200 |
alarm-list:: |
| 201 |
|
| 202 |
monasca alarm-list |
| 203 |
+--------------------------------------+--------------------------------------+----------------+---------------+---------------------+----------+-------+--------------------------+--------------------------+ |
| 204 |
| id | alarm_definition_id | alarm_name | metric_name | metric_dimensions | severity | state | state_updated_timestamp | created_timestamp | |
| 205 |
+--------------------------------------+--------------------------------------+----------------+---------------+---------------------+----------+-------+--------------------------+--------------------------+ |
| 206 |
| 11e8c15d-0263-4b71-a8b8-4ecdaeb2902c | af1f347b-cddb-46da-b7cc-924261eeecdf | High CPU usage | cpu.idle_perc | hostname: devstack | LOW | OK | 2015-03-26T21:45:15.000Z | 2015-03-26T21:41:50.000Z | |
| 207 |
| e5797cfe-b66e-4d44-98cd-3c7fc62d4c33 | af1f347b-cddb-46da-b7cc-924261eeecdf | High CPU usage | cpu.idle_perc | hostname: mini-mon | LOW | OK | 2015-03-26T21:43:15.000Z | 2015-03-26T21:41:47.000Z | |
| 208 |
| | | | | service: monitoring | | | | | |
| 209 |
+--------------------------------------+--------------------------------------+----------------+---------------+---------------------+----------+-------+--------------------------+--------------------------+ |
| 210 |
|
| 211 |
alarm-history:: |
| 212 |
|
| 213 |
monasca alarm-history 9d748b72-939b-45e7-a807-c0c5ad88d3e4 |
| 214 |
+--------------------------------------+-----------+--------------+------------------------------------------------------------------------------+-------------+--------------------+---------------------+--------------------------+ |
| 215 |
| alarm_id | new_state | old_state | reason | reason_data | metric_name | metric_dimensions | timestamp | |
| 216 |
+--------------------------------------+-----------+--------------+------------------------------------------------------------------------------+-------------+--------------------+---------------------+--------------------------+ |
| 217 |
| 9d748b72-939b-45e7-a807-c0c5ad88d3e4 | ALARM | UNDETERMINED | Thresholds were exceeded for the sub-alarms: [max(cpu.load_avg_1_min) > 0.0] | {} | cpu.load_avg_1_min | hostname: mini-mon | 2014-10-14T21:14:11.000Z | |
| 218 |
| | | | | | | service: monitoring | | |
| 219 |
+--------------------------------------+-----------+--------------+------------------------------------------------------------------------------+-------------+--------------------+---------------------+--------------------------+ |
| 220 |
|
| 221 |
|
| 222 |
alarm-patch:: |
| 223 |
|
| 224 |
monasca alarm-patch fda5537b-1550-435f-9d6c-262b7e05065b --state OK |