PHPackages                             vntrungld/prometheus-exporter-opcache-collector - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. vntrungld/prometheus-exporter-opcache-collector

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

vntrungld/prometheus-exporter-opcache-collector
===============================================

OPcache Collector for Prometheus Exporter

v1.0.1(2mo ago)010MITPHPPHP ^7.2|^8.0CI passing

Since Apr 9Pushed 2mo agoCompare

[ Source](https://github.com/vntrungld/prometheus-exporter-opcache-collector)[ Packagist](https://packagist.org/packages/vntrungld/prometheus-exporter-opcache-collector)[ Docs](https://github.com/vntrungld/prometheus-exporter-opcache-collector)[ RSS](/packages/vntrungld-prometheus-exporter-opcache-collector/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (2)Dependencies (5)Versions (3)Used By (0)

Prometheus Exporter OPcache Collector
=====================================

[](#prometheus-exporter-opcache-collector)

[![Latest Version on Packagist](https://camo.githubusercontent.com/95e6d0040687f1256294ad51d50635ea2ffbce1e7e1ebb2a4505164974bf5771/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f766e7472756e676c642f70726f6d6574686575732d6578706f727465722d6f7063616368652d636f6c6c6563746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/vntrungld/prometheus-exporter-opcache-collector)[![Total Downloads](https://camo.githubusercontent.com/8eb55978acd757bac2487670996a3211994ae182073d759201647b8595698382/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f766e7472756e676c642f70726f6d6574686575732d6578706f727465722d6f7063616368652d636f6c6c6563746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/vntrungld/prometheus-exporter-opcache-collector)[![Tests](https://github.com/vntrungld/prometheus-exporter-opcache-collector/actions/workflows/tests.yml/badge.svg)](https://github.com/vntrungld/prometheus-exporter-opcache-collector/actions/workflows/tests.yml)[![License](https://camo.githubusercontent.com/c4aafdcbaf46d5ffd8d313d7d240ae7ef137397fe2cdc2170383e8ff6a217aff/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f766e7472756e676c642f70726f6d6574686575732d6578706f727465722d6f7063616368652d636f6c6c6563746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/vntrungld/prometheus-exporter-opcache-collector)

An OPcache metrics collector for [Prometheus Exporter](https://github.com/vntrungld/prometheus-exporter) in Laravel applications. This package collects OPcache memory usage, cache statistics, interned strings, JIT status, and configuration limits, exposing them in Prometheus format.

Requirements
------------

[](#requirements)

LaravelPHPPackage6.x7.2 - 8.01.x7.x7.2 - 8.01.x8.x7.3 - 8.11.x9.x8.0 - 8.21.x10.x8.1 - 8.31.x11.x8.2 - 8.41.x12.x8.2 - 8.41.xInstallation
------------

[](#installation)

Install via Composer:

```
composer require vntrungld/prometheus-exporter-opcache-collector
```

The package uses Laravel's auto-discovery, so the service provider will be automatically registered.

Configuration
-------------

[](#configuration)

Add the collector set to your `prometheus-exporter` configuration file (`config/prometheus-exporter.php`):

```
return [
    // ... other config options

    'collector_sets' => [
        \Vntrungld\PrometheusExporterOpcacheCollector\OpcacheCollectorSet::class,
        // ... other collector sets
    ],
];
```

Available Metrics
-----------------

[](#available-metrics)

### Up Status

[](#up-status)

Metric NameTypeDescription`opcache_up`GaugeWhether OPcache is available (1=up, 0=down)### Memory Usage

[](#memory-usage)

Metric NameTypeDescription`opcache_used_memory_bytes`GaugeUsed memory in bytes`opcache_free_memory_bytes`GaugeFree memory in bytes`opcache_wasted_memory_bytes`GaugeWasted memory in bytes`opcache_wasted_memory_percentage`GaugeWasted memory as percentage### Cache Statistics

[](#cache-statistics)

Metric NameTypeDescription`opcache_cached_scripts`GaugeNumber of cached scripts`opcache_hits_total`CounterTotal cache hits`opcache_misses_total`CounterTotal cache misses`opcache_cached_keys`GaugeNumber of keys in the hash table`opcache_max_cached_keys`GaugeMaximum slots in the hash table`opcache_oom_restarts`GaugeOut-of-memory restart count`opcache_hash_restarts`GaugeHash table overflow restart count`opcache_manual_restarts`GaugeManual restart count### Interned Strings

[](#interned-strings)

Metric NameTypeDescription`opcache_interned_strings_buffer_bytes`GaugeTotal buffer size`opcache_interned_strings_used_bytes`GaugeUsed buffer memory`opcache_interned_strings_free_bytes`GaugeFree buffer memory`opcache_interned_strings_count`GaugeNumber of interned strings### JIT (PHP 8.0+)

[](#jit-php-80)

These metrics are only available when JIT is present. They are silently skipped on PHP &lt; 8.0.

Metric NameTypeDescription`opcache_jit_enabled`GaugeWhether JIT is enabled`opcache_jit_buffer_size_bytes`GaugeTotal JIT buffer size`opcache_jit_buffer_used_bytes`GaugeUsed JIT buffer`opcache_jit_buffer_free_bytes`GaugeFree JIT buffer### Configuration Limits

[](#configuration-limits)

These gauges expose OPcache configuration values, useful for computing utilization ratios in PromQL.

Metric NameTypeSource`opcache_config_memory_limit_bytes`Gauge`opcache.memory_consumption``opcache_config_max_accelerated_files`Gauge`opcache.max_accelerated_files``opcache_config_interned_strings_buffer_bytes`Gauge`opcache.interned_strings_buffer``opcache_config_jit_buffer_size_bytes`Gauge`opcache.jit_buffer_size` (8.0+)Example PromQL Queries
----------------------

[](#example-promql-queries)

```
# Memory utilization %
opcache_used_memory_bytes / opcache_config_memory_limit_bytes * 100

# Script slots utilization %
opcache_cached_scripts / opcache_config_max_accelerated_files * 100

# Interned strings utilization %
opcache_interned_strings_used_bytes / opcache_config_interned_strings_buffer_bytes * 100

# Cache hit rate %
opcache_hits_total / (opcache_hits_total + opcache_misses_total) * 100

```

Example Output
--------------

[](#example-output)

```
# HELP opcache_up Whether OPcache is available.
# TYPE opcache_up gauge
opcache_up 1

# HELP opcache_used_memory_bytes The amount of used memory by OPcache.
# TYPE opcache_used_memory_bytes gauge
opcache_used_memory_bytes 67108864

# HELP opcache_free_memory_bytes The amount of free memory for OPcache.
# TYPE opcache_free_memory_bytes gauge
opcache_free_memory_bytes 67108864

# HELP opcache_cached_scripts The number of scripts cached by OPcache.
# TYPE opcache_cached_scripts gauge
opcache_cached_scripts 150

# HELP opcache_hits_total The total number of OPcache cache hits.
# TYPE opcache_hits_total counter
opcache_hits_total 50000

# HELP opcache_config_memory_limit_bytes The configured OPcache memory limit in bytes.
# TYPE opcache_config_memory_limit_bytes gauge
opcache_config_memory_limit_bytes 134217728

```

OPcache Configuration
---------------------

[](#opcache-configuration)

For this collector to work, the OPcache extension must be enabled. Ensure your `php.ini` has:

```
opcache.enable=1
```

The collector uses PHP's built-in `opcache_get_status()` and `opcache_get_configuration()` functions. When OPcache is not available, the `opcache_up` metric reports `0` and all other metrics are silently skipped.

Testing
-------

[](#testing)

Run the test suite:

```
composer test
```

Or with PHPUnit directly:

```
vendor/bin/phpunit
```

Changelog
---------

[](#changelog)

Please see the [changelog](changelog.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [contributing.md](contributing.md) for details and a todolist.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [vntrungld](https://github.com/vntrungld)
- [All Contributors](../../contributors)

License
-------

[](#license)

MIT. Please see the [license file](license.md) for more information.

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance88

Actively maintained with recent releases

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

61d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/39490e25f48deaf067db160681117abc2bdcf818fdce03a30eebc1ee25b784a0?d=identicon)[vntrungld](/maintainers/vntrungld)

---

Top Contributors

[![vntrungld](https://avatars.githubusercontent.com/u/19848743?v=4)](https://github.com/vntrungld "vntrungld (3 commits)")

---

Tags

laravelPrometheus ExporterOPcache Collector

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/vntrungld-prometheus-exporter-opcache-collector/health.svg)

```
[![Health](https://phpackages.com/badges/vntrungld-prometheus-exporter-opcache-collector/health.svg)](https://phpackages.com/packages/vntrungld-prometheus-exporter-opcache-collector)
```

###  Alternatives

[spatie/laravel-health

Monitor the health of a Laravel application

88011.3M149](/packages/spatie-laravel-health)[spatie/laravel-flare

Send Laravel errors to Flare

101.2M6](/packages/spatie-laravel-flare)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
