Skip to content

Commit 89e3241

Browse files
Merge pull request #43 from deubert-it/feature/documentation
Readme improvements
2 parents cab5f95 + 44c888f commit 89e3241

File tree

1 file changed

+46
-31
lines changed

1 file changed

+46
-31
lines changed

README.md

Lines changed: 46 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Magento Backend.
1313

1414
Install the Module via composer by running:
1515

16-
```
16+
```shell
1717
composer require run-as-root/magento2-prometheus-exporter
1818
php bin/magento setup:upgrade
1919
```
@@ -26,9 +26,9 @@ can enable or disable specific metrics by using the multiselect.
2626
## Prometheus Configuration
2727

2828
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`:
3030

31-
``` yaml
31+
```yaml
3232
- job_name: 'Magento 2 Exporter'
3333
scrape_interval: 5m
3434
scrape_timeout: 60s
@@ -40,6 +40,21 @@ add the following lines to your prometheus.yml under scrape_configs:
4040
- your-magento-url
4141
```
4242
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+
4358
## Module functionality
4459
4560
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.
5065

5166
The following metrics will be collected:
5267

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
7186

7287
To add a new metric, you need to implement the `\RunAsRoot\PrometheusExporter\Api\MetricAggregatorInterface`. The metric
7388
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
7792
In addition to the implementation of the MetricAggregatorInterface, you have to add your specific Aggregator to the
7893
`MetricAggregatorPool` defined in the `di.xml`. For example:
7994

80-
``` xml
95+
```xml
8196
<type name="RunAsRoot\PrometheusExporter\Metric\MetricAggregatorPool">
82-
<arguments>
83-
<argument name="items" xsi:type="array">
84-
<item name="OrderAmountAggregator" xsi:type="object">RunAsRoot\PrometheusExporter\Aggregator\Order\OrderAmountAggregator</item>
85-
<item name="OrderCountAggregator" xsi:type="object">RunAsRoot\PrometheusExporter\Aggregator\Order\OrderCountAggregator</item>
86-
<item name="OrderItemAmountAggregator" xsi:type="object">RunAsRoot\PrometheusExporter\Aggregator\Order\OrderItemAmountAggregator</item>
87-
<item name="OrderItemCountAggregator" xsi:type="object">RunAsRoot\PrometheusExporter\Aggregator\Order\OrderItemCountAggregator</item>
88-
</argument>
89-
</arguments>
90-
</type>
97+
<arguments>
98+
<argument name="items" xsi:type="array">
99+
<item name="OrderAmountAggregator" xsi:type="object">RunAsRoot\PrometheusExporter\Aggregator\Order\OrderAmountAggregator</item>
100+
<item name="OrderCountAggregator" xsi:type="object">RunAsRoot\PrometheusExporter\Aggregator\Order\OrderCountAggregator</item>
101+
<item name="OrderItemAmountAggregator" xsi:type="object">RunAsRoot\PrometheusExporter\Aggregator\Order\OrderItemAmountAggregator</item>
102+
<item name="OrderItemCountAggregator" xsi:type="object">RunAsRoot\PrometheusExporter\Aggregator\Order\OrderItemCountAggregator</item>
103+
</argument>
104+
</arguments>
105+
</type>
91106
```
92107

93108
## Contribution

0 commit comments

Comments
 (0)