mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-25 00:07:47 +01:00
feat: collect prometheus data about archived features (#6728)
This commit is contained in:
parent
5b325568d1
commit
d3847fd8ee
@ -39,6 +39,7 @@ export interface InstanceStats {
|
||||
serviceAccounts: number;
|
||||
apiTokens: Map<string, number>;
|
||||
featureToggles: number;
|
||||
archivedFeatureToggles: number;
|
||||
projects: ProjectModeCount[];
|
||||
contextFields: number;
|
||||
roles: number;
|
||||
@ -192,6 +193,12 @@ export class InstanceStatsService {
|
||||
});
|
||||
}
|
||||
|
||||
getArchivedToggleCount(): Promise<number> {
|
||||
return this.featureToggleStore.count({
|
||||
archived: true,
|
||||
});
|
||||
}
|
||||
|
||||
async hasOIDC(): Promise<boolean> {
|
||||
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,
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user