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.7 to 0.0.8

0

build/adonis-typings/index.d.ts
/// <reference path="prometheus.d.ts" />
/// <reference path="PrometheusProvider.d.ts" />
/// <reference path="./prometheus.ts" />
/// <reference path="./PrometheusProvider.ts" />

@@ -0,0 +0,0 @@ /// <reference types="@adonisjs/http-server/build/adonis-typings" />

@@ -0,0 +0,0 @@ /// <reference types="@adonisjs/application/build/adonis-typings" />

@@ -0,0 +0,0 @@ /// <reference types="@adonisjs/application/build/adonis-typings" />

2

build/providers/PrometheusProvider.js

@@ -76,3 +76,3 @@ "use strict";

}
PrometheusProvider.needsApplication = true;
exports.default = PrometheusProvider;
PrometheusProvider.needsApplication = true;

@@ -0,0 +0,0 @@ /// <reference types="@adonisjs/http-server/build/adonis-typings" />

@@ -0,0 +0,0 @@ "use strict";

import * as prometheus from 'prom-client';
export declare class Metrics {
protected config: any;
/**
* Total time each HTTP request takes.
*/
httpMetric: prometheus.Histogram<string>;
/**
* Uptime performance of the application.
*/
uptimeMetric: prometheus.Gauge<string>;
/**
* No. of request handled.
*/
throughputMetric: prometheus.Counter<string>;
constructor(config: any);
}

@@ -31,13 +31,4 @@ "use strict";

this.config = config;
/**
* Total time each HTTP request takes.
*/
this.httpMetric = new prometheus.Histogram(config.httpMetric);
/**
* Uptime performance of the application.
*/
this.uptimeMetric = new prometheus.Gauge(config.uptimeMetric);
/**
* No. of request handled.
*/
this.throughputMetric = new prometheus.Counter(config.throughputMetric);

@@ -44,0 +35,0 @@ }

{
"name": "adonis5-prometheus",
"version": "0.0.7",
"version": "0.0.8",
"packageManager": "pnpm@7.9.5",

@@ -37,25 +37,25 @@ "description": "Prometheus wrapper for Adonis 5",

"@poppinss/dev-utils": "^2.0.3",
"prom-client": "^14.1.0"
"prom-client": "^14.2.0"
},
"devDependencies": {
"@adonisjs/core": "^5.8.6",
"@adonisjs/core": "^5.9.0",
"@adonisjs/mrm-preset": "^5.0.3",
"@adonisjs/require-ts": "^2.0.12",
"@japa/api-client": "^1.4.1",
"@japa/assert": "^1.3.5",
"@japa/runner": "^2.1.1",
"@japa/spec-reporter": "^1.2.0",
"@adonisjs/require-ts": "^2.0.13",
"@japa/api-client": "^1.4.4",
"@japa/assert": "^1.4.1",
"@japa/runner": "^2.5.1",
"@japa/spec-reporter": "^1.3.3",
"@julr/eslint-config": "^0.3.2",
"@types/node": "^18.7.14",
"bumpp": "^8.2.1",
"commitizen": "^4.2.5",
"@types/node": "^18.16.3",
"bumpp": "^9.1.0",
"commitizen": "^4.3.0",
"copyfiles": "^2.4.1",
"del-cli": "^5.0.0",
"eslint": "^8.23.0",
"github-label-sync": "^2.2.0",
"eslint": "^8.39.0",
"github-label-sync": "^2.3.1",
"japa": "^4.0.0",
"mrm": "^4.1.0",
"nodemon": "^2.0.19",
"prettier": "^2.7.1",
"typescript": "^4.8.2"
"mrm": "^4.1.14",
"nodemon": "^2.0.22",
"prettier": "^2.8.8",
"typescript": "^5.0.4"
},

@@ -113,4 +113,3 @@ "eslintConfig": {

"sync-labels": "github-label-sync --labels ./node_modules/@adonisjs/mrm-preset/gh-labels.json Julien-R44/adonis5-prometheus"
},
"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]\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**Grafana 8 is required** to be able to import the dashboard correctly, otherwise you'll have to tinker a bit to make it work.\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"
}
}
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