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;
|
serviceAccounts: number;
|
||||||
apiTokens: Map<string, number>;
|
apiTokens: Map<string, number>;
|
||||||
featureToggles: number;
|
featureToggles: number;
|
||||||
|
archivedFeatureToggles: number;
|
||||||
projects: ProjectModeCount[];
|
projects: ProjectModeCount[];
|
||||||
contextFields: number;
|
contextFields: number;
|
||||||
roles: number;
|
roles: number;
|
||||||
@ -192,6 +193,12 @@ export class InstanceStatsService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getArchivedToggleCount(): Promise<number> {
|
||||||
|
return this.featureToggleStore.count({
|
||||||
|
archived: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
async hasOIDC(): Promise<boolean> {
|
async hasOIDC(): Promise<boolean> {
|
||||||
const settings = await this.settingStore.get<{ enabled: boolean }>(
|
const settings = await this.settingStore.get<{ enabled: boolean }>(
|
||||||
'unleash.enterprise.auth.oidc',
|
'unleash.enterprise.auth.oidc',
|
||||||
@ -215,6 +222,7 @@ export class InstanceStatsService {
|
|||||||
const versionInfo = await this.versionService.getVersionInfo();
|
const versionInfo = await this.versionService.getVersionInfo();
|
||||||
const [
|
const [
|
||||||
featureToggles,
|
featureToggles,
|
||||||
|
archivedFeatureToggles,
|
||||||
users,
|
users,
|
||||||
serviceAccounts,
|
serviceAccounts,
|
||||||
apiTokens,
|
apiTokens,
|
||||||
@ -237,6 +245,7 @@ export class InstanceStatsService {
|
|||||||
previousDayMetricsBucketsCount,
|
previousDayMetricsBucketsCount,
|
||||||
] = await Promise.all([
|
] = await Promise.all([
|
||||||
this.getToggleCount(),
|
this.getToggleCount(),
|
||||||
|
this.getArchivedToggleCount(),
|
||||||
this.userStore.count(),
|
this.userStore.count(),
|
||||||
this.userStore.countServiceAccounts(),
|
this.userStore.countServiceAccounts(),
|
||||||
this.apiTokenStore.countByType(),
|
this.apiTokenStore.countByType(),
|
||||||
@ -269,6 +278,7 @@ export class InstanceStatsService {
|
|||||||
apiTokens,
|
apiTokens,
|
||||||
activeUsers,
|
activeUsers,
|
||||||
featureToggles,
|
featureToggles,
|
||||||
|
archivedFeatureToggles,
|
||||||
projects,
|
projects,
|
||||||
contextFields,
|
contextFields,
|
||||||
roles,
|
roles,
|
||||||
|
@ -190,6 +190,11 @@ test('should collect metrics for feature toggle size', async () => {
|
|||||||
expect(metrics).toMatch(/feature_toggles_total\{version="(.*)"\} 0/);
|
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 () => {
|
test('should collect metrics for total client apps', async () => {
|
||||||
await statsService.refreshAppCountSnapshot();
|
await statsService.refreshAppCountSnapshot();
|
||||||
const metrics = await prometheusRegister.metrics();
|
const metrics = await prometheusRegister.metrics();
|
||||||
|
@ -108,6 +108,11 @@ export default class MetricsMonitor {
|
|||||||
help: 'Number of feature toggles',
|
help: 'Number of feature toggles',
|
||||||
labelNames: ['version'],
|
labelNames: ['version'],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const featureTogglesArchivedTotal = createGauge({
|
||||||
|
name: 'feature_toggles_archived_total',
|
||||||
|
help: 'Number of archived feature toggles',
|
||||||
|
});
|
||||||
const usersTotal = createGauge({
|
const usersTotal = createGauge({
|
||||||
name: 'users_total',
|
name: 'users_total',
|
||||||
help: 'Number of users',
|
help: 'Number of users',
|
||||||
@ -262,6 +267,9 @@ export default class MetricsMonitor {
|
|||||||
.labels({ version })
|
.labels({ version })
|
||||||
.set(stats.featureToggles);
|
.set(stats.featureToggles);
|
||||||
|
|
||||||
|
featureTogglesArchivedTotal.reset();
|
||||||
|
featureTogglesArchivedTotal.set(stats.archivedFeatureToggles);
|
||||||
|
|
||||||
usersTotal.reset();
|
usersTotal.reset();
|
||||||
usersTotal.set(stats.users);
|
usersTotal.set(stats.users);
|
||||||
|
|
||||||
|
@ -94,6 +94,7 @@ class InstanceAdminController extends Controller {
|
|||||||
featureExports: 0,
|
featureExports: 0,
|
||||||
featureImports: 0,
|
featureImports: 0,
|
||||||
featureToggles: 29,
|
featureToggles: 29,
|
||||||
|
archivedFeatureToggles: 10,
|
||||||
groups: 3,
|
groups: 3,
|
||||||
instanceId: 'ed3861ae-78f9-4e8c-8e57-b57efc15f82b',
|
instanceId: 'ed3861ae-78f9-4e8c-8e57-b57efc15f82b',
|
||||||
projects: 4,
|
projects: 4,
|
||||||
|
Loading…
Reference in New Issue
Block a user