1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-07-26 13:48:33 +02:00
unleash.unleash/src/lib/openapi/spec/instance-admin-stats-schema.ts
Thomas Heartman b0541a0af2
feat: add remaining resource usage to instance stats (#7958)
Updates the instance stats endpoint with 
- maxEnvironmentStrategies
- maxConstraints
- maxConstraintValues

It adds the following rows to the front end table:
- segments (already in the payload, just not used for the table before)
- API tokens (separate rows for type, + one for total) (also existed
before, but wasn't listed)
- Highest number of strategies used for a single flag in a single
environment
- Highest number of constraints used on a single strategy
- Highest number of values used for a single constraint


![image](https://github.com/user-attachments/assets/57798f8e-c466-4590-820b-15afd3729243)
2024-08-22 13:09:26 +02:00

282 lines
9.6 KiB
TypeScript

import type { FromSchema } from 'json-schema-to-ts';
export const instanceAdminStatsSchema = {
$id: '#/components/schemas/instanceAdminStatsSchema',
type: 'object',
additionalProperties: false,
description:
'Information about an instance and statistics about usage of various features of Unleash',
required: ['instanceId'],
properties: {
instanceId: {
type: 'string',
description:
'A unique identifier for this instance. Generated by the database migration scripts at first run. Typically a UUID.',
example: 'ed3861ae-78f9-4e8c-8e57-b57efc15f82b',
},
timestamp: {
type: 'string',
format: 'date-time',
nullable: true,
description: 'When these statistics were produced',
example: '2023-06-12T12:25:06Z',
},
versionOSS: {
type: 'string',
description:
'The version of Unleash OSS that is bundled in this instance',
example: '5.1.7',
},
versionEnterprise: {
type: 'string',
description:
'The version of Unleash Enterprise that is bundled in this instance',
example: '5.1.7',
},
users: {
type: 'integer',
description: 'The number of users this instance has',
example: 8,
minimum: 0,
},
previousDayMetricsBucketsCount: {
type: 'object',
description:
'The number client metrics buckets records recorded in the previous day. # features * # apps * # envs * # hours with metrics',
properties: {
enabledCount: {
type: 'integer',
description:
'The number of enabled/disabled metrics buckets recorded in the previous day',
example: 10,
minimum: 0,
},
variantCount: {
type: 'integer',
description:
'The number of variant metrics buckets recorded in the previous day',
example: 10,
minimum: 0,
},
},
},
activeUsers: {
type: 'object',
description:
'The number of active users in the last 7, 30 and 90 days',
properties: {
last7: {
type: 'integer',
description:
'The number of active users in the last 7 days',
example: 5,
minimum: 0,
},
last30: {
type: 'integer',
description:
'The number of active users in the last 30 days',
example: 10,
minimum: 0,
},
last60: {
type: 'integer',
description:
'The number of active users in the last 60 days',
example: 12,
minimum: 0,
},
last90: {
type: 'integer',
description:
'The number of active users in the last 90 days',
example: 15,
minimum: 0,
},
},
},
productionChanges: {
type: 'object',
description:
'The number of changes to the production environment in the last 30, 60 and 90 days',
properties: {
last30: {
type: 'integer',
description:
'The number of changes in production in the last 30 days',
example: 10,
minimum: 0,
},
last60: {
type: 'integer',
description:
'The number of changes in production in the last 60 days',
example: 12,
minimum: 0,
},
last90: {
type: 'integer',
description:
'The number of changes in production in the last 90 days',
example: 15,
minimum: 0,
},
},
},
featureToggles: {
type: 'integer',
description: 'The number of feature-toggles this instance has',
example: 47,
minimum: 0,
},
projects: {
type: 'integer',
description: 'The number of projects defined in this instance.',
example: 3,
minimum: 0,
},
contextFields: {
type: 'integer',
description:
'The number of context fields defined in this instance.',
example: 7,
minimum: 0,
},
roles: {
type: 'integer',
description: 'The number of roles defined in this instance',
example: 5,
minimum: 0,
},
groups: {
type: 'integer',
description: 'The number of groups defined in this instance',
example: 12,
minimum: 0,
},
environments: {
type: 'integer',
description: 'The number of environments defined in this instance',
example: 3,
minimum: 0,
},
segments: {
type: 'integer',
description: 'The number of segments defined in this instance',
example: 19,
minimum: 0,
},
strategies: {
type: 'integer',
description: 'The number of strategies defined in this instance',
example: 8,
minimum: 0,
},
SAMLenabled: {
type: 'boolean',
description:
'Whether or not SAML authentication is enabled for this instance',
example: false,
},
OIDCenabled: {
type: 'boolean',
description:
'Whether or not OIDC authentication is enabled for this instance',
example: true,
},
clientApps: {
type: 'array',
description:
'A count of connected applications in the last week, last month and all time since last restart',
items: {
type: 'object',
description:
'An entry describing how many client applications has been observed over the defined range',
properties: {
range: {
type: 'string',
description: 'A description of a time range',
enum: ['allTime', '30d', '7d'],
example: '30d',
},
count: {
type: 'integer',
description:
'The number of client applications that have been observed in this period',
example: 1,
},
},
},
},
featureExports: {
type: 'integer',
description: 'The number of export operations on this instance',
example: 0,
minimum: 0,
},
featureImports: {
type: 'integer',
description: 'The number of import operations on this instance',
example: 0,
minimum: 0,
},
apiTokens: {
type: 'object',
description: 'The number of API tokens in Unleash, split by type',
properties: {
admin: {
type: 'integer',
description: 'The number of admin tokens.',
minimum: 0,
example: 5,
},
client: {
type: 'integer',
description: 'The number of client tokens.',
minimum: 0,
example: 5,
},
frontend: {
type: 'integer',
description: 'The number of frontend tokens.',
minimum: 0,
example: 5,
},
},
},
maxEnvironmentStrategies: {
type: 'integer',
minimum: 0,
example: 3,
description:
'The highest number of strategies used on a single feature flag in a single environment.',
},
maxConstraints: {
type: 'integer',
minimum: 0,
example: 4,
description:
'The highest number of constraints used on a single strategy.',
},
maxConstraintValues: {
type: 'integer',
minimum: 0,
example: 17,
description:
'The highest number of constraint values used on a single constraint.',
},
sum: {
type: 'string',
description:
'A SHA-256 checksum of the instance statistics to be used to verify that the data in this object has not been tampered with',
example:
'b023323477abb1eb145bebf3cdb30a1c2063e3edc1f7ae474ed8ed6c80de9a3b',
},
},
components: {},
} as const;
export type InstanceAdminStatsSchema = FromSchema<
typeof instanceAdminStatsSchema
>;