diff --git a/src/lib/features/instance-stats/instance-stats-service.ts b/src/lib/features/instance-stats/instance-stats-service.ts index 17d7b34730..04e6ec30d1 100644 --- a/src/lib/features/instance-stats/instance-stats-service.ts +++ b/src/lib/features/instance-stats/instance-stats-service.ts @@ -39,6 +39,7 @@ export interface InstanceStats { serviceAccounts: number; apiTokens: Map; featureToggles: number; + archivedFeatureToggles: number; projects: ProjectModeCount[]; contextFields: number; roles: number; @@ -192,6 +193,12 @@ export class InstanceStatsService { }); } + getArchivedToggleCount(): Promise { + return this.featureToggleStore.count({ + archived: true, + }); + } + async hasOIDC(): Promise { const settings = await this.settingStore.get<{ enabled: boolean }>( 'unleash.enterprise.auth.oidc', @@ -215,6 +222,7 @@ export class InstanceStatsService { const versionInfo = await this.versionService.getVersionInfo(); const [ featureToggles, + archivedFeatureToggles, users, serviceAccounts, apiTokens, @@ -237,6 +245,7 @@ export class InstanceStatsService { previousDayMetricsBucketsCount, ] = await Promise.all([ this.getToggleCount(), + this.getArchivedToggleCount(), this.userStore.count(), this.userStore.countServiceAccounts(), this.apiTokenStore.countByType(), @@ -269,6 +278,7 @@ export class InstanceStatsService { apiTokens, activeUsers, featureToggles, + archivedFeatureToggles, projects, contextFields, roles, diff --git a/src/lib/metrics.test.ts b/src/lib/metrics.test.ts index 7f27944716..be2574d228 100644 --- a/src/lib/metrics.test.ts +++ b/src/lib/metrics.test.ts @@ -190,6 +190,11 @@ test('should collect metrics for feature toggle size', async () => { expect(metrics).toMatch(/feature_toggles_total\{version="(.*)"\} 0/); }); +test('should collect metrics for archived feature toggle size', async () => { + const metrics = await prometheusRegister.metrics(); + expect(metrics).toMatch(/feature_toggles_archived_total 0/); +}); + test('should collect metrics for total client apps', async () => { await statsService.refreshAppCountSnapshot(); const metrics = await prometheusRegister.metrics(); diff --git a/src/lib/metrics.ts b/src/lib/metrics.ts index 2643ba67c6..33f025a97f 100644 --- a/src/lib/metrics.ts +++ b/src/lib/metrics.ts @@ -108,6 +108,11 @@ export default class MetricsMonitor { help: 'Number of feature toggles', labelNames: ['version'], }); + + const featureTogglesArchivedTotal = createGauge({ + name: 'feature_toggles_archived_total', + help: 'Number of archived feature toggles', + }); const usersTotal = createGauge({ name: 'users_total', help: 'Number of users', @@ -262,6 +267,9 @@ export default class MetricsMonitor { .labels({ version }) .set(stats.featureToggles); + featureTogglesArchivedTotal.reset(); + featureTogglesArchivedTotal.set(stats.archivedFeatureToggles); + usersTotal.reset(); usersTotal.set(stats.users); diff --git a/src/lib/routes/admin-api/instance-admin.ts b/src/lib/routes/admin-api/instance-admin.ts index 42f2db72f5..65e1b457b7 100644 --- a/src/lib/routes/admin-api/instance-admin.ts +++ b/src/lib/routes/admin-api/instance-admin.ts @@ -94,6 +94,7 @@ class InstanceAdminController extends Controller { featureExports: 0, featureImports: 0, featureToggles: 29, + archivedFeatureToggles: 10, groups: 3, instanceId: 'ed3861ae-78f9-4e8c-8e57-b57efc15f82b', projects: 4,