1
0
Fork 0
mirror of synced 2024-07-08 15:56:23 +12:00

Merge branch 'develop' of github.com:Budibase/budibase into just-dataspace-things

This commit is contained in:
Andrew Kingston 2023-03-13 11:30:18 +00:00
commit 909118d398
32 changed files with 733 additions and 81 deletions

View file

@ -1,5 +1,5 @@
{
"version": "2.4.12-alpha.0",
"version": "2.4.12-alpha.3",
"npmClient": "yarn",
"packages": [
"packages/*"

View file

@ -1,6 +1,6 @@
{
"name": "@budibase/backend-core",
"version": "2.4.12-alpha.0",
"version": "2.4.12-alpha.3",
"description": "Budibase backend core libraries used in server and worker",
"main": "dist/src/index.js",
"types": "dist/src/index.d.ts",
@ -24,7 +24,7 @@
"dependencies": {
"@budibase/nano": "10.1.2",
"@budibase/pouchdb-replication-stream": "1.2.10",
"@budibase/types": "2.4.12-alpha.0",
"@budibase/types": "2.4.12-alpha.3",
"@shopify/jest-koa-mocks": "5.0.1",
"@techpass/passport-openidconnect": "0.3.2",
"aws-cloudfront-sign": "2.2.0",

View file

@ -5,6 +5,8 @@ import {
generateAppUserID,
queryGlobalView,
UNICODE_MAX,
DocumentType,
SEPARATOR,
directCouchFind,
} from "./db"
import { BulkDocsResponse, User } from "@budibase/types"
@ -45,6 +47,16 @@ export const bulkGetGlobalUsersById = async (
return users
}
export const getAllUserIds = async () => {
const db = getGlobalDB()
const startKey = `${DocumentType.USER}${SEPARATOR}`
const response = await db.allDocs({
startkey: startKey,
endkey: `${startKey}${UNICODE_MAX}`,
})
return response.rows.map(row => row.id)
}
export const bulkUpdateGlobalUsers = async (users: User[]) => {
const db = getGlobalDB()
return (await db.bulkDocs(users)) as BulkDocsResponse

View file

@ -1,7 +1,7 @@
{
"name": "@budibase/bbui",
"description": "A UI solution used in the different Budibase projects.",
"version": "2.4.12-alpha.0",
"version": "2.4.12-alpha.3",
"license": "MPL-2.0",
"svelte": "src/index.js",
"module": "dist/bbui.es.js",
@ -38,8 +38,8 @@
],
"dependencies": {
"@adobe/spectrum-css-workflow-icons": "1.2.1",
"@budibase/shared-core": "2.4.12-alpha.0",
"@budibase/string-templates": "2.4.12-alpha.0",
"@budibase/shared-core": "2.4.12-alpha.3",
"@budibase/string-templates": "2.4.12-alpha.3",
"@spectrum-css/accordion": "3.0.24",
"@spectrum-css/actionbutton": "1.0.1",
"@spectrum-css/actiongroup": "1.0.1",

View file

@ -1,5 +1,7 @@
<script>
import { Input, Icon, notifications } from "@budibase/bbui"
import Input from "../Form/Input.svelte"
import Icon from "../Icon/Icon.svelte"
import { notifications } from "../Stores/notifications"
export let label = null
export let value

View file

@ -67,6 +67,7 @@ export { default as ColorPicker } from "./ColorPicker/ColorPicker.svelte"
export { default as IconPicker } from "./IconPicker/IconPicker.svelte"
export { default as InlineAlert } from "./InlineAlert/InlineAlert.svelte"
export { default as Banner } from "./Banner/Banner.svelte"
export { default as CopyInput } from "./Input/CopyInput.svelte"
export { default as BannerDisplay } from "./Banner/BannerDisplay.svelte"
export { default as MarkdownEditor } from "./Markdown/MarkdownEditor.svelte"
export { default as MarkdownViewer } from "./Markdown/MarkdownViewer.svelte"

View file

@ -1,6 +1,6 @@
{
"name": "@budibase/builder",
"version": "2.4.12-alpha.0",
"version": "2.4.12-alpha.3",
"license": "GPL-3.0",
"private": true,
"scripts": {
@ -58,11 +58,11 @@
}
},
"dependencies": {
"@budibase/bbui": "2.4.12-alpha.0",
"@budibase/client": "2.4.12-alpha.0",
"@budibase/frontend-core": "2.4.12-alpha.0",
"@budibase/shared-core": "2.4.12-alpha.0",
"@budibase/string-templates": "2.4.12-alpha.0",
"@budibase/bbui": "2.4.12-alpha.3",
"@budibase/client": "2.4.12-alpha.3",
"@budibase/frontend-core": "2.4.12-alpha.3",
"@budibase/shared-core": "2.4.12-alpha.3",
"@budibase/string-templates": "2.4.12-alpha.3",
"@fortawesome/fontawesome-svg-core": "^6.2.1",
"@fortawesome/free-brands-svg-icons": "^6.2.1",
"@fortawesome/free-solid-svg-icons": "^6.2.1",

View file

@ -1,5 +1,5 @@
<script>
import CopyInput from "components/common/inputs/CopyInput.svelte"
import { CopyInput } from "@budibase/bbui"
export let value

View file

@ -5,12 +5,12 @@
notifications,
ModalContent,
Layout,
ProgressCircle,
CopyInput,
} from "@budibase/bbui"
import { API } from "api"
import analytics, { Events, EventSource } from "analytics"
import { store } from "builderStore"
import { ProgressCircle } from "@budibase/bbui"
import CopyInput from "components/common/inputs/CopyInput.svelte"
import TourWrap from "../portal/onboarding/TourWrap.svelte"
import { TOUR_STEP_KEYS } from "../portal/onboarding/tours.js"

View file

@ -1,9 +1,7 @@
<script>
import { ModalContent } from "@budibase/bbui"
import { Body, notifications } from "@budibase/bbui"
import { ModalContent, Body, notifications, CopyInput } from "@budibase/bbui"
import { auth } from "stores/portal"
import { onMount } from "svelte"
import CopyInput from "components/common/inputs/CopyInput.svelte"
let apiKey = null

View file

@ -7,6 +7,7 @@
clickOutside,
notifications,
ActionButton,
CopyInput,
} from "@budibase/bbui"
import { store } from "builderStore"
import { groups, licensing, apps, users } from "stores/portal"
@ -17,7 +18,6 @@
import RoleSelect from "components/common/RoleSelect.svelte"
import { Constants, Utils } from "@budibase/frontend-core"
import { emailValidator } from "helpers/validation"
import CopyInput from "components/common/inputs/CopyInput.svelte"
import { roles } from "stores/backend"
let query = null

View file

@ -1,6 +1,6 @@
{
"name": "@budibase/cli",
"version": "2.4.12-alpha.0",
"version": "2.4.12-alpha.3",
"description": "Budibase CLI, for developers, self hosting and migrations.",
"main": "dist/index.js",
"bin": {
@ -29,9 +29,9 @@
"outputPath": "build"
},
"dependencies": {
"@budibase/backend-core": "2.4.12-alpha.0",
"@budibase/string-templates": "2.4.12-alpha.0",
"@budibase/types": "2.4.12-alpha.0",
"@budibase/backend-core": "2.4.12-alpha.3",
"@budibase/string-templates": "2.4.12-alpha.3",
"@budibase/types": "2.4.12-alpha.3",
"axios": "0.21.2",
"chalk": "4.1.0",
"cli-progress": "3.11.2",

View file

@ -1,6 +1,6 @@
{
"name": "@budibase/client",
"version": "2.4.12-alpha.0",
"version": "2.4.12-alpha.3",
"license": "MPL-2.0",
"module": "dist/budibase-client.js",
"main": "dist/budibase-client.js",
@ -19,11 +19,11 @@
"dev:builder": "rollup -cw"
},
"dependencies": {
"@budibase/bbui": "2.4.12-alpha.0",
"@budibase/frontend-core": "2.4.12-alpha.0",
"@budibase/shared-core": "2.4.12-alpha.0",
"@budibase/string-templates": "2.4.12-alpha.0",
"@budibase/types": "2.4.8-alpha.4",
"@budibase/bbui": "2.4.12-alpha.3",
"@budibase/frontend-core": "2.4.12-alpha.3",
"@budibase/shared-core": "2.4.12-alpha.3",
"@budibase/string-templates": "2.4.12-alpha.3",
"@budibase/types": "2.4.12-alpha.3",
"@spectrum-css/button": "^3.0.3",
"@spectrum-css/card": "^3.0.3",
"@spectrum-css/divider": "^1.0.3",

View file

@ -1,13 +1,13 @@
{
"name": "@budibase/frontend-core",
"version": "2.4.12-alpha.0",
"version": "2.4.12-alpha.3",
"description": "Budibase frontend core libraries used in builder and client",
"author": "Budibase",
"license": "MPL-2.0",
"svelte": "src/index.js",
"dependencies": {
"@budibase/bbui": "2.4.12-alpha.0",
"@budibase/shared-core": "2.4.12-alpha.0",
"@budibase/bbui": "2.4.12-alpha.3",
"@budibase/shared-core": "2.4.12-alpha.3",
"dayjs": "^1.11.7",
"lodash": "^4.17.21",
"socket.io-client": "^4.6.1",

View file

@ -1,6 +1,6 @@
{
"name": "@budibase/sdk",
"version": "2.4.12-alpha.0",
"version": "2.4.12-alpha.3",
"description": "Budibase Public API SDK",
"author": "Budibase",
"license": "MPL-2.0",

View file

@ -1,7 +1,7 @@
{
"name": "@budibase/server",
"email": "hi@budibase.com",
"version": "2.4.12-alpha.0",
"version": "2.4.12-alpha.3",
"description": "Budibase Web Server",
"main": "src/index.ts",
"repository": {
@ -43,12 +43,12 @@
"license": "GPL-3.0",
"dependencies": {
"@apidevtools/swagger-parser": "10.0.3",
"@budibase/backend-core": "2.4.12-alpha.0",
"@budibase/client": "2.4.12-alpha.0",
"@budibase/pro": "2.4.12-alpha.0",
"@budibase/shared-core": "2.4.12-alpha.0",
"@budibase/string-templates": "2.4.12-alpha.0",
"@budibase/types": "2.4.12-alpha.0",
"@budibase/backend-core": "2.4.12-alpha.3",
"@budibase/client": "2.4.12-alpha.3",
"@budibase/pro": "2.4.12-alpha.3",
"@budibase/shared-core": "2.4.12-alpha.3",
"@budibase/string-templates": "2.4.12-alpha.3",
"@budibase/types": "2.4.12-alpha.3",
"@bull-board/api": "3.7.0",
"@bull-board/koa": "3.9.4",
"@elastic/elasticsearch": "7.10.0",

View file

@ -115,6 +115,15 @@
]
}
},
"deploymentOutput": {
"value": {
"data": {
"_id": "ef12381f934b4f129675cdbb76eff3c2",
"status": "SUCCESS",
"appUrl": "/app-url"
}
}
},
"inputRow": {
"value": {
"_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": {
@ -2054,6 +2066,33 @@
}
}
},
"/metrics": {
"get": {
"operationId": "metricsGet",
"summary": "Retrieve Budibase tenant metrics",
"description": "Output metrics in OpenMetrics format compatible with Prometheus",
"tags": [
"metrics"
],
"responses": {
"200": {
"description": "Returns tenant metrics.",
"content": {
"text/plain": {
"schema": {
"type": "string"
},
"examples": {
"metrics": {
"$ref": "#/components/examples/metrics"
}
}
}
}
}
}
}
},
"/queries/{queryId}": {
"post": {
"operationId": "queryExecute",

View file

@ -85,6 +85,12 @@ components:
updatedAt: 2022-02-22T13:00:54.035Z
createdAt: 2022-02-11T18:02:26.961Z
status: development
deploymentOutput:
value:
data:
_id: ef12381f934b4f129675cdbb76eff3c2
status: SUCCESS
appUrl: /app-url
inputRow:
value:
_id: ro_ta_5b1649e42a5b41dea4ef7742a36a7a70_e6dc7e38cf1343b2b56760265201cda4
@ -290,6 +296,152 @@ components:
name: Admin
permissionId: admin
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:
ApiKeyAuth:
type: apiKey
@ -1531,6 +1683,23 @@ paths:
examples:
applications:
$ref: "#/components/examples/applications"
/metrics:
get:
operationId: metricsGet
summary: Retrieve Budibase tenant metrics
description: Output metrics in OpenMetrics format compatible with Prometheus
tags:
- metrics
responses:
"200":
description: Returns tenant metrics.
content:
text/plain:
schema:
type: string
examples:
metrics:
$ref: "#/components/examples/metrics"
"/queries/{queryId}":
post:
operationId: queryExecute

View file

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

View file

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

@ -0,0 +1,251 @@
import { Ctx } from "@budibase/types"
import { users as userCore, db as dbCore } from "@budibase/backend-core"
import { quotas, licensing } from "@budibase/pro"
import os from "os"
export async function fetch(ctx: Ctx) {
// *** OPERATING SYSTEM ***
const freeMem = os.freemem()
const totalMem = os.totalmem()
const usedMem = totalMem - freeMem
const uptime = os.uptime()
// *** APPS ***
const allDatabases = await dbCore.getAllDbs()
const devAppIDs = await dbCore.getDevAppIDs()
const prodAppIDs = await dbCore.getProdAppIDs()
const allAppIds = await dbCore.getAllApps({ idsOnly: true })
// *** USERS ***
const usersObject = await userCore.getAllUserIds()
// *** QUOTAS ***
const usage = await quotas.getQuotaUsage()
const license = await licensing.cache.getCachedLicense()
const appsQuotaUsage = usage.usageQuota.apps
const rowsQuotaUsage = usage.usageQuota.rows
const pluginsQuotaUsage = usage.usageQuota.plugins
const userGroupsQuotaUsage = usage.usageQuota.userGroups
const queryQuotaUsage = usage.monthly.current.queries
const automationsQuotaUsage = usage.monthly.current.automations
const appsQuotaLimit = license.quotas.usage.static.apps.value
const rowsQuotaLimit = license.quotas.usage.static.rows.value
const userGroupsQuotaLimit = license.quotas.usage.static.userGroups.value
const pluginsQuotaLimit = license.quotas.usage.static.plugins.value
const queryQuotaLimit = license.quotas.usage.monthly.queries.value
const automationsQuotaLimit = license.quotas.usage.monthly.automations.value
// *** BUILD THE OUTPUT STRING ***
var outputString = ""
// **** budibase_os_uptime ****
outputString += convertToOpenMetrics(
"budibase_os_uptime",
"Time in seconds that the host operating system has been up",
"counter",
uptime
)
// **** budibase_os_free_mem ****
outputString += convertToOpenMetrics(
"budibase_os_free_mem",
"Bytes of memory free for usage on the host operating system",
"gauge",
freeMem
)
// **** budibase_os_total_mem ****
outputString += convertToOpenMetrics(
"budibase_os_total_mem",
"Total bytes of memory on the host operating system",
"gauge",
totalMem
)
// **** budibase_os_used_mem ****
outputString += convertToOpenMetrics(
"budibase_os_used_mem",
"Total bytes of memory in use on the host operating system",
"gauge",
usedMem
)
// **** budibase_os_load1 ****
outputString += convertToOpenMetrics(
"budibase_os_load1",
"Host operating system load average",
"gauge",
os.loadavg()[0]
)
// **** budibase_os_load5 ****
outputString += convertToOpenMetrics(
"budibase_os_load5",
"Host operating system load average",
"gauge",
os.loadavg()[1]
)
// **** budibase_os_load15 ****
outputString += convertToOpenMetrics(
"budibase_os_load15",
"Host operating system load average",
"gauge",
os.loadavg()[2]
)
// **** budibase_tenant_user_count ****
outputString += convertToOpenMetrics(
"budibase_tenant_user_count",
"The number of users created",
"gauge",
usersObject.length
)
// **** budibase_tenant_app_count ****
outputString += convertToOpenMetrics(
"budibase_tenant_app_count",
"The number of apps created by a user",
"gauge",
allAppIds.length
)
// **** budibase_tenant_production_app_count ****
outputString += convertToOpenMetrics(
"budibase_tenant_production_app_count",
"The number of apps a user has published",
"gauge",
prodAppIDs.length
)
// **** budibase_tenant_dev_app_count ****
outputString += convertToOpenMetrics(
"budibase_tenant_dev_app_count",
"The number of apps a user has unpublished in development",
"gauge",
devAppIDs.length
)
// **** budibase_tenant_db_count ****
outputString += convertToOpenMetrics(
"budibase_tenant_db_count",
"The number of couchdb databases including global tables such as _users",
"gauge",
allDatabases.length
)
// **** budibase_quota_usage_apps ****
outputString += convertToOpenMetrics(
"budibase_quota_usage_apps",
"The number of apps created",
"gauge",
appsQuotaUsage
)
// **** budibase_quota_limit_apps ****
outputString += convertToOpenMetrics(
"budibase_quota_limit_apps",
"The limit on the number of apps that can be created",
"gauge",
appsQuotaLimit == -1 ? Number.MAX_SAFE_INTEGER : appsQuotaLimit
)
// **** budibase_quota_usage_rows ****
outputString += convertToOpenMetrics(
"budibase_quota_usage_rows",
"The number of database rows used from the quota",
"gauge",
rowsQuotaUsage
)
// **** budibase_quota_limit_rows ****
outputString += convertToOpenMetrics(
"budibase_quota_limit_rows",
"The limit on the number of rows that can be created",
"gauge",
rowsQuotaLimit == -1 ? Number.MAX_SAFE_INTEGER : rowsQuotaLimit
)
// **** budibase_quota_usage_plugins ****
outputString += convertToOpenMetrics(
"budibase_quota_usage_plugins",
"The number of plugins in use",
"gauge",
pluginsQuotaUsage
)
// **** budibase_quota_limit_plugins ****
outputString += convertToOpenMetrics(
"budibase_quota_limit_plugins",
"The limit on the number of plugins that can be created",
"gauge",
pluginsQuotaLimit == -1 ? Number.MAX_SAFE_INTEGER : pluginsQuotaLimit
)
// **** budibase_quota_usage_user_groups ****
outputString += convertToOpenMetrics(
"budibase_quota_usage_user_groups",
"The number of user groups created",
"gauge",
userGroupsQuotaUsage
)
// **** budibase_quota_limit_user_groups ****
outputString += convertToOpenMetrics(
"budibase_quota_limit_user_groups",
"The limit on the number of user groups that can be created",
"gauge",
userGroupsQuotaLimit == -1 ? Number.MAX_SAFE_INTEGER : userGroupsQuotaLimit
)
// **** budibase_quota_usage_queries ****
outputString += convertToOpenMetrics(
"budibase_quota_usage_queries",
"The number of queries used in the current month",
"gauge",
queryQuotaUsage
)
// **** budibase_quota_limit_queries ****
outputString += convertToOpenMetrics(
"budibase_quota_limit_queries",
"The limit on the number of queries for the current month",
"gauge",
queryQuotaLimit == -1 ? Number.MAX_SAFE_INTEGER : queryQuotaLimit
)
// **** budibase_quota_usage_automations ****
outputString += convertToOpenMetrics(
"budibase_quota_usage_automations",
"The number of automations used in the current month",
"gauge",
automationsQuotaUsage
)
// **** budibase_quota_limit_automations ****
outputString += convertToOpenMetrics(
"budibase_quota_limit_automations",
"The limit on the number of automations that can be created",
"gauge",
automationsQuotaLimit == -1
? Number.MAX_SAFE_INTEGER
: automationsQuotaLimit
)
ctx.body = outputString
ctx.set("Content-Type", "text/plain")
}
export function convertToOpenMetrics(
metricName: string,
metricHelp: string,
metricType: string,
metricValue: number
) {
return `# HELP ${metricName} ${metricHelp}.
# TYPE ${metricName} ${metricType}
${metricName} ${metricValue}\n`
}
export default {
fetch,
}

View file

@ -1,4 +1,5 @@
import appEndpoints from "./applications"
import metricEndpoints from "./metrics"
import queryEndpoints from "./queries"
import tableEndpoints from "./tables"
import rowEndpoints from "./rows"
@ -12,7 +13,7 @@ import env from "../../../environment"
// below imports don't have declaration files
const Router = require("@koa/router")
const { RateLimit, Stores } = require("koa2-ratelimit")
import { redis, permissions } from "@budibase/backend-core"
import { middleware, redis, permissions } from "@budibase/backend-core"
const { PermissionType, PermissionLevel } = permissions
const PREFIX = "/api/public/v1"
@ -91,6 +92,13 @@ function addToRouter(endpoints: any) {
}
}
function applyAdminRoutes(endpoints: any) {
addMiddleware(endpoints.read, middleware.builderOrAdmin)
addMiddleware(endpoints.write, middleware.builderOrAdmin)
addToRouter(endpoints.read)
addToRouter(endpoints.write)
}
function applyRoutes(
endpoints: any,
permType: string,
@ -119,6 +127,7 @@ function applyRoutes(
addToRouter(endpoints.write)
}
applyAdminRoutes(metricEndpoints)
applyRoutes(appEndpoints, PermissionType.APP, "appId")
applyRoutes(tableEndpoints, PermissionType.TABLE, "tableId")
applyRoutes(userEndpoints, PermissionType.USER, "userId")

View file

@ -0,0 +1,28 @@
import controller from "../../controllers/public/metrics"
import Endpoint from "./utils/Endpoint"
const read = []
/**
* @openapi
* /metrics:
* get:
* operationId: metricsGet
* summary: Retrieve Budibase tenant metrics
* description: Output metrics in OpenMetrics format compatible with Prometheus
* tags:
* - metrics
* responses:
* 200:
* description: Returns tenant metrics.
* content:
* text/plain:
* schema:
* type: string
* examples:
* metrics:
* $ref: '#/components/examples/metrics'
*/
read.push(new Endpoint("get", "/metrics", controller.fetch))
export default { read }

View file

@ -0,0 +1,34 @@
const setup = require("../../tests/utilities")
jest.setTimeout(30000)
describe("/metrics", () => {
let request = setup.getRequest()
let config = setup.getConfig()
afterAll(setup.afterAll)
// For some reason this cannot be a beforeAll or the test "should be able to update the user" fail
beforeEach(async () => {
await config.init()
})
describe("get", () => {
it("returns a list of metrics", async () => {
const res = await request
.get(`/api/public/v1/metrics`)
.set(config.defaultHeaders())
.expect("Content-Type", /text\/plain/)
.expect(200)
expect(res.text).toContain("budibase_tenant_user_count")
})
it("endpoint should not be publicly exposed", async () => {
await request
.get(`/api/public/v1/metrics`)
.set(config.publicHeaders())
.expect(403)
})
})
})

View file

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

View file

@ -1278,14 +1278,14 @@
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
"@budibase/backend-core@2.4.12-alpha.0":
version "2.4.12-alpha.0"
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-2.4.12-alpha.0.tgz#4ca56bd24a9ff8a744436dd8754a98e1cb314a99"
integrity sha512-GCZwU/vO4itHxbtdDug8LseBU6S3EMHfB2BjvAIqfR3rGtA6n8i8fWJKBxuJY4b3IWbGynGZLYM/y4oRHVY1HA==
"@budibase/backend-core@2.4.12-alpha.3":
version "2.4.12-alpha.3"
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-2.4.12-alpha.3.tgz#5f5b1a7d0f47ae44910ea7d5de6eb805934d3f20"
integrity sha512-44A15I3sC+7CtZgm41xjyVAJ1eHoWXY67pM4G/ACIB0dVTZkGqCfiuWPQ92IL/fN8vw6IEjHCvebSLkDjqmGcg==
dependencies:
"@budibase/nano" "10.1.2"
"@budibase/pouchdb-replication-stream" "1.2.10"
"@budibase/types" "2.4.12-alpha.0"
"@budibase/types" "2.4.12-alpha.3"
"@shopify/jest-koa-mocks" "5.0.1"
"@techpass/passport-openidconnect" "0.3.2"
aws-cloudfront-sign "2.2.0"
@ -1417,14 +1417,14 @@
pouchdb-promise "^6.0.4"
through2 "^2.0.0"
"@budibase/pro@2.4.12-alpha.0":
version "2.4.12-alpha.0"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-2.4.12-alpha.0.tgz#27f0b52b19eb50bab5337ae04791a36b0e7d44b9"
integrity sha512-sXYKrR25CGDQj4+3SIXhPM0z7kDyLQwclHMag+5OewT9wHqKS6nKFLy3k+4eYDnus99t4MBv6EDXVnhb/gEjBQ==
"@budibase/pro@2.4.12-alpha.3":
version "2.4.12-alpha.3"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-2.4.12-alpha.3.tgz#e9c77a9b75fda94f289343350c659f2dc772d174"
integrity sha512-jq3IPaEij58hTMAJfvGQi9si/Zam1EG4+7rAOdoy0BdSMHUsvFYrOB7m++VmowPgwl2qkmCBa0dk95+70b0Ocw==
dependencies:
"@budibase/backend-core" "2.4.12-alpha.0"
"@budibase/backend-core" "2.4.12-alpha.3"
"@budibase/string-templates" "2.3.20"
"@budibase/types" "2.4.12-alpha.0"
"@budibase/types" "2.4.12-alpha.3"
"@koa/router" "8.0.8"
bull "4.10.1"
joi "17.6.0"
@ -1463,10 +1463,10 @@
lodash "^4.17.20"
vm2 "^3.9.4"
"@budibase/types@2.4.12-alpha.0":
version "2.4.12-alpha.0"
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-2.4.12-alpha.0.tgz#f46f4d5db05db0c98aca6bd572c2be0d27ec1961"
integrity sha512-NziMSJMDA070h/wfb/cTv8ZYHaUyLwEHqDXfMqy/XxGMruR+5u6uxRxvSAhg2EwNjmyRGhuBTUUsA/m5Wghj8g==
"@budibase/types@2.4.12-alpha.3":
version "2.4.12-alpha.3"
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-2.4.12-alpha.3.tgz#5b8ecea059dcee92e31ae673fd3f9092e570f41e"
integrity sha512-McKWpcbG+eFmO1NUWZUJurbH7FHuv95EdKNSMqY53QIQNoZ97uHf0rREc9Mw5pN0y+wzVLskq65pYa1isi0WSA==
"@bull-board/api@3.7.0":
version "3.7.0"

View file

@ -1,6 +1,6 @@
{
"name": "@budibase/shared-core",
"version": "2.4.12-alpha.0",
"version": "2.4.12-alpha.3",
"description": "Shared data utils",
"main": "dist/cjs/src/index.js",
"types": "dist/mjs/src/index.d.ts",
@ -20,7 +20,7 @@
"dev:builder": "yarn prebuild && concurrently \"tsc -p tsconfig.build.json --watch\" \"tsc -p tsconfig-cjs.build.json --watch\""
},
"dependencies": {
"@budibase/types": "2.4.5-alpha.0"
"@budibase/types": "2.4.12-alpha.3"
},
"devDependencies": {
"concurrently": "^7.6.0",

View file

@ -1,6 +1,6 @@
{
"name": "@budibase/string-templates",
"version": "2.4.12-alpha.0",
"version": "2.4.12-alpha.3",
"description": "Handlebars wrapper for Budibase templating.",
"main": "src/index.cjs",
"module": "dist/bundle.mjs",

View file

@ -1,6 +1,6 @@
{
"name": "@budibase/types",
"version": "2.4.12-alpha.0",
"version": "2.4.12-alpha.3",
"description": "Budibase types",
"main": "dist/cjs/index.js",
"types": "dist/mjs/index.d.ts",

View file

@ -1,7 +1,7 @@
{
"name": "@budibase/worker",
"email": "hi@budibase.com",
"version": "2.4.12-alpha.0",
"version": "2.4.12-alpha.3",
"description": "Budibase background service",
"main": "src/index.ts",
"repository": {
@ -36,10 +36,10 @@
"author": "Budibase",
"license": "GPL-3.0",
"dependencies": {
"@budibase/backend-core": "2.4.12-alpha.0",
"@budibase/pro": "2.4.12-alpha.0",
"@budibase/string-templates": "2.4.12-alpha.0",
"@budibase/types": "2.4.12-alpha.0",
"@budibase/backend-core": "2.4.12-alpha.3",
"@budibase/pro": "2.4.12-alpha.3",
"@budibase/string-templates": "2.4.12-alpha.3",
"@budibase/types": "2.4.12-alpha.3",
"@koa/router": "8.0.8",
"@sentry/node": "6.17.7",
"@techpass/passport-openidconnect": "0.3.2",

View file

@ -475,14 +475,14 @@
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
"@budibase/backend-core@2.4.12-alpha.0":
version "2.4.12-alpha.0"
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-2.4.12-alpha.0.tgz#4ca56bd24a9ff8a744436dd8754a98e1cb314a99"
integrity sha512-GCZwU/vO4itHxbtdDug8LseBU6S3EMHfB2BjvAIqfR3rGtA6n8i8fWJKBxuJY4b3IWbGynGZLYM/y4oRHVY1HA==
"@budibase/backend-core@2.4.12-alpha.3":
version "2.4.12-alpha.3"
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-2.4.12-alpha.3.tgz#5f5b1a7d0f47ae44910ea7d5de6eb805934d3f20"
integrity sha512-44A15I3sC+7CtZgm41xjyVAJ1eHoWXY67pM4G/ACIB0dVTZkGqCfiuWPQ92IL/fN8vw6IEjHCvebSLkDjqmGcg==
dependencies:
"@budibase/nano" "10.1.2"
"@budibase/pouchdb-replication-stream" "1.2.10"
"@budibase/types" "2.4.12-alpha.0"
"@budibase/types" "2.4.12-alpha.3"
"@shopify/jest-koa-mocks" "5.0.1"
"@techpass/passport-openidconnect" "0.3.2"
aws-cloudfront-sign "2.2.0"
@ -564,14 +564,14 @@
pouchdb-promise "^6.0.4"
through2 "^2.0.0"
"@budibase/pro@2.4.12-alpha.0":
version "2.4.12-alpha.0"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-2.4.12-alpha.0.tgz#27f0b52b19eb50bab5337ae04791a36b0e7d44b9"
integrity sha512-sXYKrR25CGDQj4+3SIXhPM0z7kDyLQwclHMag+5OewT9wHqKS6nKFLy3k+4eYDnus99t4MBv6EDXVnhb/gEjBQ==
"@budibase/pro@2.4.12-alpha.3":
version "2.4.12-alpha.3"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-2.4.12-alpha.3.tgz#e9c77a9b75fda94f289343350c659f2dc772d174"
integrity sha512-jq3IPaEij58hTMAJfvGQi9si/Zam1EG4+7rAOdoy0BdSMHUsvFYrOB7m++VmowPgwl2qkmCBa0dk95+70b0Ocw==
dependencies:
"@budibase/backend-core" "2.4.12-alpha.0"
"@budibase/backend-core" "2.4.12-alpha.3"
"@budibase/string-templates" "2.3.20"
"@budibase/types" "2.4.12-alpha.0"
"@budibase/types" "2.4.12-alpha.3"
"@koa/router" "8.0.8"
bull "4.10.1"
joi "17.6.0"
@ -592,10 +592,10 @@
lodash "^4.17.20"
vm2 "^3.9.4"
"@budibase/types@2.4.12-alpha.0":
version "2.4.12-alpha.0"
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-2.4.12-alpha.0.tgz#f46f4d5db05db0c98aca6bd572c2be0d27ec1961"
integrity sha512-NziMSJMDA070h/wfb/cTv8ZYHaUyLwEHqDXfMqy/XxGMruR+5u6uxRxvSAhg2EwNjmyRGhuBTUUsA/m5Wghj8g==
"@budibase/types@2.4.12-alpha.3":
version "2.4.12-alpha.3"
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-2.4.12-alpha.3.tgz#5b8ecea059dcee92e31ae673fd3f9092e570f41e"
integrity sha512-McKWpcbG+eFmO1NUWZUJurbH7FHuv95EdKNSMqY53QIQNoZ97uHf0rREc9Mw5pN0y+wzVLskq65pYa1isi0WSA==
"@cspotcode/source-map-support@^0.8.0":
version "0.8.1"