47 lines
1.2 KiB
Markdown
47 lines
1.2 KiB
Markdown
# promstats
|
|
|
|
> 📊 Access Prometheus + Node Exporter hardware metrics through simple JavaScript functions.
|
|
|
|
`promstats` is a lightweight Node.js package that fetches and parses hardware and system metrics (like CPU and system info) from a Prometheus server running with Node Exporter. It wraps raw metrics into clean JS functions so you can integrate them into your apps with ease.
|
|
|
|
---
|
|
|
|
## ✨ Features
|
|
|
|
- 🔧 Fetches real-time metrics from Prometheus
|
|
- 📦 Simple API for accessing CPU and system-level data
|
|
- 🧠 Intelligent parsing of Node Exporter metrics
|
|
- ⚡ Written in TypeScript
|
|
|
|
---
|
|
|
|
## 🚀 Installation
|
|
```bash
|
|
npm install promstats
|
|
```
|
|
|
|
## 🔧 Configuration
|
|
Before using any functions, you must configure the Prometheus endpoint:
|
|
```js
|
|
import { setUrlEndpoint } from 'promstats';
|
|
setUrlEndpoint('http://localhost:9090');
|
|
```
|
|
|
|
## Usage:
|
|
```js
|
|
import { setUrlEndpoint, CPU, RAM, System } from 'promstats';
|
|
|
|
setUrlEndpoint('http://localhost:9090');
|
|
|
|
CPU.getCpuLoad().then(load => {
|
|
console.log('CPU Load:', load);
|
|
});
|
|
|
|
RAM.getUsedMemory().then(used => {
|
|
console.log('Used Memory:', used);
|
|
});
|
|
|
|
System.getOsName().then(os => {
|
|
console.log('OS Name:', os);
|
|
});
|
|
```
|