@@ -13,7 +13,7 @@ Magento Backend.
13
13
14
14
Install the Module via composer by running:
15
15
16
- ```
16
+ ``` shell
17
17
composer require run-as-root/magento2-prometheus-exporter
18
18
php bin/magento setup:upgrade
19
19
```
@@ -26,9 +26,9 @@ can enable or disable specific metrics by using the multiselect.
26
26
## Prometheus Configuration
27
27
28
28
After installing the Magento Module, your Prometheus needs to get pointed to your Magento Metrics endpoint. To do so,
29
- add the following lines to your prometheus.yml under scrape_configs:
29
+ add the following lines to your ` prometheus.yml ` under ` scrape_configs ` :
30
30
31
- ``` yaml
31
+ ``` yaml
32
32
- job_name : ' Magento 2 Exporter'
33
33
scrape_interval : 5m
34
34
scrape_timeout : 60s
@@ -40,6 +40,21 @@ add the following lines to your prometheus.yml under scrape_configs:
40
40
- your-magento-url
41
41
` ` `
42
42
43
+ ### Authorization
44
+
45
+ Your metrics endpoint should not be available to everyone, so the use of authorization is recommended.
46
+ The module provides support for authorization tokens via Magento Backend.
47
+
48
+ For Basic or Bearer authorization, the scrape job should be extended like this:
49
+
50
+ ` ` ` yaml
51
+ - job_name : ' Magento 2 Exporter'
52
+ [..]
53
+ authorization :
54
+ type : ' Bearer'
55
+ credentials : " {{ magento2_metrics_password }}"
56
+ ` ` `
57
+
43
58
## Module functionality
44
59
45
60
The module registers a cron job that runs every minute. The cronjob is responsible for aggregating the metric data. The
@@ -50,24 +65,24 @@ in the table and renders the correct response for prometheus.
50
65
51
66
The following metrics will be collected :
52
67
53
- | Metric | Labels | TYPE | Help |
54
- |:-------------------------------------|:--------------------------------|:--------|:--------------------------------------------------------------------------------|
55
- | magento_orders_count_total | status, store_code | gauge | All Magento Orders |
56
- | magento_orders_amount_total | status, store_code | gauge | Total amount of all Magento Orders |
57
- | magento_order_items_count_total | status, store_code | gauge | Total count of orderitems |
58
- | magento_cms_block_count_total | store_code | gauge | Total count of available cms blocks |
59
- | magento_cms_page_count_total | store_code | gauge | Total count of available cms pages |
60
- | magento_customer_count_total | store_code | gauge | Total count of available customer |
61
- | magento_cronjob_broken_count_total | | gauge | Broken CronJobs occur when when status is pending but execution_time is set. |
62
- | magento_cronjob_count_total | status, job_code | gauge | Total count of available CronJob Count. |
63
- | magento_indexer_backlog_count_total | title | gauge | Total count of backlog item in indexer (the data from `indexer:status` command) |
64
- | magento_shipments_count_total | source, store_code | counter | Count of Shipments created by store and source. |
65
- | magento_catalog_category_count_total | status, menu_status, store_code | gauge | Count of Categories by store, status and menu status. |
66
- | magento_store_count_total | status | gauge | Total count of Stores by status. |
67
- | magento_website_count_total | | gauge | Total count websites. |
68
- | magento_products_by_type_count_total | project_type | gauge | Total count of products by type. |
69
-
70
- # # Add you own Metric
68
+ | Metric | Labels | TYPE | Help |
69
+ |:-------------------------------------|:--------------------------------|:--------|:--------------------------------------------------------------------------------- |
70
+ | magento_orders_count_total | status, store_code | gauge | Total count of Magento Orders. |
71
+ | magento_orders_amount_total | status, store_code | gauge | Total amount of all Magento Orders. |
72
+ | magento_order_items_count_total | status, store_code | gauge | Total count of orderitems. |
73
+ | magento_cms_block_count_total | store_code | gauge | Total count of available cms blocks. |
74
+ | magento_cms_page_count_total | store_code | gauge | Total count of available cms pages. |
75
+ | magento_customer_count_total | store_code | gauge | Total count of available customers. |
76
+ | magento_cronjob_broken_count_total | | gauge | Broken CronJobs occur when when status is pending but execution_time is set. |
77
+ | magento_cronjob_count_total | status, job_code | gauge | Total count of available CronJob Count. |
78
+ | magento_indexer_backlog_count_total | title | gauge | Total count of backlog item in indexer (the data from `indexer:status` command). |
79
+ | magento_shipments_count_total | source, store_code | counter | Count of Shipments created by store and source. |
80
+ | magento_catalog_category_count_total | status, menu_status, store_code | gauge | Count of Categories by store, status and menu status. |
81
+ | magento_store_count_total | status | gauge | Total count of Stores by status. |
82
+ | magento_website_count_total | | gauge | Total count of websites. |
83
+ | magento_products_by_type_count_total | project_type | gauge | Total count of products by type. |
84
+
85
+ # # Add your own Metric
71
86
72
87
To add a new metric, you need to implement the `\RunAsRoot\PrometheusExporter\Api\MetricAggregatorInterface`. The metric
73
88
aggregator object is responsible for collecting the necessary information for the specific metric from magento and then
@@ -77,17 +92,17 @@ add a new metric record. New records can be easily added via
77
92
In addition to the implementation of the MetricAggregatorInterface, you have to add your specific Aggregator to the
78
93
`MetricAggregatorPool` defined in the `di.xml`. For example :
79
94
80
- ` ` ` xml
95
+ ` ` ` xml
81
96
<type name="RunAsRoot\P rometheusExporter\M etric\M etricAggregatorPool">
82
- <arguments>
83
- <argument name="items" xsi:type="array">
84
- <item name="OrderAmountAggregator" xsi:type="object">RunAsRoot\P rometheusExporter\A ggregator\O rder\O rderAmountAggregator</item>
85
- <item name="OrderCountAggregator" xsi:type="object">RunAsRoot\P rometheusExporter\A ggregator\O rder\O rderCountAggregator</item>
86
- <item name="OrderItemAmountAggregator" xsi:type="object">RunAsRoot\P rometheusExporter\A ggregator\O rder\O rderItemAmountAggregator</item>
87
- <item name="OrderItemCountAggregator" xsi:type="object">RunAsRoot\P rometheusExporter\A ggregator\O rder\O rderItemCountAggregator</item>
88
- </argument>
89
- </arguments>
90
- </type>
97
+ <arguments>
98
+ <argument name="items" xsi:type="array">
99
+ <item name="OrderAmountAggregator" xsi:type="object">RunAsRoot\P rometheusExporter\A ggregator\O rder\O rderAmountAggregator</item>
100
+ <item name="OrderCountAggregator" xsi:type="object">RunAsRoot\P rometheusExporter\A ggregator\O rder\O rderCountAggregator</item>
101
+ <item name="OrderItemAmountAggregator" xsi:type="object">RunAsRoot\P rometheusExporter\A ggregator\O rder\O rderItemAmountAggregator</item>
102
+ <item name="OrderItemCountAggregator" xsi:type="object">RunAsRoot\P rometheusExporter\A ggregator\O rder\O rderItemCountAggregator</item>
103
+ </argument>
104
+ </arguments>
105
+ </type>
91
106
` ` `
92
107
93
108
# # Contribution
0 commit comments