medusa-prometheus-monitoring
v0.0.4
Published
Prometheus monitoring plugin for Medusa
Downloads
19
Readme
Compatibility
This starter is compatible with versions >= 2.4.0 of @medusajs/medusa.
Getting Started
Visit the Quickstart Guide to set up a server.
Visit the Plugins documentation to learn more about plugins and how to create them.
Visit the Docs to learn more about our system requirements.
What is Medusa
Medusa is a set of commerce modules and tools that allow you to build rich, reliable, and performant commerce applications without reinventing core commerce logic. The modules can be customized and used to build advanced ecommerce stores, marketplaces, or any product that needs foundational commerce primitives. All modules are open-source and freely available on npm.
Learn more about Medusa's architecture and commerce modules in the Docs.
Community & Contributions
The community and core team are available in GitHub Discussions, where you can ask for support, discuss roadmap, and share ideas.
Join our Discord server to meet other community members.
Other channels
Medusa Prometheus Plugin
A Medusa v2 plugin that adds Prometheus monitoring capabilities to your Medusa backend. This plugin uses swagger-stats to automatically collect metrics from all REST API endpoints and expose them in Prometheus format.
Features
- Automatic monitoring of all REST API endpoints (both Admin and Store APIs)
- Real-time metrics dashboard at
/swagger-stats/ - Prometheus-compatible metrics endpoint at
/swagger-stats/metrics - JSON stats endpoint at
/swagger-stats/stats - No configuration required - works out of the box
- Customizable dashboard name and metrics options
Prerequisites
- Medusa backend version 2.x
- Node.js version 20 or later
Installation
npm install medusa-plugin-prometheus
# or
yarn add medusa-plugin-prometheusConfiguration
Add the plugin to your medusa-config.js or medusa-config.ts:
import { defineConfig } from "@medusajs/framework/utils"
export default defineConfig({
/* ... other config ... */
plugins: [
// ...other plugins
{
resolve: "medusa-plugin-prometheus",
options: {
// Optional: customize the dashboard name
name: "My Medusa Monitoring Dashboard"
}
}
]
})Environment Variables
MEDUSA_MONITOR_NAME: Optional. Set a custom name for the monitoring dashboard.
Usage
Once installed and configured, the plugin automatically starts collecting metrics. The following endpoints become available:
Dashboard UI:
- URL:
/swagger-stats/ - A web interface showing real-time metrics and API analytics
- URL:
Prometheus Metrics:
- URL:
/swagger-stats/metrics - Endpoint for Prometheus to scrape metrics
- Returns metrics in Prometheus format
- URL:
JSON Stats:
- URL:
/swagger-stats/stats - Returns detailed statistics in JSON format
- URL:
Prometheus Configuration
Add the following to your Prometheus configuration to scrape metrics:
scrape_configs:
- job_name: 'medusa'
metrics_path: '/swagger-stats/metrics'
static_configs:
- targets: ['your-medusa-host:9000']Metrics
The plugin collects various metrics including:
- Request counts (total, by endpoint, by method)
- Response times (min, max, average)
- Response codes (2xx, 3xx, 4xx, 5xx)
- Request sizes
- Response sizes
- And more...
All metrics are prefixed with medusa_ by default.
Development
yarn # install dependencies
yarn build # build the plugin
yarn dev # run in development modeLicense
MIT License
Contributing
Feel free to open issues and pull requests!
