1
0
Fork 0
mirror of synced 2024-07-11 09:15:48 +12:00

Updating metrics endpoint to have examples of expected data format - show OpenMetrics response.

This commit is contained in:
mike12345567 2023-03-06 15:55:55 +00:00
parent 13ae950101
commit 36683459b8
8 changed files with 295 additions and 3 deletions

View file

@ -115,6 +115,15 @@
] ]
} }
}, },
"deploymentOutput": {
"value": {
"data": {
"_id": "ef12381f934b4f129675cdbb76eff3c2",
"status": "SUCCESS",
"appUrl": "/app-url"
}
}
},
"inputRow": { "inputRow": {
"value": { "value": {
"_id": "ro_ta_5b1649e42a5b41dea4ef7742a36a7a70_e6dc7e38cf1343b2b56760265201cda4", "_id": "ro_ta_5b1649e42a5b41dea4ef7742a36a7a70_e6dc7e38cf1343b2b56760265201cda4",
@ -413,6 +422,9 @@
} }
] ]
} }
},
"metrics": {
"value": "# HELP budibase_os_uptime Time in seconds that the host operating system has been up.\n# TYPE budibase_os_uptime counter\nbudibase_os_uptime 54958\n# HELP budibase_os_free_mem Bytes of memory free for usage on the host operating system.\n# TYPE budibase_os_free_mem gauge\nbudibase_os_free_mem 804507648\n# HELP budibase_os_total_mem Total bytes of memory on the host operating system.\n# TYPE budibase_os_total_mem gauge\nbudibase_os_total_mem 16742404096\n# HELP budibase_os_used_mem Total bytes of memory in use on the host operating system.\n# TYPE budibase_os_used_mem gauge\nbudibase_os_used_mem 15937896448\n# HELP budibase_os_load1 Host operating system load average.\n# TYPE budibase_os_load1 gauge\nbudibase_os_load1 1.91\n# HELP budibase_os_load5 Host operating system load average.\n# TYPE budibase_os_load5 gauge\nbudibase_os_load5 1.75\n# HELP budibase_os_load15 Host operating system load average.\n# TYPE budibase_os_load15 gauge\nbudibase_os_load15 1.56\n# HELP budibase_tenant_user_count The number of users created.\n# TYPE budibase_tenant_user_count gauge\nbudibase_tenant_user_count 1\n# HELP budibase_tenant_app_count The number of apps created by a user.\n# TYPE budibase_tenant_app_count gauge\nbudibase_tenant_app_count 2\n# HELP budibase_tenant_production_app_count The number of apps a user has published.\n# TYPE budibase_tenant_production_app_count gauge\nbudibase_tenant_production_app_count 1\n# HELP budibase_tenant_dev_app_count The number of apps a user has unpublished in development.\n# TYPE budibase_tenant_dev_app_count gauge\nbudibase_tenant_dev_app_count 1\n# HELP budibase_tenant_db_count The number of couchdb databases including global tables such as _users.\n# TYPE budibase_tenant_db_count gauge\nbudibase_tenant_db_count 3\n# HELP budibase_quota_usage_apps The number of apps created.\n# TYPE budibase_quota_usage_apps gauge\nbudibase_quota_usage_apps 1\n# HELP budibase_quota_limit_apps The limit on the number of apps that can be created.\n# TYPE budibase_quota_limit_apps gauge\nbudibase_quota_limit_apps 9007199254740991\n# HELP budibase_quota_usage_rows The number of database rows used from the quota.\n# TYPE budibase_quota_usage_rows gauge\nbudibase_quota_usage_rows 0\n# HELP budibase_quota_limit_rows The limit on the number of rows that can be created.\n# TYPE budibase_quota_limit_rows gauge\nbudibase_quota_limit_rows 9007199254740991\n# HELP budibase_quota_usage_plugins The number of plugins in use.\n# TYPE budibase_quota_usage_plugins gauge\nbudibase_quota_usage_plugins 0\n# HELP budibase_quota_limit_plugins The limit on the number of plugins that can be created.\n# TYPE budibase_quota_limit_plugins gauge\nbudibase_quota_limit_plugins 9007199254740991\n# HELP budibase_quota_usage_user_groups The number of user groups created.\n# TYPE budibase_quota_usage_user_groups gauge\nbudibase_quota_usage_user_groups 0\n# HELP budibase_quota_limit_user_groups The limit on the number of user groups that can be created.\n# TYPE budibase_quota_limit_user_groups gauge\nbudibase_quota_limit_user_groups 9007199254740991\n# HELP budibase_quota_usage_queries The number of queries used in the current month.\n# TYPE budibase_quota_usage_queries gauge\nbudibase_quota_usage_queries 0\n# HELP budibase_quota_limit_queries The limit on the number of queries for the current month.\n# TYPE budibase_quota_limit_queries gauge\nbudibase_quota_limit_queries 9007199254740991\n# HELP budibase_quota_usage_automations The number of automations used in the current month.\n# TYPE budibase_quota_usage_automations gauge\nbudibase_quota_usage_automations 0\n# HELP budibase_quota_limit_automations The limit on the number of automations that can be created.\n# TYPE budibase_quota_limit_automations gauge\nbudibase_quota_limit_automations 9007199254740991\n"
} }
}, },
"securitySchemes": { "securitySchemes": {
@ -2066,7 +2078,16 @@
"200": { "200": {
"description": "Returns tenant metrics.", "description": "Returns tenant metrics.",
"content": { "content": {
"text/plain": null "text/plain": {
"schema": {
"type": "string"
},
"examples": {
"metrics": {
"$ref": "#/components/examples/metrics"
}
}
}
} }
} }
} }

View file

@ -85,6 +85,12 @@ components:
updatedAt: 2022-02-22T13:00:54.035Z updatedAt: 2022-02-22T13:00:54.035Z
createdAt: 2022-02-11T18:02:26.961Z createdAt: 2022-02-11T18:02:26.961Z
status: development status: development
deploymentOutput:
value:
data:
_id: ef12381f934b4f129675cdbb76eff3c2
status: SUCCESS
appUrl: /app-url
inputRow: inputRow:
value: value:
_id: ro_ta_5b1649e42a5b41dea4ef7742a36a7a70_e6dc7e38cf1343b2b56760265201cda4 _id: ro_ta_5b1649e42a5b41dea4ef7742a36a7a70_e6dc7e38cf1343b2b56760265201cda4
@ -290,6 +296,152 @@ components:
name: Admin name: Admin
permissionId: admin permissionId: admin
inherits: POWER inherits: POWER
metrics:
value: >
# HELP budibase_os_uptime Time in seconds that the host operating system
has been up.
# TYPE budibase_os_uptime counter
budibase_os_uptime 54958
# HELP budibase_os_free_mem Bytes of memory free for usage on the host operating system.
# TYPE budibase_os_free_mem gauge
budibase_os_free_mem 804507648
# HELP budibase_os_total_mem Total bytes of memory on the host operating system.
# TYPE budibase_os_total_mem gauge
budibase_os_total_mem 16742404096
# HELP budibase_os_used_mem Total bytes of memory in use on the host operating system.
# TYPE budibase_os_used_mem gauge
budibase_os_used_mem 15937896448
# HELP budibase_os_load1 Host operating system load average.
# TYPE budibase_os_load1 gauge
budibase_os_load1 1.91
# HELP budibase_os_load5 Host operating system load average.
# TYPE budibase_os_load5 gauge
budibase_os_load5 1.75
# HELP budibase_os_load15 Host operating system load average.
# TYPE budibase_os_load15 gauge
budibase_os_load15 1.56
# HELP budibase_tenant_user_count The number of users created.
# TYPE budibase_tenant_user_count gauge
budibase_tenant_user_count 1
# HELP budibase_tenant_app_count The number of apps created by a user.
# TYPE budibase_tenant_app_count gauge
budibase_tenant_app_count 2
# HELP budibase_tenant_production_app_count The number of apps a user has published.
# TYPE budibase_tenant_production_app_count gauge
budibase_tenant_production_app_count 1
# HELP budibase_tenant_dev_app_count The number of apps a user has unpublished in development.
# TYPE budibase_tenant_dev_app_count gauge
budibase_tenant_dev_app_count 1
# HELP budibase_tenant_db_count The number of couchdb databases including global tables such as _users.
# TYPE budibase_tenant_db_count gauge
budibase_tenant_db_count 3
# HELP budibase_quota_usage_apps The number of apps created.
# TYPE budibase_quota_usage_apps gauge
budibase_quota_usage_apps 1
# HELP budibase_quota_limit_apps The limit on the number of apps that can be created.
# TYPE budibase_quota_limit_apps gauge
budibase_quota_limit_apps 9007199254740991
# HELP budibase_quota_usage_rows The number of database rows used from the quota.
# TYPE budibase_quota_usage_rows gauge
budibase_quota_usage_rows 0
# HELP budibase_quota_limit_rows The limit on the number of rows that can be created.
# TYPE budibase_quota_limit_rows gauge
budibase_quota_limit_rows 9007199254740991
# HELP budibase_quota_usage_plugins The number of plugins in use.
# TYPE budibase_quota_usage_plugins gauge
budibase_quota_usage_plugins 0
# HELP budibase_quota_limit_plugins The limit on the number of plugins that can be created.
# TYPE budibase_quota_limit_plugins gauge
budibase_quota_limit_plugins 9007199254740991
# HELP budibase_quota_usage_user_groups The number of user groups created.
# TYPE budibase_quota_usage_user_groups gauge
budibase_quota_usage_user_groups 0
# HELP budibase_quota_limit_user_groups The limit on the number of user groups that can be created.
# TYPE budibase_quota_limit_user_groups gauge
budibase_quota_limit_user_groups 9007199254740991
# HELP budibase_quota_usage_queries The number of queries used in the current month.
# TYPE budibase_quota_usage_queries gauge
budibase_quota_usage_queries 0
# HELP budibase_quota_limit_queries The limit on the number of queries for the current month.
# TYPE budibase_quota_limit_queries gauge
budibase_quota_limit_queries 9007199254740991
# HELP budibase_quota_usage_automations The number of automations used in the current month.
# TYPE budibase_quota_usage_automations gauge
budibase_quota_usage_automations 0
# HELP budibase_quota_limit_automations The limit on the number of automations that can be created.
# TYPE budibase_quota_limit_automations gauge
budibase_quota_limit_automations 9007199254740991
securitySchemes: securitySchemes:
ApiKeyAuth: ApiKeyAuth:
type: apiKey type: apiKey
@ -1542,7 +1694,12 @@ paths:
"200": "200":
description: Returns tenant metrics. description: Returns tenant metrics.
content: content:
? text/plain text/plain:
schema:
type: string
examples:
metrics:
$ref: "#/components/examples/metrics"
"/queries/{queryId}": "/queries/{queryId}":
post: post:
operationId: queryExecute operationId: queryExecute

View file

@ -15,6 +15,12 @@ const application = {
lockedBy: userResource.getExamples().user.value.user, lockedBy: userResource.getExamples().user.value.user,
} }
const deployment = {
_id: "ef12381f934b4f129675cdbb76eff3c2",
status: "SUCCESS",
appUrl: "/app-url",
}
const base = { const base = {
name: { name: {
description: "The name of the app.", description: "The name of the app.",
@ -108,6 +114,11 @@ export default new Resource()
data: [application], data: [application],
}, },
}, },
deploymentOutput: {
value: {
data: deployment,
},
},
}) })
.setSchemas({ .setSchemas({
application: applicationSchema, application: applicationSchema,

View file

@ -3,6 +3,7 @@ import row from "./row"
import table from "./table" import table from "./table"
import query from "./query" import query from "./query"
import user from "./user" import user from "./user"
import metrics from "./metrics"
import misc from "./misc" import misc from "./misc"
export const examples = { export const examples = {
@ -12,6 +13,7 @@ export const examples = {
...query.getExamples(), ...query.getExamples(),
...user.getExamples(), ...user.getExamples(),
...misc.getExamples(), ...misc.getExamples(),
...metrics.getExamples(),
} }
export const schemas = { export const schemas = {

View file

@ -0,0 +1,81 @@
import Resource from "./utils/Resource"
const metricsResponse =
"# HELP budibase_os_uptime Time in seconds that the host operating system has been up.\n" +
"# TYPE budibase_os_uptime counter\n" +
"budibase_os_uptime 54958\n" +
"# HELP budibase_os_free_mem Bytes of memory free for usage on the host operating system.\n" +
"# TYPE budibase_os_free_mem gauge\n" +
"budibase_os_free_mem 804507648\n" +
"# HELP budibase_os_total_mem Total bytes of memory on the host operating system.\n" +
"# TYPE budibase_os_total_mem gauge\n" +
"budibase_os_total_mem 16742404096\n" +
"# HELP budibase_os_used_mem Total bytes of memory in use on the host operating system.\n" +
"# TYPE budibase_os_used_mem gauge\n" +
"budibase_os_used_mem 15937896448\n" +
"# HELP budibase_os_load1 Host operating system load average.\n" +
"# TYPE budibase_os_load1 gauge\n" +
"budibase_os_load1 1.91\n" +
"# HELP budibase_os_load5 Host operating system load average.\n" +
"# TYPE budibase_os_load5 gauge\n" +
"budibase_os_load5 1.75\n" +
"# HELP budibase_os_load15 Host operating system load average.\n" +
"# TYPE budibase_os_load15 gauge\n" +
"budibase_os_load15 1.56\n" +
"# HELP budibase_tenant_user_count The number of users created.\n" +
"# TYPE budibase_tenant_user_count gauge\n" +
"budibase_tenant_user_count 1\n" +
"# HELP budibase_tenant_app_count The number of apps created by a user.\n" +
"# TYPE budibase_tenant_app_count gauge\n" +
"budibase_tenant_app_count 2\n" +
"# HELP budibase_tenant_production_app_count The number of apps a user has published.\n" +
"# TYPE budibase_tenant_production_app_count gauge\n" +
"budibase_tenant_production_app_count 1\n" +
"# HELP budibase_tenant_dev_app_count The number of apps a user has unpublished in development.\n" +
"# TYPE budibase_tenant_dev_app_count gauge\n" +
"budibase_tenant_dev_app_count 1\n" +
"# HELP budibase_tenant_db_count The number of couchdb databases including global tables such as _users.\n" +
"# TYPE budibase_tenant_db_count gauge\n" +
"budibase_tenant_db_count 3\n" +
"# HELP budibase_quota_usage_apps The number of apps created.\n" +
"# TYPE budibase_quota_usage_apps gauge\n" +
"budibase_quota_usage_apps 1\n" +
"# HELP budibase_quota_limit_apps The limit on the number of apps that can be created.\n" +
"# TYPE budibase_quota_limit_apps gauge\n" +
"budibase_quota_limit_apps 9007199254740991\n" +
"# HELP budibase_quota_usage_rows The number of database rows used from the quota.\n" +
"# TYPE budibase_quota_usage_rows gauge\n" +
"budibase_quota_usage_rows 0\n" +
"# HELP budibase_quota_limit_rows The limit on the number of rows that can be created.\n" +
"# TYPE budibase_quota_limit_rows gauge\n" +
"budibase_quota_limit_rows 9007199254740991\n" +
"# HELP budibase_quota_usage_plugins The number of plugins in use.\n" +
"# TYPE budibase_quota_usage_plugins gauge\n" +
"budibase_quota_usage_plugins 0\n" +
"# HELP budibase_quota_limit_plugins The limit on the number of plugins that can be created.\n" +
"# TYPE budibase_quota_limit_plugins gauge\n" +
"budibase_quota_limit_plugins 9007199254740991\n" +
"# HELP budibase_quota_usage_user_groups The number of user groups created.\n" +
"# TYPE budibase_quota_usage_user_groups gauge\n" +
"budibase_quota_usage_user_groups 0\n" +
"# HELP budibase_quota_limit_user_groups The limit on the number of user groups that can be created.\n" +
"# TYPE budibase_quota_limit_user_groups gauge\n" +
"budibase_quota_limit_user_groups 9007199254740991\n" +
"# HELP budibase_quota_usage_queries The number of queries used in the current month.\n" +
"# TYPE budibase_quota_usage_queries gauge\n" +
"budibase_quota_usage_queries 0\n" +
"# HELP budibase_quota_limit_queries The limit on the number of queries for the current month.\n" +
"# TYPE budibase_quota_limit_queries gauge\n" +
"budibase_quota_limit_queries 9007199254740991\n" +
"# HELP budibase_quota_usage_automations The number of automations used in the current month.\n" +
"# TYPE budibase_quota_usage_automations gauge\n" +
"budibase_quota_usage_automations 0\n" +
"# HELP budibase_quota_limit_automations The limit on the number of automations that can be created.\n" +
"# TYPE budibase_quota_limit_automations gauge\n" +
"budibase_quota_limit_automations 9007199254740991\n"
export default new Resource().setExamples({
metrics: {
value: metricsResponse,
},
})

View file

@ -232,7 +232,7 @@ export async function fetch(ctx: BBContext) {
: automationsQuotaLimit : automationsQuotaLimit
) )
ctx.body = outputString ctx.body = outputString
ctx.set('Content-Type', 'text/plain'); ctx.set("Content-Type", "text/plain")
} }
export function convertToOpenMetrics( export function convertToOpenMetrics(

View file

@ -17,6 +17,11 @@ const read = []
* description: Returns tenant metrics. * description: Returns tenant metrics.
* content: * content:
* text/plain: * text/plain:
* schema:
* type: string
* examples:
* metrics:
* $ref: '#/components/examples/metrics'
*/ */
read.push(new Endpoint("get", "/metrics", controller.fetch)) read.push(new Endpoint("get", "/metrics", controller.fetch))

View file

@ -22,6 +22,10 @@ export interface paths {
/** Based on application properties (currently only name) search for applications. */ /** Based on application properties (currently only name) search for applications. */
post: operations["appSearch"]; post: operations["appSearch"];
}; };
"/metrics": {
/** Output metrics in OpenMetrics format compatible with Prometheus */
get: operations["getById"];
};
"/queries/{queryId}": { "/queries/{queryId}": {
/** Queries which have been created within a Budibase app can be executed using this, */ /** Queries which have been created within a Budibase app can be executed using this, */
post: operations["queryExecute"]; post: operations["queryExecute"];
@ -844,6 +848,17 @@ export interface operations {
}; };
}; };
}; };
/** Output metrics in OpenMetrics format compatible with Prometheus */
getById: {
responses: {
/** Returns tenant metrics. */
200: {
content: {
"text/plain": string;
};
};
};
};
/** Queries which have been created within a Budibase app can be executed using this, */ /** Queries which have been created within a Budibase app can be executed using this, */
queryExecute: { queryExecute: {
parameters: { parameters: {