https://github.com/s00d/nuxt-prometheus-exporter
https://github.com/s00d/nuxt-prometheus-exporter
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/s00d/nuxt-prometheus-exporter
- Owner: s00d
- Created: 2023-09-27T10:28:18.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-09-27T14:44:29.000Z (over 2 years ago)
- Last Synced: 2025-03-03T02:33:59.406Z (over 1 year ago)
- Language: Go
- Size: 18.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# NUXT Prometheus Exporter
NUXT Prometheus exporter makes it possible to monitor NUXT using Prometheus.
## Getting Started
1. download latest version from release
2. runas service
```bash
[Unit]
Description=NUXT Prometheus Exporter
After=network.target
[Service]
User=nuxt-exp
Group=nuxt-exp
ExecStart=/usr/local/bin/nuxt-prometheus-exporter
```
3. add server middleware to nuxt `server-middleware/prometheus.js`, example with axios
```js
import axios from 'axios';
export default function (req, res, next) {
const start = +new Date();
res.once('finish', () => {
const end = +new Date();
axios.post('http://localhost:45555/nodejs-requests', {
route: req._parsedUrl.pathname ?? req.originalUrl,
code: res.statusCode.toString(),
method: req.method,
date: start.toString(),
duration: (end - start).toString(),
}, {
headers: {
'Content-Type': 'application/json',
},
});
});
next();
}
```
all values must be string
by analogy, can be used with any other project
4. enable server middleware in `nuxt.config.js`
```js
{
// ...
serverMiddleware: [
// ...
'~/server-middleware/prometheus',
// ...
]
// ...
}
```