mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-25 11:16:31 -05:00
enhancement(metrics): allow disabling via config option
Signed-off-by: Erik Michelson <github@erik.michelson.eu>
This commit is contained in:
parent
a349ddde56
commit
143864b8d9
6 changed files with 20 additions and 11 deletions
6
app.js
6
app.js
|
@ -75,8 +75,10 @@ app.use(morgan('combined', {
|
||||||
}))
|
}))
|
||||||
|
|
||||||
// Register prometheus metrics endpoint
|
// Register prometheus metrics endpoint
|
||||||
app.use(apiMetrics())
|
if (config.enableStatsApi) {
|
||||||
metrics.setupCustomPrometheusMetrics()
|
app.use(apiMetrics())
|
||||||
|
metrics.setupCustomPrometheusMetrics()
|
||||||
|
}
|
||||||
|
|
||||||
// socket io
|
// socket io
|
||||||
const io = require('socket.io')(server, { cookie: false })
|
const io = require('socket.io')(server, { cookie: false })
|
||||||
|
|
|
@ -21,7 +21,7 @@ to `config.json` before filling in your own details.
|
||||||
## HedgeDoc basics
|
## HedgeDoc basics
|
||||||
|
|
||||||
| config file | environment | **default** and example value | description |
|
| config file | environment | **default** and example value | description |
|
||||||
| -------------------- | ------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|----------------------|---------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||||
| | `CMD_CONFIG_FILE` | **no default**, `/path/to/config.json` | optional override for the path to HedgeDoc's config file |
|
| | `CMD_CONFIG_FILE` | **no default**, `/path/to/config.json` | optional override for the path to HedgeDoc's config file |
|
||||||
| `db` | | **`undefined`**, `{ "dialect": "sqlite", "storage": "./db.hedgedoc.sqlite" }` | set the db configs, [see more here](https://sequelize.org/v5/manual/dialects.html) |
|
| `db` | | **`undefined`**, `{ "dialect": "sqlite", "storage": "./db.hedgedoc.sqlite" }` | set the db configs, [see more here](https://sequelize.org/v5/manual/dialects.html) |
|
||||||
| `db.username` | `CMD_DB_USERNAME` | **`undefined`**, `hedgedoc-db-user` | Username used to authenticate to the database (host). |
|
| `db.username` | `CMD_DB_USERNAME` | **`undefined`**, `hedgedoc-db-user` | Username used to authenticate to the database (host). |
|
||||||
|
@ -41,6 +41,7 @@ to `config.json` before filling in your own details.
|
||||||
| `heartbeatTimeout` | | **`10000`** | socket.io heartbeat timeout |
|
| `heartbeatTimeout` | | **`10000`** | socket.io heartbeat timeout |
|
||||||
| `documentMaxLength` | `CMD_DOCUMENT_MAX_LENGTH` | **`100000`** | note max length |
|
| `documentMaxLength` | `CMD_DOCUMENT_MAX_LENGTH` | **`100000`** | note max length |
|
||||||
| `linkifyHeaderStyle` | | **`keep-case`**, `lower-case`, `gfm` | how is a header text converted into a link id |
|
| `linkifyHeaderStyle` | | **`keep-case`**, `lower-case`, `gfm` | how is a header text converted into a link id |
|
||||||
|
| `enableStatsApi` | `CMD_ENABLE_STATS_API` | **`true`**, `false` | Enables or disables the /status and /metrics endpoint. |
|
||||||
|
|
||||||
## HedgeDoc paths stuff
|
## HedgeDoc paths stuff
|
||||||
|
|
||||||
|
|
|
@ -179,5 +179,6 @@ module.exports = {
|
||||||
// Generated id: "31-good-morning-my-friend---do-you-have-5"
|
// Generated id: "31-good-morning-my-friend---do-you-have-5"
|
||||||
// 2nd appearance: "31-good-morning-my-friend---do-you-have-5-1"
|
// 2nd appearance: "31-good-morning-my-friend---do-you-have-5-1"
|
||||||
// 3rd appearance: "31-good-morning-my-friend---do-you-have-5-2"
|
// 3rd appearance: "31-good-morning-my-friend---do-you-have-5-2"
|
||||||
linkifyHeaderStyle: 'keep-case'
|
linkifyHeaderStyle: 'keep-case',
|
||||||
|
enableStatsApi: true
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,5 +157,6 @@ module.exports = {
|
||||||
allowEmailRegister: toBooleanConfig(process.env.CMD_ALLOW_EMAIL_REGISTER),
|
allowEmailRegister: toBooleanConfig(process.env.CMD_ALLOW_EMAIL_REGISTER),
|
||||||
allowGravatar: toBooleanConfig(process.env.CMD_ALLOW_GRAVATAR),
|
allowGravatar: toBooleanConfig(process.env.CMD_ALLOW_GRAVATAR),
|
||||||
openID: toBooleanConfig(process.env.CMD_OPENID),
|
openID: toBooleanConfig(process.env.CMD_OPENID),
|
||||||
linkifyHeaderStyle: process.env.CMD_LINKIFY_HEADER_STYLE
|
linkifyHeaderStyle: process.env.CMD_LINKIFY_HEADER_STYLE,
|
||||||
|
enableStatsApi: toBooleanConfig(process.env.CMD_ENABLE_STATS_API)
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,9 @@ statusRouter.get('/_health', function (req, res) {
|
||||||
|
|
||||||
// get status
|
// get status
|
||||||
statusRouter.get('/status', function (req, res, next) {
|
statusRouter.get('/status', function (req, res, next) {
|
||||||
|
if (!config.enableStatsApi) {
|
||||||
|
return errors.errorForbidden(res)
|
||||||
|
}
|
||||||
realtime.getStatus(function (data) {
|
realtime.getStatus(function (data) {
|
||||||
res.set({
|
res.set({
|
||||||
'Cache-Control': 'private', // only cache by client
|
'Cache-Control': 'private', // only cache by client
|
||||||
|
|
|
@ -15,6 +15,7 @@ special actions.
|
||||||
- Add dedicated healthcheck endpoint at /_health that is less resource intensive than /status.
|
- Add dedicated healthcheck endpoint at /_health that is less resource intensive than /status.
|
||||||
- Compatibility with Node.js 18 and later
|
- Compatibility with Node.js 18 and later
|
||||||
- Add support for the arm64 architecture in the docker image
|
- Add support for the arm64 architecture in the docker image
|
||||||
|
- Add a config option to disable the `/status` and `/metrics` endpoints
|
||||||
|
|
||||||
### Bugfixes
|
### Bugfixes
|
||||||
- Fix that permission errors can break existing connections to a note, causing inconsistent note content and changes not being saved
|
- Fix that permission errors can break existing connections to a note, causing inconsistent note content and changes not being saved
|
||||||
|
|
Loading…
Reference in a new issue