diff --git a/admin_manual/configuration_monitoring/index.rst b/admin_manual/configuration_monitoring/index.rst new file mode 100644 index 00000000000..fcaefeb13dd --- /dev/null +++ b/admin_manual/configuration_monitoring/index.rst @@ -0,0 +1,24 @@ +========== +Monitoring +========== + +OpenMetrics +----------- + +.. versionadded:: 33 + +Nextcloud exposes a ``/metrics`` endpoint. By default, it responds only on localhost. +You can change this behaviour with :ref:`OpenMetrics configuration`. + +.. note: + + Please ensure this endpoint is not accessible to everyone as it could lead to some load on your server. + + +You can view the content of this endpoint with the following command: + +:: + + curl "https://your.domain/metrics" + + diff --git a/admin_manual/configuration_server/config_sample_php_parameters.rst b/admin_manual/configuration_server/config_sample_php_parameters.rst index 41a058bd251..0ce62552b45 100644 --- a/admin_manual/configuration_server/config_sample_php_parameters.rst +++ b/admin_manual/configuration_server/config_sample_php_parameters.rst @@ -3290,6 +3290,40 @@ hashingCost The hashing cost used by hashes generated by Nextcloud Using a higher value requires more time and CPU power to calculate the hashes +.. _label_openmetrics_config: + +OpenMetrics exporter +-------------------- + +Nextcloud exposes some OpenMetrics metrics on the ``/metrics`` endpoint. + +openmetrics_allowed_clients +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +:: + + 'openmetrics_allowed_clients' => [ + '192.168.0.0/16', + 'fe80::/10', + '10.0.0.1', + ]; + +By default, Nextcloud metrics are only sent to localhost clients. +This option allows to allow other clients by range or single IP address. + +openmetrics_skipped_classes +^^^^^^^^^^^^^^^^^^^^^^^^^^^ +:: + + 'openmetrics_skipped_classes' => [ + 'OC\OpenMetrics\Exporters\FilesByType', + 'OCA\Files_Sharing\OpenMetrics\SharesCount', + ]; + +Some metrics can be time consumming and not useful for you. +In this case, you can skip some metrics by using their full classname. + + All other configuration options ------------------------------- diff --git a/admin_manual/contents.rst b/admin_manual/contents.rst index 6442113fb16..29a833bebbf 100644 --- a/admin_manual/contents.rst +++ b/admin_manual/contents.rst @@ -65,6 +65,7 @@ Table of contents .. toctree:: :caption: Maintenance + configuration_monitoring/index maintenance/index issues/index diff --git a/developer_manual/digging_deeper/index.rst b/developer_manual/digging_deeper/index.rst index 0f152d42016..4f516d42cb9 100644 --- a/developer_manual/digging_deeper/index.rst +++ b/developer_manual/digging_deeper/index.rst @@ -24,6 +24,7 @@ Digging deeper notifications oidc out_of_office + openmetrics performance phonenumberutil psr diff --git a/developer_manual/digging_deeper/openmetrics.rst b/developer_manual/digging_deeper/openmetrics.rst new file mode 100644 index 00000000000..9f0a5b9da80 --- /dev/null +++ b/developer_manual/digging_deeper/openmetrics.rst @@ -0,0 +1,90 @@ +===================== +Open Metrics exporter +===================== + +.. versionadded:: 33.0 + +Nextcloud allows to export metrics using `OpenMetrics ` format. + +The data is available on the ``/metrics`` endpoint and can then be imported into any OpenMetrics (formerly Prometheus) enabled tool. + + +Register a new exporter +----------------------- + +Each exporter must be registered inside **/appinfo/info.xml**: + +.. code-block:: xml + + + OCA\MyApp\OpenMetrics\CustomExporter + OCA\MyApp\OpenMetrics\AnotherExporter + + + +Implement a new exporter +------------------------ + +Then you need to implement it: + +.. code-block:: php + + 'one value'], + ); + yield new Metric( + 1337, + ['label' => 'another value'], + ); + } + } + +This exporter will add something like this on the ``/metrics`` endpoint: + +.. code-block:: + + # TYPE nextcloud_myapp_metric gauge + # UNIT nextcloud_myapp_metric units + # HELP nextcloud_myapp_metric Description of metric + nextcloud_myapp_metric{label="one value"} 42 + nextcloud_myapp_metric{backend="another value"} 1337 +