Skip to content

Commit

Permalink
feat: metrics for password and scim enabled (#8730)
Browse files Browse the repository at this point in the history
  • Loading branch information
kwasniew authored Nov 13, 2024
1 parent 7feba0c commit bb0403d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/lib/features/instance-stats/instance-stats-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,22 @@ export class InstanceStatsService {
return settings?.enabled || false;
}

async hasPasswordAuth(): Promise<boolean> {
const settings = await this.settingStore.get<{ disabled: boolean }>(
'unleash.auth.simple',
);

return settings?.disabled !== false;
}

async hasSCIM(): Promise<boolean> {
const settings = await this.settingStore.get<{ enabled: boolean }>(
'scim',
);

return settings?.enabled || false;
}

async getStats(): Promise<InstanceStats> {
const versionInfo = await this.versionService.getVersionInfo();
const [
Expand All @@ -239,6 +255,8 @@ export class InstanceStatsService {
strategies,
SAMLenabled,
OIDCenabled,
passwordAuthEnabled,
SCIMenabled,
clientApps,
featureExports,
featureImports,
Expand All @@ -265,6 +283,8 @@ export class InstanceStatsService {
this.strategiesCount(),
this.hasSAML(),
this.hasOIDC(),
this.hasPasswordAuth(),
this.hasSCIM(),
this.appCount ? this.appCount : this.getLabeledAppCounts(),
this.eventStore.deprecatedFilteredCount({
type: FEATURES_EXPORTED,
Expand Down
14 changes: 14 additions & 0 deletions src/lib/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,20 @@ export function registerPrometheusMetrics(
map: (result) => ({ value: result ? 1 : 0 }),
});

dbMetrics.registerGaugeDbMetric({
name: 'password_auth',
help: 'Whether password auth is enabled',
query: () => instanceStatsService.hasPasswordAuth(),
map: (result) => ({ value: result ? 1 : 0 }),
});

dbMetrics.registerGaugeDbMetric({
name: 'scim_enabled',
help: 'Whether SCIM is enabled',
query: () => instanceStatsService.hasSCIM(),
map: (result) => ({ value: result ? 1 : 0 }),
});

const clientSdkVersionUsage = createCounter({
name: 'client_sdk_versions',
help: 'Which sdk versions are being used',
Expand Down

0 comments on commit bb0403d

Please sign in to comment.