|
| 1 | +.. _mcli-cm-performanceadvisor-slowQueryLogs-cmd: |
| 2 | + |
| 3 | +======================================================= |
| 4 | +mongocli cloud-manager performanceAdvisor slowQueryLogs |
| 5 | +======================================================= |
| 6 | + |
| 7 | +.. default-domain:: mongodb |
| 8 | + |
| 9 | +.. contents:: On this page |
| 10 | + :local: |
| 11 | + :backlinks: none |
| 12 | + :depth: 1 |
| 13 | + :class: singlecol |
| 14 | + |
| 15 | +.. include:: /includes/styles/corrections.rst |
| 16 | + |
| 17 | +The ``performanceAdvisor slowQueryLogs`` command |
| 18 | +retrieves a list of log lines for slow queries. You can also analyze slow queries through the |cloud-short| :cloudmgr:`UI</analyze-slow-queries/>` or :cloudmgr:`API</reference/api/performance-advisor-get-slow-queries/>`. |
| 19 | + |
| 20 | +Syntax |
| 21 | +------ |
| 22 | + |
| 23 | +.. code-block:: text |
| 24 | + |
| 25 | + mongocli cloud-manager|cm performanceadvisor slowQueryLog|s ls |
| 26 | + --hostId <host-name> |
| 27 | + [ --since <unix-epoch-timestamp> ] |
| 28 | + [ --duration <milliseconds> ] |
| 29 | + [ --nLogs <max-log-lines> ] |
| 30 | + [ --namespace <namespaces> ] |
| 31 | + [ --projectId <project-ID> ] |
| 32 | + |
| 33 | +.. include:: /includes/fact-command-line-help.rst |
| 34 | + |
| 35 | +.. _cm-performanceadvisor-slowQueryLogs-options: |
| 36 | + |
| 37 | +Options |
| 38 | +------- |
| 39 | + |
| 40 | +.. list-table:: |
| 41 | + :widths: 20 10 60 10 |
| 42 | + :header-rows: 1 |
| 43 | + |
| 44 | + * - Option |
| 45 | + - Type |
| 46 | + - Description |
| 47 | + - Required? |
| 48 | + |
| 49 | + * - ``--hostId`` |
| 50 | + - string |
| 51 | + - The unique identifier of the host of a MongoDB process. Use the |
| 52 | + ``process list`` :ref:`command <mcli-cm-process-list-cmd>` to retrieve your ``hostId``. |
| 53 | + - yes |
| 54 | + |
| 55 | + * - ``--since`` |
| 56 | + - integer |
| 57 | + - Point in time, specified as a |epoch-time-ms|, from which you |
| 58 | + want to retrieve results. |
| 59 | + - no |
| 60 | + |
| 61 | + * - ``--duration`` |
| 62 | + - string |
| 63 | + - Length of time from the ``since`` parameter, in milliseconds, |
| 64 | + for which you want to retrieve results. |
| 65 | + - no |
| 66 | + |
| 67 | + * - ``--nLogs`` |
| 68 | + - integer |
| 69 | + - Maximum number of log lines to return. Defaults to 20000. |
| 70 | + - no |
| 71 | + |
| 72 | + * - ``--namespace`` |
| 73 | + - string |
| 74 | + - Namespace from which to retrieve slow query logs. A namespace |
| 75 | + consists of the database and collection resource separated by a ``.``, such as ``<database>.<collection>``. |
| 76 | + - no |
| 77 | + |
| 78 | + * - ``--projectId`` |
| 79 | + - string |
| 80 | + - Unique identifier of the project that contains the host |
| 81 | + for which you want to retrieve slow-running queries. If omitted, uses the project ID in the profile or :ref:`environment variable |
| 82 | + <mcli-env-var>`. |
| 83 | + - no |
| 84 | + |
| 85 | +.. note:: |
| 86 | + |
| 87 | + If ``since`` is indicated and ``duration`` is omitted, the response contains results from the since point up to the present time. |
| 88 | + |
| 89 | + If ``duration`` is indicated and ``since`` is omitted, the response contains results from duration ms ago through the present time. |
| 90 | + |
| 91 | + If both ``since`` and ``duration`` are omitted, the response contains results from the previous 24 hours up through the present time. |
| 92 | + |
| 93 | +.. _cm-performanceadvisor-slowQueryLogs-output: |
| 94 | + |
| 95 | +Output |
| 96 | +------ |
| 97 | + |
| 98 | +If the command succeeds, it returns the following output in the default |
| 99 | +format. If the command returns errors, see |
| 100 | +:ref:`Troubleshooting <troubleshooting>` for recommended solutions. |
| 101 | + |
| 102 | +.. code-block:: sh |
| 103 | + :copyable: false |
| 104 | + |
| 105 | + NAMESPACE LINE |
| 106 | + <database>.<collection> log line |
| 107 | + |
| 108 | +.. include:: /includes/fact-default-output.rst |
| 109 | + |
| 110 | +- :cloudmgr:`Cloud Manager API </reference/api/performance-advisor-get-slow-queries/>` |
| 111 | + |
| 112 | +Example |
| 113 | +------- |
| 114 | + |
| 115 | +.. tabs:: |
| 116 | + |
| 117 | + .. tab:: Default Output |
| 118 | + :tabid: default-output |
| 119 | + |
| 120 | + The following command retrieves the namespaces for collections |
| 121 | + experiencing slow queries for a project using the |
| 122 | + {+default-profile+}, which contains credentials to access the |
| 123 | + project and the project ID. The output is returned in the default |
| 124 | + format. |
| 125 | + |
| 126 | + .. code-block:: sh |
| 127 | + |
| 128 | + mongocli cm performanceAdvisor slowQueryLogs ls --hostId 78b0e5ae329f98047bddeac69ab40bc5 |
| 129 | + |
| 130 | + The previous command prints the following to the terminal. |
| 131 | + |
| 132 | + .. code-block:: sh |
| 133 | + :copyable: false |
| 134 | + |
| 135 | + NAMESPACE LINE |
| 136 | + myDB.users "2018-08-16T22:53:43.447+0000 I COMMAND [conn10614] command myDb.users appName: \"MongoDB Shell\" command: find { find: \"users\", filter: { emails: \" [email protected]\" }, lsid: { id: UUID(\"832b4b0e-085a-480e-b470-16a0994dc7cb\") }, $clusterTime: { clusterTime: Timestamp(1534460016, 1)..." |
| 137 | + myDB.users "2018-08-16T22:54:32.705+0000 I COMMAND [conn10614] command myDb.users appName: \"MongoDB Shell\" command: find { find: \"users\", filter: { emails: \" [email protected]\" }, lsid: { id: UUID(\"832b4b0e-085a-480e-b470-16a0994dc7cb\") }, $clusterTime: { clusterTime: Timestamp(1534460056, 1), ..." |
| 138 | + |
| 139 | + .. tab:: JSON Output |
| 140 | + :tabid: json-output |
| 141 | + |
| 142 | + The following command retrieves the namespaces for collections |
| 143 | + experiencing slow queries for a project using the |
| 144 | + {+default-profile+}, which contains credentials to access the |
| 145 | + project and the project ID. The output is returned in |json| |
| 146 | + format. |
| 147 | + |
| 148 | + .. code-block:: sh |
| 149 | + |
| 150 | + mongocli cm performanceAdvisor slowQueryLogs ls --hostId 78b0e5ae329f98047bddeac69ab40bc5 --output json |
| 151 | + |
| 152 | + The previous command prints the following to the terminal in |
| 153 | + |json| format. |
| 154 | + |
| 155 | + .. code-block:: json |
| 156 | + :copyable: false |
| 157 | + |
| 158 | + { |
| 159 | + "slowQueries": [ |
| 160 | + { |
| 161 | + "line" : "2018-08-16T22:53:43.447+0000 I COMMAND [conn10614] command myDb.users appName: \"MongoDB Shell\" command: find { find: \"users\", filter: { emails: \" [email protected]\" }, lsid: { id: UUID(\"832b4b0e-085a-480e-b470-16a0994dc7cb\") }, $clusterTime: { clusterTime: Timestamp(1534460016, 1)...", |
| 162 | + "namespace": "myDB.users" |
| 163 | + }, |
| 164 | + { |
| 165 | + "line": "2018-08-16T22:54:32.705+0000 I COMMAND [conn10614] command myDb.users appName: \"MongoDB Shell\" command: find { find: \"users\", filter: { emails: \" [email protected]\" }, lsid: { id: UUID(\"832b4b0e-085a-480e-b470-16a0994dc7cb\") }, $clusterTime: { clusterTime: Timestamp(1534460056, 1), ...", |
| 166 | + "namespace": "myDB.users" |
| 167 | + } |
| 168 | + ] |
| 169 | + } |
0 commit comments