-
Notifications
You must be signed in to change notification settings - Fork 0
Metrics
MicroFox provides built-in support for exposing application metrics via a Prometheus-compatible endpoint at:
/metrics
This functionality is powered by Micrometer, the industry-standard metrics collection library used in production environments.
To enable metrics in your MicroFox application, simply add the following Maven dependency:
<dependency>
<groupId>ir.moke.microfox</groupId>
<artifactId>microfox-metrics</artifactId>
<version>${microfox.version}</version>
</dependency>That's it β no manual configuration or activation is needed. Once the dependency is present, the /metrics endpoint becomes automatically available.
Path:
GET /metrics
Content-Type:
text/plain; version=0.0.4
Output: Prometheus-compliant metric format:
# HELP jvm_memory_used_bytes The amount of used memory
# TYPE jvm_memory_used_bytes gauge
jvm_memory_used_bytes{area="heap",id="G1 Eden Space",} 1.048576E7
...
MicroFox metrics module is internally based on:
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-core</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>This ensures compatibility with modern observability stacks including Prometheus, Grafana, and OpenTelemetry (via bridge adapters).
Out of the box, MicroFox + Micrometer collects:
| Metric Category | Description |
|---|---|
| jvm.memory.* | Heap, non-heap, Eden/Survivor/Old space usage |
| jvm.gc.* | GC pause count and duration |
| system.cpu.* | CPU usage, system load |
| process.* | Uptime, threads, file descriptors |
| http.server.requests | Request count, response time (Jetty internal) |
| logback.events | Logging events (if logback is used) |
To scrape metrics into Prometheus, use the following config:
scrape_configs:
- job_name: 'microfox-app'
static_configs:
- targets: ['localhost:8080']
metrics_path: '/metrics'
Then visualize data in Grafana using the Prometheus data source.
- One-line setup via Maven
- No config files or annotations
- Standards-compliant /metrics endpoint
- Full Prometheus integration
- Works with JVM, HTTP, system, and custom metrics