start prometheus metrics

This commit is contained in:
les 2021-02-09 12:17:39 +01:00
parent c948a5bd47
commit d93315b22c
5 changed files with 59 additions and 13 deletions

View file

@ -1,7 +1,9 @@
const conf = require('config') const conf = require('config')
const { format, transports } = require('winston')
module.exports = { module.exports = {
telemetry: false, telemetry: false,
modern: (process.env.NODE_ENV === 'production') && 'client',
/* /*
** Headers of the page ** Headers of the page
*/ */
@ -60,8 +62,27 @@ module.exports = {
['nuxt-express-module', { expressPath: 'server/', routesPath: 'server/routes' }], ['nuxt-express-module', { expressPath: 'server/', routesPath: 'server/routes' }],
// Doc: https://axios.nuxtjs.org/usage // Doc: https://axios.nuxtjs.org/usage
'@nuxtjs/axios', '@nuxtjs/axios',
'@nuxtjs/auth' '@nuxtjs/auth',
'nuxt-winston-log'
], ],
// configure nuxt-winston-log module
winstonLog: {
skipRequestMiddlewareHandler: true,
useDefaultLogger: false,
loggerOptions: {
transports: process.env.NODE_ENV !== 'production'
? [new transports.Console(
{ level: 'debug', format: format.combine(format.simple(), format.errors({ stack: true })) }
)]
: [new transports.File(
{
filename: 'gancio.log',
format: format.combine(format.simple(), format.errors({ stack: true }))
}
)]
}
},
/* /*
** Axios module configuration ** Axios module configuration
* See https://github.com/nuxt-community/axios-module#options * See https://github.com/nuxt-community/axios-module#options

View file

@ -6,13 +6,14 @@
"scripts": { "scripts": {
"build": "nuxt build", "build": "nuxt build",
"lint": "eslint --ext .js,.vue --ignore-path .gitignore .", "lint": "eslint --ext .js,.vue --ignore-path .gitignore .",
"dev": "cross-env DEBUG=*,-babel*,-preview-email,-i18n:debug,-email-templates,-follow-redirects,-send,-body-parser:*,-express:*,-connect:*,-sequelize:* NODE_ENV=development node server/index.js", "dev": "NODE_ENV=development node server/index.js",
"dev:nuxt": "cross-env NODE_ENV=development nuxt dev", "dev:nuxt": "cross-env NODE_ENV=development nuxt dev --modern",
"doc": "cd docs && bundle exec jekyll b", "doc": "cd docs && bundle exec jekyll b",
"doc:dev": "cd docs && bundle exec jekyll s --drafts", "doc:dev": "cd docs && bundle exec jekyll s --drafts",
"migrate": "NODE_ENV=production sequelize db:migrate", "migrate": "NODE_ENV=production sequelize db:migrate",
"migrate:dev": "sequelize db:migrate", "migrate:dev": "sequelize db:migrate",
"start": "cross-env DEBUG=*,-babel*,-preview-email,-i18n:debug,-email-templates,-follow-redirects,-send,-body-parser:*,-express:*,-connect:*,-sequelize:* NODE_ENV=production node server/cli.js" "start:debug": "cross-env DEBUG=* NODE_ENV=production node server/cli.js",
"start": "NODE_ENV=production node server/cli.js"
}, },
"files": [ "files": [
"server/", "server/",
@ -44,6 +45,7 @@
"email-templates": "^8.0.3", "email-templates": "^8.0.3",
"express": "^4.17.1", "express": "^4.17.1",
"express-oauth-server": "^2.0.0", "express-oauth-server": "^2.0.0",
"express-prom-bundle": "^6.3.1",
"fs": "^0.0.1-security", "fs": "^0.0.1-security",
"http-signature": "^1.3.5", "http-signature": "^1.3.5",
"ical.js": "^1.4.0", "ical.js": "^1.4.0",
@ -51,7 +53,7 @@
"inquirer": "^7.3.3", "inquirer": "^7.3.3",
"jsdom": "^16.4.0", "jsdom": "^16.4.0",
"jsonwebtoken": "^8.5.1", "jsonwebtoken": "^8.5.1",
"less": "^4.1.0", "less": "^4.1.1",
"linkifyjs": "^2.1.9", "linkifyjs": "^2.1.9",
"lodash": "^4.17.20", "lodash": "^4.17.20",
"microformat-node": "^2.0.1", "microformat-node": "^2.0.1",
@ -61,16 +63,18 @@
"multer": "^1.4.2", "multer": "^1.4.2",
"nuxt": "^2.14.12", "nuxt": "^2.14.12",
"nuxt-express-module": "^0.0.11", "nuxt-express-module": "^0.0.11",
"nuxt-winston-log": "^1.2.0",
"pg": "^8.5.1", "pg": "^8.5.1",
"sequelize": "^6.4.0", "prom-client": "^13.1.0",
"sequelize": "^6.5.0",
"sequelize-cli": "^6.2.0", "sequelize-cli": "^6.2.0",
"sharp": "^0.27.0", "sharp": "^0.27.1",
"sqlite3": "^5.0.1", "sqlite3": "^5.0.1",
"tiptap": "^1.31.0", "tiptap": "^1.32.0",
"tiptap-extensions": "^1.34.0", "tiptap-extensions": "^1.35.0",
"to-ico": "^1.1.5", "to-ico": "^1.1.5",
"url": "^0.11.0", "url": "^0.11.0",
"v-calendar": "^2.2.1", "v-calendar": "^2.2.2",
"vue-clipboard2": "^0.3.1", "vue-clipboard2": "^0.3.1",
"vue-i18n": "^8.22.4", "vue-i18n": "^8.22.4",
"yargs": "^16.1.1" "yargs": "^16.1.1"
@ -80,7 +84,7 @@
"@nuxtjs/eslint-config": "^5.0.0", "@nuxtjs/eslint-config": "^5.0.0",
"@nuxtjs/vuetify": "^1.11.3", "@nuxtjs/vuetify": "^1.11.3",
"babel-eslint": "^10.1.0", "babel-eslint": "^10.1.0",
"eslint": "^7.18.0", "eslint": "^7.19.0",
"eslint-config-prettier": "^7.2.0", "eslint-config-prettier": "^7.2.0",
"eslint-config-standard": "^16.0.2", "eslint-config-standard": "^16.0.2",
"eslint-loader": "^4.0.2", "eslint-loader": "^4.0.2",
@ -97,8 +101,8 @@
"pug-plain-loader": "^1.1.0", "pug-plain-loader": "^1.1.0",
"sass": "^1.32.5", "sass": "^1.32.5",
"sass-loader": "^10.1.1", "sass-loader": "^10.1.1",
"vue-cli-plugin-vuetify": "~2.0.9", "vue-cli-plugin-vuetify": "~2.1.0",
"vuetify-loader": "^1.3.0", "vuetify-loader": "^1.7.1",
"webpack-cli": "^4.4.0" "webpack-cli": "^4.4.0"
}, },
"resolutions": { "resolutions": {

View file

@ -0,0 +1,7 @@
const User = require('../models/user')
const metrics = {
}
module.exports = metrics

9
server/metrics.js Normal file
View file

@ -0,0 +1,9 @@
// const promClient = require('prom-client')
// promClient.Gauge({
// name: ''
// })
// module.exports = {
// }

View file

@ -13,6 +13,9 @@ const debug = require('debug')('routes')
const exportController = require('./api/controller/export') const exportController = require('./api/controller/export')
const eventController = require('./api/controller/event') const eventController = require('./api/controller/event')
const announceController = require('./api/controller/announce') const announceController = require('./api/controller/announce')
// const metricsController = require('./metrics')
const promBundle = require('express-prom-bundle')
const metricsMiddleware = promBundle({ includeMethod: true })
const helpers = require('./helpers') const helpers = require('./helpers')
const app = express() const app = express()
@ -20,6 +23,8 @@ const app = express()
// ignore unimplemented ping url from fediverse // ignore unimplemented ping url from fediverse
app.use(spamFilter) app.use(spamFilter)
app.use(metricsMiddleware)
app.use((req, res, next) => { app.use((req, res, next) => {
debug(req.method, req.path) debug(req.method, req.path)
next() next()