|
| 1 | +.. _monitoring-getting_started: |
| 2 | + |
| 3 | +Getting started with monitoring |
| 4 | +=============================== |
| 5 | + |
| 6 | +.. NOTE:: |
| 7 | + |
| 8 | + If you use Tarantool version below `2.11.1 <https://github.com/tarantool/tarantool/releases/tag/2.11.1>`__, |
| 9 | + it is necessary to install the latest version of `metrics <https://github.com/tarantool/metrics>`__ first. |
| 10 | + |
| 11 | +Main concepts: |
| 12 | + |
| 13 | +- overview |
| 14 | +- metrics configuration |
| 15 | +- metrics module |
| 16 | + |
| 17 | + |
| 18 | +.. _monitoring_overview: |
| 19 | + |
| 20 | +Overview |
| 21 | +-------- |
| 22 | + |
| 23 | +- collectors |
| 24 | +- built-in metrics |
| 25 | +- metrics of third-party plugins (crud, expirationd) |
| 26 | +- custom metrics |
| 27 | + |
| 28 | + |
| 29 | +.. _monitoring_quick_start: |
| 30 | + |
| 31 | +Quick start |
| 32 | +----------- |
| 33 | + |
| 34 | +Example on GitHub: `metrics <https://github.com/tarantool/doc/tree/latest/doc/code_snippets/snippets/config/instances.enabled/metrics>`_ |
| 35 | + |
| 36 | + |
| 37 | +1. Config (``config.yaml``) -- the :ref:`metrics <configuration_reference_metrics>` section: |
| 38 | + |
| 39 | + .. literalinclude:: /code_snippets/snippets/config/instances.enabled/metrics/config.yaml |
| 40 | + :end-before: roles: |
| 41 | + :language: yaml |
| 42 | + :dedent: |
| 43 | + |
| 44 | +2. Serve metrics using a :ref:`role <application_roles>` -- config: |
| 45 | + |
| 46 | + .. literalinclude:: /code_snippets/snippets/config/instances.enabled/metrics/config.yaml |
| 47 | + :start-at: roles: |
| 48 | + :end-at: expose_prometheus_metrics |
| 49 | + :language: yaml |
| 50 | + :dedent: |
| 51 | + |
| 52 | +3. Create ``expose_prometheus_metrics.lua`` in the ``examples`` directory next to the ``config.yaml`` file: |
| 53 | + |
| 54 | + .. literalinclude:: /code_snippets/snippets/config/instances.enabled/metrics/examples/expose_prometheus_metrics.lua |
| 55 | + :language: lua |
| 56 | + :dedent: |
| 57 | + |
| 58 | +4. Install the `http <https://github.com/tarantool/http>`__ external module: |
| 59 | + |
| 60 | + .. code-block:: console |
| 61 | +
|
| 62 | + $ tt rocks install http |
| 63 | +
|
| 64 | +5. Start app: |
| 65 | + |
| 66 | + .. code-block:: console |
| 67 | +
|
| 68 | + $ tt start metrics |
| 69 | +
|
| 70 | + Access metrics `http://127.0.0.1:8080/metrics/prometheus <http://127.0.0.1:8080/metrics/prometheus>`_. |
| 71 | + |
| 72 | +6. Prometheus scrape config (``prometheus.yml``): |
| 73 | + |
| 74 | + .. literalinclude:: /code_snippets/snippets/config/instances.enabled/metrics/prometheus.yml |
| 75 | + :language: yaml |
| 76 | + :dedent: |
| 77 | + |
| 78 | + |
| 79 | + |
| 80 | + |
| 81 | + |
| 82 | +.. _monitoring_configuring_metrics: |
| 83 | + |
| 84 | +Configuring metrics |
| 85 | +------------------- |
| 86 | + |
| 87 | +Example 1 (built-in) |
| 88 | + |
| 89 | +.. literalinclude:: /code_snippets/snippets/config/instances.enabled/metrics/config.yaml |
| 90 | + :end-before: roles: |
| 91 | + :language: yaml |
| 92 | + :dedent: |
| 93 | + |
| 94 | + |
| 95 | +Example 2 (third-party) |
| 96 | + |
| 97 | +The example below shows how to enable statistics on called operations by providing the ``roles.crud-router`` role's configuration: |
| 98 | + |
| 99 | +.. literalinclude:: /code_snippets/snippets/sharding/instances.enabled/sharded_cluster_crud/config.yaml |
| 100 | + :language: yaml |
| 101 | + :start-at: roles.crud-router |
| 102 | + :end-at: stats_quantile_max_age_time |
| 103 | + :dedent: |
| 104 | + |
| 105 | +Example on GitHub: `sharded_cluster_crud <https://github.com/tarantool/doc/tree/latest/doc/code_snippets/snippets/sharding/instances.enabled/sharded_cluster_crud>`_ |
| 106 | + |
| 107 | + |
| 108 | + |
| 109 | +.. _monitoring_using_metrics_module: |
| 110 | + |
| 111 | +Using the 'metrics' module |
| 112 | +-------------------------- |
| 113 | + |
| 114 | +.. _metrics-plugins-available: |
| 115 | +.. _monitoring_plugins_for_exposing_metrics: |
| 116 | + |
| 117 | +Plugins for exposing metrics |
| 118 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 119 | + |
| 120 | +Prometheus (:ref:`metrics-prometheus-api_reference`): |
| 121 | + |
| 122 | +.. literalinclude:: /code_snippets/snippets/config/instances.enabled/metrics/examples/expose_prometheus_metrics.lua |
| 123 | + :start-at: local prometheus_plugin |
| 124 | + :end-at: local prometheus_metrics |
| 125 | + :language: lua |
| 126 | + :dedent: |
| 127 | + |
| 128 | +JSON (:ref:`metrics-json-api_reference`): |
| 129 | + |
| 130 | +.. literalinclude:: /code_snippets/snippets/config/instances.enabled/metrics/examples/expose_json_metrics.lua |
| 131 | + :start-at: local json_plugin |
| 132 | + :end-at: local json_metrics |
| 133 | + :language: lua |
| 134 | + :dedent: |
| 135 | + |
| 136 | +Graphite (:ref:`metrics-graphite-api_reference`): |
| 137 | + |
| 138 | +.. code-block:: lua |
| 139 | +
|
| 140 | + local graphite_plugin = require('metrics.plugins.graphite') |
| 141 | + graphite_plugin.init { |
| 142 | + prefix = 'tarantool', |
| 143 | + host = '127.0.0.1', |
| 144 | + port = 2003, |
| 145 | + send_interval = 1, |
| 146 | + } |
| 147 | +
|
| 148 | +
|
| 149 | +.. NOTE:: |
| 150 | + |
| 151 | + Custom plugins note. |
| 152 | + |
| 153 | + |
| 154 | + |
| 155 | +.. _monitoring_metrics_collecting: |
| 156 | + |
| 157 | +Collecting metrics |
| 158 | +~~~~~~~~~~~~~~~~~~ |
| 159 | + |
| 160 | +TODO |
| 161 | + |
| 162 | + |
| 163 | +.. _monitoring_metrics_collecting_http: |
| 164 | + |
| 165 | +Collecting HTTP metrics |
| 166 | +~~~~~~~~~~~~~~~~~~~~~~~ |
| 167 | + |
| 168 | +Example: |
| 169 | + |
| 170 | +.. literalinclude:: /code_snippets/snippets/config/instances.enabled/metrics/examples/collect_http_metrics.lua |
| 171 | + :start-after: Collect HTTP metrics |
| 172 | + :end-at: httpd:start() |
| 173 | + :language: lua |
| 174 | + :dedent: |
| 175 | + |
| 176 | + |
| 177 | + |
| 178 | +.. _monitoring_metrics_collecting_custom_metrics: |
| 179 | + |
| 180 | +Collecting custom metrics |
| 181 | +~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 182 | + |
| 183 | +Example 1: |
| 184 | + |
| 185 | +.. literalinclude:: /code_snippets/snippets/config/instances.enabled/metrics/examples/collect_custom_replace_count.lua |
| 186 | + :start-after: Collect a custom metric |
| 187 | + :end-before: -- End -- |
| 188 | + :language: lua |
| 189 | + :dedent: |
| 190 | + |
| 191 | + |
| 192 | +Example 2: |
| 193 | + |
| 194 | +.. literalinclude:: /code_snippets/snippets/config/instances.enabled/metrics/examples/collect_custom_waste_size.lua |
| 195 | + :start-after: Collect a custom metric |
| 196 | + :end-before: -- End -- |
| 197 | + :language: lua |
| 198 | + :dedent: |
| 199 | + |
| 200 | + |
0 commit comments