andersundsehr / metrics_exporter
Prometheus metrics collector for TYPO3. Collect and export metrics.
Installs: 33
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:typo3-cms-extension
pkg:composer/andersundsehr/metrics_exporter
Requires
- php: ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0
- promphp/prometheus_client_php: ^2.14.1
- typo3/cms-core: ^11.5 || ^12.4 || ^13.4
Requires (Dev)
- pluswerk/grumphp-config: *
- saschaegerer/phpstan-typo3: *
- ssch/typo3-rector: ^2.5.0
- typo3/testing-framework: *
- weakbit/fallback-cache: dev-feature/TYPO3v13
Suggests
- weakbit/fallback-cache: Ensures metrics collector doesn't break pages if caching fails and enables immutable caching for metrics
This package is not auto-updated.
Last update: 2025-11-06 14:54:14 UTC
README
This extension provides a metrics collector for your TYPO3 application and exposes an endpoint that outputs the collected metrics in a format compatible with Prometheus. This allows you to monitor application performance and behavior using Prometheus or similar monitoring tools.
Code Example: Collecting Metrics
Here's how to inject the CollectorService into your own class and collect metrics:
<?php declare(strict_types=1); namespace MyVendor\MyExtension\Service; use AUS\MetricsExporter\Service\CollectorService; class MyCustomService { public function __construct( private readonly CollectorService $collectorService ) { } public function doSomething(): void { // Collect a gauge metric (represents a value that can go up and down) $gauge = $this->collectorService->getOrRegisterGauge( 'my_extension_prefix', 'my_custom_gauge', 'Description of my custom gauge metric', ['label1', 'label2'] // Optional labels ); $gauge->set(42.5, ['value1', 'value2']); // Set gauge value with label values // Collect a counter metric (represents a value that only increases) $counter = $this->collectorService->getOrRegisterCounter( 'my_extension_prefix', 'my_custom_counter', 'Description of my custom counter metric', ['status'] // Optional labels ); $counter->inc(['success']); // Increment counter by 1 $counter->incBy(5, ['error']); // Increment counter by 5 } }
Configuration
- Install the extension via composer:
composer require andersundsehr/metrics_exporter
- Optional: Define the data endpoint in your site configuration:
routeEnhancers: PageTypeSuffix: type: PageType map: metrics.txt: 1717676395
- Database configuration if wanted, see below.
Visibility
Remember that metrics may contain sensitive data and should be protected from public access.
Storage
You can change the Storage by configuring the cache "prometheus_storage" in the TYPO3 caching framework!
Cache? Isn't that cleared so my counters get lost? Yes, but you can install and properly configure "weakbit/fallback-cache" which gives you immutable caches that are not flushed by TYPO3.