Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

adonis5-prometheus

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

adonis5-prometheus - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

4

build/templates/prometheus.txt

@@ -1,2 +0,2 @@

const prometheusConfig {
const prometheusConfig = {
/*

@@ -70,3 +70,3 @@ |--------------------------------------------------------------------------

throughputMetric: {
enabled: false,
enabled: true,
name: 'adonis_throughput_metrics',

@@ -73,0 +73,0 @@ help: 'No. of request handled.',

{
"name": "adonis5-prometheus",
"version": "0.0.3",
"version": "0.0.4",
"description": "Prometheus wrapper for Adonis 5",

@@ -17,2 +17,10 @@ "main": "build/providers/PrometheusProvider.js",

},
"keywords": [
"adonisjs",
"adonis",
"prometheus",
"adonis-prometheus",
"monitoring",
"grafana"
],
"author": "Julien Ripouteau <julien@ripouteau.com>",

@@ -110,3 +118,3 @@ "license": "MIT",

},
"readme": "<div align=\"center\">\r\n <img src=\"https://i.imgur.com/QZf8jrj.png\" width=\"300px\" /> \r\n <br/>\r\n <h3>Adonis5-Prometheus</h3>\r\n <p>Simple Prometheus Wrapper for Adonis</p>\r\n <img src=\"https://img.shields.io/npm/v/adonis5-prometheus.svg?style=for-the-badge&logo=npm\" />\r\n <img src=\"https://img.shields.io/npm/l/adonis5-prometheus?color=blueviolet&style=for-the-badge\" />\r\n <img src=\"https://img.shields.io/badge/Typescript-294E80.svg?style=for-the-badge&logo=typescript\" />\r\n</div>\r\n\r\n## Installation\r\n```\r\nnpm i adonis5-prometheus\r\nnode ace configure adonis5-prometheus\r\n```\r\n\r\n## Usage\r\n\r\nA configuration file has been added in `config/prometheus.ts`.\r\n\r\nBy default the system metrics are collected ( `systemMetrics.enabled: true` ), so now you can call the endpoint `{{host}}/metrics` to get the measured metrics.\r\n\r\n## Built-in Metrics\r\nThere currently exists built-ins metrics such as:\r\n- HTTP Metric: Total time each HTTP request takes.\r\n- Uptime Metric: Uptime performance of the application.\r\n- Throughput metric: No. of request handled.\r\n\r\nTo enable them, simply register the `CollectPerformanceMetrics` as the first item in the start/kernel.ts:\r\n\r\n```typescript\r\nServer.middleware.register([\r\n // Make it first in the list for reliable metrics.\r\n () => import('@ioc:Adonis/Prometheus/Middlewares/CollectPerformanceMetrics'),\r\n () => import('@ioc:Adonis/Core/BodyParser'),\r\n ...\r\n])\r\n```\r\n\r\n## Custom Metrics\r\n```typescript\r\n// Register your custom metrics in the separate file you want.\r\nexport const OrderMetric = new Prometheus.Counter({\r\n name: 'sent_orders',\r\n help: 'Total Orders Sent',\r\n})\r\n\r\n// OrderController.ts\r\nimport { OrderMetric } from 'App/Metrics'\r\n\r\nexport default class OrderController {\r\n public async store({ request }: HttpContextContract) {\r\n const order = await request.validate({ schema: OrderSchema })\r\n\r\n // ...\r\n OrderMetric.inc()\r\n // ...\r\n }\r\n}\r\n```\r\nWhen hitting `{{host}}/metrics` you will now get the following:\r\n```\r\n# HELP send_orders Total Orders Sent\r\n# TYPE send_orders counter\r\nsent_orders 2\r\n```\r\n\r\n## Documentation\r\nThis 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](https://github.com/siimon/prom-client) for more information.\r\n\r\n## Acknowledgments\r\n- [tnkemdilim/adonis-prometheus](https://github.com/tnkemdilim/adonis-prometheus) - At first, I just adapted his library to support Adonis5.\r\n"
"readme": "<div align=\"center\">\n <img src=\"https://i.imgur.com/QZf8jrj.png\" width=\"300px\" /> \n <br/>\n <h3>Adonis5-Prometheus</h3>\n <p>Simple Prometheus Wrapper for Adonis</p>\n <a href=\"https://www.npmjs.com/package/adonis5-prometheus\">\n <img src=\"https://img.shields.io/npm/v/adonis5-prometheus.svg?style=for-the-badge&logo=npm\" />\n </a>\n <img src=\"https://img.shields.io/npm/l/adonis5-prometheus?color=blueviolet&style=for-the-badge\" />\n <img src=\"https://img.shields.io/badge/Typescript-294E80.svg?style=for-the-badge&logo=typescript\" />\n</div>\n\n## Installation\n```\nnpm i adonis5-prometheus\nnode ace configure adonis5-prometheus\n```\n\n## Usage\n\nA configuration file has been added in `config/prometheus.ts`.\n\nBy default the system metrics are collected ( `systemMetrics.enabled: true` ), so now you can call the endpoint `{{host}}/metrics` to get the measured metrics.\n\nHere is an example scrape_config to add to prometheus.yml:\n```yaml\nscrape_configs:\n - job_name: 'my-adonis-app'\n static_configs:\n - targets: ['my-adonis-app.com:3333']\n scrape_interval: 5s\n```\n\n## Built-in Metrics\nMetrics collected by Adonis5-prometheus middleware\n| Type | Name | Description |\n| --- | --- | --- |\n| Histogram | `adonis_http_request_durations` | Total time each HTTP requests takes. |\n| Gauge | `adonis_uptime_metrics` | Uptime performance of the application (1 = up, 0 = down) |\n| Counter | `adonis_throughput_metrics` | No. of request handled. |\n\nTo enable them, simply register the `CollectPerformanceMetrics` as the first item in the start/kernel.ts:\n```typescript\nServer.middleware.register([\n // Make it first in the list for reliable metrics.\n () => import('@ioc:Adonis/Prometheus/Middlewares/CollectPerformanceMetrics'),\n () => import('@ioc:Adonis/Core/BodyParser'),\n ...\n])\n```\nVerify if the metrics are enabled in the `config/prometheus.ts` file. You can also configure the metrics there.\n\n## Custom Metrics\n```typescript\n// Register your custom metrics in the separate file you want.\nexport const OrderMetric = new Prometheus.Counter({\n name: 'sent_orders',\n help: 'Total Orders Sent',\n})\n\n// OrderController.ts\nimport { OrderMetric } from 'App/Metrics'\n\nexport default class OrderController {\n public async store({ request }: HttpContextContract) {\n const order = await request.validate({ schema: OrderSchema })\n\n // ...\n OrderMetric.inc()\n // ...\n }\n}\n```\nWhen hitting `{{host}}/metrics` you will now get the following:\n```\n# HELP send_orders Total Orders Sent\n# TYPE send_orders counter\nsent_orders 2\n```\n\n## Grafana Dashboard\nA basic ready to use dashboard is available in the `grafana` folder.\n![https://i.imgur.com/mD0UMhA.png?1](https://i.imgur.com/mD0UMhA.png?1)\nIt includes :\n- Process CPU usage\n- Event loop lag\n- Node.JS version\n- Requests by second\n- Request volume rate by URL\n- Average response time\n- Response error rate by URL\n\nTo be fully functional, you need to enable `systemMetrics`, `httpMetric` and `throughputMetric` in the `config/prometheus.ts` file.\n\n## Documentation\nThis 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](https://github.com/siimon/prom-client) for more information.\n\n## Acknowledgments\n- [tnkemdilim/adonis-prometheus](https://github.com/tnkemdilim/adonis-prometheus) - At first, I just adapted his library to support Adonis5.\n"
}

@@ -6,3 +6,5 @@ <div align="center">

<p>Simple Prometheus Wrapper for Adonis</p>
<img src="https://img.shields.io/npm/v/adonis5-prometheus.svg?style=for-the-badge&logo=npm" />
<a href="https://www.npmjs.com/package/adonis5-prometheus">
<img src="https://img.shields.io/npm/v/adonis5-prometheus.svg?style=for-the-badge&logo=npm" />
</a>
<img src="https://img.shields.io/npm/l/adonis5-prometheus?color=blueviolet&style=for-the-badge" />

@@ -24,10 +26,20 @@ <img src="https://img.shields.io/badge/Typescript-294E80.svg?style=for-the-badge&logo=typescript" />

Here is an example scrape_config to add to prometheus.yml:
```yaml
scrape_configs:
- job_name: 'my-adonis-app'
static_configs:
- targets: ['my-adonis-app.com:3333']
scrape_interval: 5s
```
## Built-in Metrics
There currently exists built-ins metrics such as:
- HTTP Metric: Total time each HTTP request takes.
- Uptime Metric: Uptime performance of the application.
- Throughput metric: No. of request handled.
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:
```typescript

@@ -41,2 +53,3 @@ Server.middleware.register([

```
Verify if the metrics are enabled in the `config/prometheus.ts` file. You can also configure the metrics there.

@@ -71,6 +84,20 @@ ## Custom Metrics

## Grafana Dashboard
A basic ready to use dashboard is available in the `grafana` folder.
![https://i.imgur.com/mD0UMhA.png?1](https://i.imgur.com/mD0UMhA.png?1)
It includes :
- Process CPU usage
- Event loop lag
- Node.JS version
- Requests by second
- Request volume rate by URL
- Average response time
- Response error rate by URL
To be fully functional, you need to enable `systemMetrics`, `httpMetric` and `throughputMetric` in the `config/prometheus.ts` file.
## Documentation
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](https://github.com/siimon/prom-client) for more information.
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](https://github.com/siimon/prom-client) for more information.
## Acknowledgments
- [tnkemdilim/adonis-prometheus](https://github.com/tnkemdilim/adonis-prometheus) - At first, I just adapted his library to support Adonis5.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc