fleet/website/api/models/HistoricalUsageSnapshot.js
Eric f14ab358fe
2023-11-21 Website: Add new usage statistics (#15263)
Closes: #15255

Changes:
- Added the usage statistics added in
https://github.com/fleetdm/fleet/pull/14216 to the inputs of the
`receive-usage-analytics` webhook.
- Updated the `receive-usage-analytics` webhook to send the new usage
statistics to Datadog.
- Added attributes for the new usage statistics to the
`HistoricalUsageSnapshot` model.
- Removed the `columnName` from the `hostsStatusWebHookEnabled`
attribute of the `HistoricalUsageSnapshot` model, the name of this
column will be changed in the database when the new columns are added to
the databse table.
- Updated the usage statistics documentation to have the new statistics.


This PR requires database migrations. When this is approved and ready to
merge, we will need to:
- [ ] Merge this PR
- [ ] Put fleetdm.com into maintenance mode while the "Deploy Fleet
website" GH action runs.
- [ ] Add the new columns to the database table
- [ ] Change the name of the `hostStatusWebhookEnabled` column to
`hostsStatusWebHookEnabled`
- [ ] Set the default values for the new columns on the existing
records.
- [ ] When the website has finished redeploying, take it out of
maintenance mode.
2023-12-01 17:59:41 -06:00

52 lines
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'},
// ╔═╗╔╦╗╔╗ ╔═╗╔╦╗╔═╗
// ║╣ ║║║╠╩╗║╣ ║║╚═╗
// ╚═╝╩ ╩╚═╝╚═╝═╩╝╚═╝
// ╔═╗╔═╗╔═╗╔═╗╔═╗╦╔═╗╔╦╗╦╔═╗╔╗╔╔═╗
// ╠═╣╚═╗╚═╗║ ║║ ║╠═╣ ║ ║║ ║║║║╚═╗
// ╩ ╩╚═╝╚═╝╚═╝╚═╝╩╩ ╩ ╩ ╩╚═╝╝╚╝╚═╝
},
};