1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-02-09 00:18:00 +01:00

feat: prometheus now gets licensed users data (#8740)

We have the licensed users service implemented, this just spread the
data to prometheus.
This commit is contained in:
Jaanus Sellin 2024-11-13 16:00:47 +02:00 committed by GitHub
parent 088eaedbc3
commit d2daae5857
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 0 deletions

View File

@ -359,3 +359,9 @@ test('should collect traffic_total metrics', async () => {
await prometheusRegister.getSingleMetricAsString('traffic_total'); await prometheusRegister.getSingleMetricAsString('traffic_total');
expect(recordedMetric).toMatch(/traffic_total 0/); expect(recordedMetric).toMatch(/traffic_total 0/);
}); });
test('should collect licensed_users metrics', async () => {
const recordedMetric =
await prometheusRegister.getSingleMetricAsString('licensed_users');
expect(recordedMetric).toMatch(/licensed_users 0/);
});

View File

@ -650,6 +650,11 @@ export function registerPrometheusMetrics(
resourceLimit.labels({ resource }).set(limit); resourceLimit.labels({ resource }).set(limit);
} }
const licensedUsers = createGauge({
name: 'licensed_users',
help: 'The number of licensed users.',
});
const addonEventsHandledCounter = createCounter({ const addonEventsHandledCounter = createCounter({
name: 'addon_events_handled', name: 'addon_events_handled',
help: 'Events handled by addons and the result.', help: 'Events handled by addons and the result.',
@ -1018,6 +1023,11 @@ export function registerPrometheusMetrics(
usersActive90days.reset(); usersActive90days.reset();
usersActive90days.set(activeUsers.last90); usersActive90days.set(activeUsers.last90);
const licensedUsersStat =
await instanceStatsService.getLicencedUsers();
licensedUsers.reset();
licensedUsers.set(licensedUsersStat);
const productionChanges = const productionChanges =
await instanceStatsService.getProductionChanges(); await instanceStatsService.getProductionChanges();
productionChanges30.reset(); productionChanges30.reset();