using SQLInsight.Collectors.Concurrency; using SQLInsight.Collectors.Databases; using SQLInsight.Collectors.Instance; using SQLInsight.Collectors.Performance; namespace SQLInsight.Collectors; public static class BuiltInCollectors { /// Community and local rules whose queries are run by the custom-rules collector. /// The customer's settings for collectors that need them; defaults when null. public static IReadOnlyList Create(Core.CustomRules.CustomRuleCatalog? custom = null, CollectorSettings? settings = null) { settings ??= new CollectorSettings(); return [ new ServerCollector(), new ConfigurationCollector(), new TraceFlagCollector(), new InstanceConfigurationCollector(), new PrivilegeCollector(settings.Groups, settings.MaxSysadminAccounts), new DatabaseCollector(), new SuspectPageCollector(), new PlanCacheCollector(), new WaitStatsCollector(), new FileIoCollector(), new QueryStatsCollector(settings.ActivityThresholdPercent), new WaitSamplingCollector(), new LongOperationCollector(), new ErrorLogCollector(settings.LoginFailureBurst), new PerformanceCounterCollector(), new CpuCollector(), new BlockingCollector(), new DeadlockCollector(), new QueryStoreCollector(), new PlanAnalysisCollector(), new IndexCollector(), new AvailabilityGroupCollector(), new AgentJobCollector(), .. custom is null ? Array.Empty() : [new Custom.CustomQueryCollector(custom)], ]; } } /// Settings from the agent's configuration that some collectors need. /// Unfolds Windows groups with server rights to the people in them (Active Directory). /// More people and accounts with sysadmin than this is a finding. /// A statement using more CPU time than this share of its lifetime is a finding. /// Failed logins within one collection (5 minutes) before it is a finding. public sealed record CollectorSettings( Core.Data.IGroupMemberResolver? Groups = null, int MaxSysadminAccounts = 3, double ActivityThresholdPercent = 50, int LoginFailureBurst = 20);