Download the PHP package run-as-root/magento2-prometheus-exporter without Composer
On this page you can find all versions of the php package run-as-root/magento2-prometheus-exporter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download run-as-root/magento2-prometheus-exporter
More information about run-as-root/magento2-prometheus-exporter
Files in run-as-root/magento2-prometheus-exporter
Package magento2-prometheus-exporter
Short Description Magento2 Prometheus Exporter
License MIT
Homepage https://github.com/run-as-root/magento2-prometheus-exporter
Informations about the package magento2-prometheus-exporter
Magento 2 Prometheus Exporter
A comprehensive Magento 2 module that exposes essential Magento metrics in Prometheus format, enabling powerful monitoring and observability for your e-commerce platform.
🚀 Features
- 📊 Rich Metrics Collection: Monitors orders, products, customers, CMS content, cron jobs, indexers, and more
- 🔧 Configurable Metrics: Enable/disable specific metrics through Magento admin interface
- 🔐 Secure Access: Bearer token authentication support to protect your metrics endpoint
- ⚡ Performance Optimized: Efficient cron-based data aggregation to minimize performance impact
- 🎯 Prometheus Ready: Native Prometheus format output for seamless integration
- 🔌 Extensible Architecture: Easy to add custom metrics with clean interfaces
📋 Table of Contents
- Installation
- Configuration
- Prometheus Setup
- Available Metrics
- Security
- Custom Metrics
- CLI Commands
- Architecture
- Troubleshooting
- Contributing
- License
📦 Installation
Requirements
- Magento 2.3.x or higher
- PHP 7.4 or higher
- Composer
Install via Composer
Verify Installation
After installation, your metrics endpoint will be available at:
⚙️ Configuration
Admin Configuration
Navigate to Stores → Configuration → Prometheus → Metric Configuration to:
- Enable/disable specific metric collectors
- Configure authentication settings
- Set collection intervals
- Manage metric labels and groupings
Cron Configuration
The module automatically registers a cron job that runs every minute to aggregate metrics. The job uses a dedicated cron group: run_as_root_prometheus_metrics_aggregator
.
🎯 Prometheus Setup
Basic Configuration
Add the following scrape configuration to your prometheus.yml
:
With Authentication
For production environments, secure your metrics endpoint:
Advanced Configuration with Labels
📊 Available Metrics
Order Metrics
Metric | Type | Labels | Description |
---|---|---|---|
magento_orders_count_total |
gauge | status , store_code |
Total count of orders by status and store |
magento_orders_amount_total |
gauge | status , store_code |
Total revenue by order status and store |
magento_order_items_count_total |
gauge | status , store_code |
Total count of order items |
Product & Catalog Metrics
Metric | Type | Labels | Description |
---|---|---|---|
magento_products_by_type_count_total |
gauge | product_type |
Count of products by type (simple, configurable, etc.) |
magento_catalog_category_count_total |
gauge | status , menu_status , store_code |
Count of categories by status |
EAV & Attribute Metrics
Metric | Type | Labels | Description |
---|---|---|---|
magento_eav_attribute_count_total |
gauge | - | Total count of EAV attributes |
magento_eav_attribute_options_above_recommended_level_total |
gauge | - | Count of attributes with more than 100 options (performance risk) |
Customer Metrics
Metric | Type | Labels | Description |
---|---|---|---|
magento_customer_count_total |
gauge | store_code |
Total count of registered customers |
Content Metrics
Metric | Type | Labels | Description |
---|---|---|---|
magento_cms_block_count_total |
gauge | store_code |
Count of CMS blocks |
magento_cms_page_count_total |
gauge | store_code |
Count of CMS pages |
System Health Metrics
Metric | Type | Labels | Description |
---|---|---|---|
magento_cronjob_count_total |
gauge | status , job_code |
Count of cron jobs by status |
magento_cronjob_broken_count_total |
gauge | - | Count of broken cron jobs |
magento_indexer_backlog_count_total |
gauge | title |
Count of items in indexer backlog |
Infrastructure Metrics
Metric | Type | Labels | Description |
---|---|---|---|
magento_store_count_total |
gauge | status |
Count of stores by status |
magento_website_count_total |
gauge | - | Total count of websites |
magento_shipments_count_total |
counter | source , store_code |
Count of shipments created |
🔐 Security
Authentication Setup
- Generate Bearer Token: Navigate to Magento Admin → System → Integrations
- Create New Integration: Set up API access with appropriate permissions
- Configure Token: Use the generated access token in your Prometheus configuration
Best Practices
- Always use HTTPS for metrics endpoints in production
- Regularly rotate authentication tokens
- Restrict access to metrics endpoint via firewall rules
- Monitor access logs for unusual activity
IP Whitelisting
Consider restricting access to your Prometheus server IPs:
🔧 Custom Metrics
Creating a Custom Metric Aggregator
-
Implement the Interface:
- Register in DI Configuration (
etc/di.xml
):
Example: Product Rating Aggregator
💻 CLI Commands
Collect Metrics Manually
View Current Metrics
Clear Metrics Data
🏗️ Architecture
Data Flow
- Cron Execution: Every minute, the
run_as_root_prometheus_metrics_aggregator
cron group executes - Metric Aggregation: Each enabled aggregator collects and processes data
- Data Storage: Aggregated metrics are stored in
run_as_root_prometheus_metrics
table - Endpoint Response:
/metrics
controller serves data in Prometheus format
Key Components
- MetricAggregatorInterface: Contract for all metric collectors
- MetricAggregatorPool: Registry of all available aggregators
- UpdateMetricService: Service for storing metric data
- PrometheusController: HTTP endpoint for serving metrics
Database Schema
The module creates a dedicated table run_as_root_prometheus_metrics
with the following structure:
metric_id
: Primary keymetric_code
: Unique metric identifiermetric_value
: Numeric valuemetric_type
: Type (gauge, counter, histogram)metric_help
: Description textmetric_labels
: JSON-encoded labelsupdated_at
: Last update timestamp
🔍 Troubleshooting
Common Issues
Metrics Not Updating
Permission Denied on /metrics
- Verify web server has read access to Magento files
- Check Magento file permissions:
find . -type f -exec chmod 644 {} \;
- Ensure proper ownership:
chown -R www-data:www-data .
High Memory Usage
- Reduce collection frequency in cron configuration
- Disable unused metric aggregators in admin configuration
- Consider implementing metric data retention policies
Debug Mode
Enable debug logging by adding to app/etc/env.php
:
Performance Monitoring
Monitor the impact of metric collection:
🤝 Contributing
We welcome contributions! Here's how you can help:
Development Setup
- Fork the repository
- Clone your fork:
git clone https://gitlab.com/your-username/magento2-prometheus-exporter.git
- Install dependencies:
composer install
- Create a feature branch:
git checkout -b feature/your-feature-name
Code Standards
- Follow Magento 2 coding standards
- Write unit tests for new features
- Update documentation for new metrics or features
- Use meaningful commit messages
Pull Request Process
- Ensure all tests pass:
vendor/bin/phpunit
- Update the CHANGELOG.md
- Submit a pull request with a clear description
- Respond to code review feedback
Reporting Issues
Please include:
- Magento version
- PHP version
- Module version
- Detailed error messages
- Steps to reproduce
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🙏 Acknowledgments
- run_as_root GmbH - Original development and maintenance
- Prometheus Community - For the excellent monitoring toolkit
- Magento Community - For feedback and contributions
📞 Support
- Email: [email protected]
- GitLab Issues: Report a bug
- Documentation: Wiki
Made with ❤️ by run_as_root
All versions of magento2-prometheus-exporter with dependencies
magento/module-payment Version *
magento/module-eav Version *
magento/module-cron Version *
magento/module-cms Version *
magento/module-shipping Version *
magento/module-catalog Version *
magento/module-sales Version *
laminas/laminas-http Version ^2.15.0
magento/module-config Version *
magento/module-backend Version *
guzzlehttp/guzzle Version ^7.4.5
symfony/console Version ^5.4.46|^6.0
psr/log Version ^1.1|^2.0|^3.0
monolog/monolog Version ^2.9.0|^3.0
magento/module-store Version *
magento/module-indexer Version *
magento/zend-db Version *