
Security News
ECMAScript 2025 Finalized with Iterator Helpers, Set Methods, RegExp.escape, and More
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
adonis5-prometheus
Advanced tools
npm i adonis5-prometheus
node ace configure adonis5-prometheus
A configuration file has been added in config/prometheus.ts
.
By default the system metrics are collected ( systemMetrics.enabled: true
), so now you can call the endpoint {{host}}/metrics
to get the measured metrics.
Here is an example scrape_config to add to prometheus.yml:
scrape_configs:
- job_name: my-adonis-app
static_configs:
- targets: [my-adonis-app.com]
scrape_interval: 5s
Metrics collected by Adonis5-prometheus middleware
Type | Name | Description |
---|---|---|
Histogram | adonis_http_request_durations | Total time each HTTP requests takes. |
Gauge | adonis_uptime_metrics | Uptime performance of the application (1 = up, 0 = down) |
Counter | adonis_throughput_metrics | No. of request handled. |
To enable them, simply register the CollectPerformanceMetrics
as the first item in the start/kernel.ts:
Server.middleware.register([
// Make it first in the list for reliable metrics.
() => import('@ioc:Adonis/Prometheus/Middlewares/CollectPerformanceMetrics'),
() => import('@ioc:Adonis/Core/BodyParser'),
...
])
Verify if the metrics are enabled in the config/prometheus.ts
file. You can also configure the metrics there.
// Register your custom metrics in the separate file you want.
export const OrderMetric = new Prometheus.Counter({
name: 'sent_orders',
help: 'Total Orders Sent',
})
// OrderController.ts
import { OrderMetric } from 'App/Metrics'
export default class OrderController {
public async store({ request }: HttpContextContract) {
const order = await request.validate({ schema: OrderSchema })
// ...
OrderMetric.inc()
// ...
}
}
When hitting {{host}}/metrics
you will now get the following:
# HELP send_orders Total Orders Sent
# TYPE send_orders counter
sent_orders 2
A basic ready to use dashboard is available in the grafana
folder.
Grafana 8 is required to be able to import the dashboard correctly, otherwise you'll have to tinker a bit to make it work.
It includes :
To be fully functional, you need to enable systemMetrics
, httpMetric
and throughputMetric
in the config/prometheus.ts
file.
This library is a wrapper for prom-client. The prom-client object can be imported with import Prometheus from '@ioc:Adonis/Prometheus'
. Check out the documentation for more information.
FAQs
Prometheus wrapper for Adonis 5
The npm package adonis5-prometheus receives a total of 77 weekly downloads. As such, adonis5-prometheus popularity was classified as not popular.
We found that adonis5-prometheus demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
Research
North Korean threat actors linked to the Contagious Interview campaign return with 35 new malicious npm packages using a stealthy multi-stage malware loader.