Skip to content

Commit

Permalink
Website: add support for new usage statistics (#24511)
Browse files Browse the repository at this point in the history
Changes:
- Updated the receive-usage-analytics webhook to support a new input:
`numQueries`
- Added a new attribute to the HistoricalUsageSnapshot model
`numQueries`
- Added a commented-out section to the
send-aggregated-metrics-to-datadog script.
  • Loading branch information
eashaw authored Dec 13, 2024
1 parent 39e71cf commit 02b0a97
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ module.exports = {
maintenanceWindowsEnabled: {type: 'boolean', defaultsTo: false },
maintenanceWindowsConfigured: {type: 'boolean', defaultsTo: false },
numHostsFleetDesktopEnabled: {type: 'number', defaultsTo: 0 },
numQueries: {type: 'number', defaultsTo: 0 },
},


Expand Down
1 change: 1 addition & 0 deletions website/api/models/HistoricalUsageSnapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ module.exports = {
maintenanceWindowsEnabled: {required: true, type: 'boolean'},
maintenanceWindowsConfigured: {required: true, type: 'boolean'},
numHostsFleetDesktopEnabled: {required: true, type: 'number'},
numQueries: {required: true, type: 'number' },

// ╔═╗╔╦╗╔╗ ╔═╗╔╦╗╔═╗
// ║╣ ║║║╠╩╗║╣ ║║╚═╗
Expand Down
25 changes: 25 additions & 0 deletions website/scripts/send-aggregated-metrics-to-datadog.js
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,31 @@ module.exports = {
tags: [`license_tier:free`],
});

// FUTURE: Uncomment the section below to send metrics about reported number of queries to Datadog.
// let fleetInstancesThatReportedNumQueries = _.filter(latestStatisticsReportedByReleasedFleetVersions, (statistics)=>{
// return statistics.numQueries > 0;
// });

// let averageNumberOfQueries = Math.foor(_.sum(_.pluck(fleetInstancesThatReportedNumQueries, 'numQueries')) / fleetInstancesThatReportedNumQueries.length);
// metricsToReport.push({
// metric: 'usage_statistics.avg_num_queries',
// type: 3,
// points: [{
// timestamp: timestampForTheseMetrics,
// value: averageNumberOfQueries
// }],
// });

// let highestNumberOfQueries = _.max(_.pluck(fleetInstancesThatReportedNumQueries, 'numQueries'));
// metricsToReport.push({
// metric: 'usage_statistics.max_num_queries',
// type: 3,
// points: [{
// timestamp: timestampForTheseMetrics,
// value: highestNumberOfQueries
// }],
// });

// Break the metrics into smaller arrays to ensure we don't exceed Datadog's 512 kb request body limit.
let chunkedMetrics = _.chunk(metricsToReport, 500);// Note: 500 stringified JSON metrics is ~410 kb.
for(let chunkOfMetrics of chunkedMetrics) {
Expand Down

0 comments on commit 02b0a97

Please sign in to comment.