fleet/website/api/models/HistoricalUsageSnapshot.js
Eric 9ea69df576
Website: add new usage statistics (#19315)
Closes: https://github.com/fleetdm/fleet/issues/19308

Changes:
- Added six new attributes to the `HistoricalUsageSnapshot` model (
`numSoftwareVersions`, `numHostSoftwares`, `numSoftwareTitles`,
`numHostSoftwareInstalledPaths`, `numSoftwareCPEs` and
`numSoftwareCVEs`)
- Added inputs to the receive-usage-analytics webhook for the new usage
statistics.


When this PR is merged, we will need to migrate the Fleet website's
database to add the new columns, to do this:
- [x] Make an announcement in Slack to let people know the website will
be offline for ~8 minutes
- [ ] Merge this PR
- [ ] As the deploy action runs, put the website into maintenance mode
- [ ] Add the new columns for the added attributes
- [ ] Set the default value for the new attributes on existing database
records
- [ ] After the deploy workflow is complete, take the website out of
maintenance mode.
2024-06-04 18:36:25 -05:00

58 lines
3.3 KiB
JavaScript
Vendored

/**
* HistoricalUsageSnapshot.js
*
* @description :: A model definition represents a database table/collection.
* @docs :: https://sailsjs.com/docs/concepts/models-and-orm/models
*/
module.exports = {
attributes: {
// ╔═╗╦═╗╦╔╦╗╦╔╦╗╦╦ ╦╔═╗╔═╗
// ╠═╝╠╦╝║║║║║ ║ ║╚╗╔╝║╣ ╚═╗
// ╩ ╩╚═╩╩ ╩╩ ╩ ╩ ╚╝ ╚═╝╚═╝
anonymousIdentifier: { required: true, type: 'string', example: '9pnzNmrES3mQG66UQtd29cYTiX2+fZ4CYxDvh495720=', description: 'An anonymous identifier telling us which Fleet deployment this is.', },
fleetVersion: { required: true, type: 'string', example: 'x.x.x' },
licenseTier: { required: true, type: 'string', example: 'free' },
numHostsEnrolled: { required: true, type: 'number', min: 0, custom: (num) => Math.floor(num) === num },
numUsers: { required: true, type: 'number' },
numTeams: { required: true, type: 'number' },
numPolicies: { required: true, type: 'number' },
numLabels: { required: true, type: 'number' },
softwareInventoryEnabled: { required: true, type: 'boolean' },
vulnDetectionEnabled: { required: true, type: 'boolean' },
systemUsersEnabled: { required: true, type: 'boolean' },
hostsStatusWebHookEnabled: { required: true, type: 'boolean'},
numWeeklyActiveUsers: { required: true, type: 'number' },
numWeeklyPolicyViolationDaysActual: { required: true, type: 'number' },
numWeeklyPolicyViolationDaysPossible: { required: true, type: 'number'},
hostsEnrolledByOperatingSystem: { required: true, type: 'json' },
hostsEnrolledByOrbitVersion: { required: true, type: 'json' },
hostsEnrolledByOsqueryVersion: { required: true, type: 'json' },
storedErrors: { required: true, type: 'json' },
numHostsNotResponding: { required: true, type: 'number', description: 'The number of hosts per deployment that have not submitted results for distibuted queries. A host is counted as not responding if Fleet hasn\'t received a distributed write to requested distibuted queries for the host during the 2-hour interval since the host was last seen. Hosts that have not been seen for 7 days or more are not counted.', },
organization: { required: true, type: 'string' },
mdmMacOsEnabled: {required: true, type: 'boolean'},
mdmWindowsEnabled: {required: true, type: 'boolean'},
liveQueryDisabled: {required: true, type: 'boolean'},
hostExpiryEnabled: {required: true, type: 'boolean'},
numSoftwareVersions: {required: true, type: 'number'},
numHostSoftwares: {required: true, type: 'number'},
numSoftwareTitles: {required: true, type: 'number'},
numHostSoftwareInstalledPaths: {required: true, type: 'number'},
numSoftwareCPEs: {required: true, type: 'number'},
numSoftwareCVEs: {required: true, type: 'number'},
// ╔═╗╔╦╗╔╗ ╔═╗╔╦╗╔═╗
// ║╣ ║║║╠╩╗║╣ ║║╚═╗
// ╚═╝╩ ╩╚═╝╚═╝═╩╝╚═╝
// ╔═╗╔═╗╔═╗╔═╗╔═╗╦╔═╗╔╦╗╦╔═╗╔╗╔╔═╗
// ╠═╣╚═╗╚═╗║ ║║ ║╠═╣ ║ ║║ ║║║║╚═╗
// ╩ ╩╚═╝╚═╝╚═╝╚═╝╩╩ ╩ ╩ ╩╚═╝╝╚╝╚═╝
},
};