@oneuptime/common 14.0.92 → 14.0.93

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/Models/DatabaseModels/Alert.js +8 -1
  2. package/Models/DatabaseModels/AlertEpisodeMember.d.mts +1 -0
  3. package/Models/DatabaseModels/AlertEpisodeMember.d.ts +1 -0
  4. package/Models/DatabaseModels/AlertEpisodeMember.js +50 -0
  5. package/Models/DatabaseModels/IncidentEpisodeMember.d.mts +1 -0
  6. package/Models/DatabaseModels/IncidentEpisodeMember.d.ts +1 -0
  7. package/Models/DatabaseModels/IncidentEpisodeMember.js +50 -0
  8. package/Models/DatabaseModels/IncomingCallPolicy.js +1 -1
  9. package/Models/DatabaseModels/LlmProvider.js +1 -1
  10. package/Models/DatabaseModels/MonitorTemplate.js +10 -4
  11. package/Models/DatabaseModels/NetworkDeviceDiscoveryScan.js +13 -13
  12. package/Models/DatabaseModels/OnCallDutyPolicy.js +1 -1
  13. package/Models/DatabaseModels/ScheduledMaintenanceReminderRule.js +1 -1
  14. package/Models/DatabaseModels/StatusPage.d.mts +2 -0
  15. package/Models/DatabaseModels/StatusPage.d.ts +2 -0
  16. package/Models/DatabaseModels/StatusPage.js +100 -0
  17. package/Types/Database/BlankColumnValue.d.mts +6 -0
  18. package/Types/Database/BlankColumnValue.d.ts +6 -0
  19. package/Types/Database/BlankColumnValue.js +77 -0
  20. package/Types/Database/BlankColumnValue.mjs +4 -0
  21. package/Types/Email/EmailTemplateType.d.mts +1 -0
  22. package/Types/Email/EmailTemplateType.d.ts +1 -0
  23. package/Types/Email/EmailTemplateType.js +1 -0
  24. package/Types/IncomingCall/IncomingCallPolicyRepeat.d.mts +6 -0
  25. package/Types/IncomingCall/IncomingCallPolicyRepeat.d.ts +6 -0
  26. package/Types/IncomingCall/IncomingCallPolicyRepeat.js +41 -14
  27. package/Types/IncomingCall/IncomingCallPolicyRepeat.mjs +3 -0
  28. package/Types/Monitor/CriteriaFilter.d.mts +1 -0
  29. package/Types/Monitor/CriteriaFilter.d.ts +1 -0
  30. package/Types/Monitor/CriteriaFilter.js +9 -0
  31. package/Types/Monitor/DatabaseMetricCatalog.js +2 -2
  32. package/Types/Monitor/KubernetesEventAlertTemplates.d.mts +20 -0
  33. package/Types/Monitor/KubernetesEventAlertTemplates.d.ts +20 -0
  34. package/Types/Monitor/KubernetesEventAlertTemplates.js +232 -0
  35. package/Types/Monitor/KubernetesEventAlertTemplates.mjs +8 -0
  36. package/Types/Monitor/MonitorType.js +12 -2
  37. package/Types/Monitor/Recommendation/MonitorRecommendationCatalog.js +27 -2
  38. package/Types/Monitor/Recommendation/MonitorRecommendationUtil.d.mts +1 -0
  39. package/Types/Monitor/Recommendation/MonitorRecommendationUtil.d.ts +1 -0
  40. package/Types/Monitor/Recommendation/MonitorRecommendationUtil.js +31 -1
  41. package/Types/Monitor/SnmpMonitor/NetworkDeviceAlertPack.d.mts +3 -1
  42. package/Types/Monitor/SnmpMonitor/NetworkDeviceAlertPack.d.ts +3 -1
  43. package/Types/Monitor/SnmpMonitor/NetworkDeviceAlertPack.js +3 -2
  44. package/Types/Monitor/SnmpMonitor/SnmpMonitorResponse.d.mts +1 -0
  45. package/Types/Monitor/SnmpMonitor/SnmpMonitorResponse.d.ts +1 -0
  46. package/Types/NotificationSetting/NotificationEmailRollupCategory.js +2 -0
  47. package/Types/NotificationSetting/NotificationEmailRollupPolicy.js +10 -3
  48. package/Types/NotificationSetting/NotificationSettingEventType.d.mts +1 -0
  49. package/Types/NotificationSetting/NotificationSettingEventType.d.ts +1 -0
  50. package/Types/NotificationSetting/NotificationSettingEventType.js +7 -0
  51. package/Types/OnCallDutyPolicy/OnCallDutyPolicyRepeat.d.mts +7 -0
  52. package/Types/OnCallDutyPolicy/OnCallDutyPolicyRepeat.d.ts +7 -0
  53. package/Types/OnCallDutyPolicy/OnCallDutyPolicyRepeat.js +51 -0
  54. package/Types/OnCallDutyPolicy/OnCallDutyPolicyRepeat.mjs +4 -0
  55. package/Types/Reminder/ScheduledMaintenanceReminderNeverReminds.d.mts +8 -0
  56. package/Types/Reminder/ScheduledMaintenanceReminderNeverReminds.d.ts +8 -0
  57. package/Types/Reminder/ScheduledMaintenanceReminderNeverReminds.js +55 -0
  58. package/Types/Reminder/ScheduledMaintenanceReminderNeverReminds.mjs +5 -0
  59. package/Types/Workflow/Templates.js +2 -5
  60. package/Utils/ColorContrast.d.mts +3 -0
  61. package/Utils/ColorContrast.d.ts +3 -0
  62. package/Utils/ColorContrast.js +41 -3
  63. package/Utils/ColorContrast.mjs +2 -0
  64. package/Utils/Incident/WhoOpenedItRootCause.d.mts +2 -0
  65. package/Utils/Incident/WhoOpenedItRootCause.d.ts +2 -0
  66. package/Utils/Incident/WhoOpenedItRootCause.js +50 -0
  67. package/Utils/Incident/WhoOpenedItRootCause.mjs +3 -0
  68. package/Utils/Monitor/SyntheticMonitorStepsUtil.d.mts +18 -0
  69. package/Utils/Monitor/SyntheticMonitorStepsUtil.d.ts +18 -0
  70. package/Utils/Monitor/SyntheticMonitorStepsUtil.js +129 -0
  71. package/Utils/Monitor/SyntheticMonitorStepsUtil.mjs +4 -0
  72. package/Utils/Rules/RuleRunSummary.d.mts +1 -0
  73. package/Utils/Rules/RuleRunSummary.d.ts +1 -0
  74. package/Utils/Rules/RuleRunSummary.js +19 -1
  75. package/Utils/Rules/RuleRunSummary.mjs +1 -0
  76. package/Utils/Sms/Gsm7Text.js +9 -1
  77. package/Utils/Sms/OnCallPageSms.d.mts +2 -0
  78. package/Utils/Sms/OnCallPageSms.d.ts +2 -0
  79. package/Utils/Sms/OnCallPageSms.js +19 -2
  80. package/Utils/Sms/OnCallPageSms.mjs +1 -0
  81. package/Utils/Sms/SubscriberSms.d.mts +2 -0
  82. package/Utils/Sms/SubscriberSms.d.ts +2 -0
  83. package/Utils/Sms/SubscriberSms.js +35 -0
  84. package/Utils/Sms/SubscriberSms.mjs +3 -0
  85. package/package.json +1 -1
@@ -1,20 +1,9 @@
1
1
  "use strict";
2
- /*
3
- * How many more times an incoming call policy rings its escalation rules
4
- * from the first one, after the last one rang and nobody answered.
5
- *
6
- * A policy stores it in two columns: repeatPolicyIfNoOneAnswers (the switch)
7
- * and repeatPolicyIfNoOneAnswersTimes (how many times). The call handler
8
- * (Notification/API/IncomingCall: dial-status) starts the rules again while
9
- * the call's repeatCount is below this, and the policy's Settings page says
10
- * the same in words (its "Repeat Policy" card). So both read it here.
11
- *
12
- * Unlike an on-call policy's repeats (OnCallDutyPolicyRepeat), a number left
13
- * at 0, or never set, counts as 1 while the switch is on: the call handler
14
- * has always read `times || 1`. A negative number never repeats.
15
- */
16
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.INCOMING_CALL_POLICY_REPEAT_TIMES_REFUSAL = exports.INCOMING_CALL_POLICY_REPEAT_COLUMNS = void 0;
17
4
  exports.getIncomingCallPolicyRepeatsAllowed = getIncomingCallPolicyRepeatsAllowed;
5
+ exports.getIncomingCallPolicyRepeatRefusal = getIncomingCallPolicyRepeatRefusal;
6
+ const OnCallDutyPolicyRepeat_1 = require("../OnCallDutyPolicy/OnCallDutyPolicyRepeat");
18
7
  /*
19
8
  * The number of times the rules start again from the first: 0 while the
20
9
  * switch is off, otherwise the number - 1 when it is 0 or not set.
@@ -37,3 +26,41 @@ function getIncomingCallPolicyRepeatsAllowed(policy) {
37
26
  */
38
27
  return Math.ceil(times);
39
28
  }
29
+ /*
30
+ * A POLICY THAT SAYS IT RINGS AGAIN SAYS HOW MANY TIMES: 1 OR MORE.
31
+ *
32
+ * The call handler reads the switch on with 0 as "ring again once" (above),
33
+ * a quirk kept for the policies stored that way. The Dashboard's Repeat
34
+ * Policy card never makes it - its "How many more times?" box takes a whole
35
+ * number of 1 or more - and the server holds the API, Terraform, MCP and
36
+ * workflows to the same (IncomingCallPolicyService, through
37
+ * Server/Utils/Database/ColumnRuleCheck): 0, a negative number or a part of
38
+ * one is refused while the switch is on. A policy stored that way before
39
+ * keeps ringing as it did, and an edit that leaves the pair as it is still
40
+ * saves.
41
+ *
42
+ * A number not given is the column's default, 1: turning the switch on
43
+ * alone rings again once, as it always did.
44
+ */
45
+ exports.INCOMING_CALL_POLICY_REPEAT_COLUMNS = [
46
+ "repeatPolicyIfNoOneAnswers",
47
+ "repeatPolicyIfNoOneAnswersTimes",
48
+ ];
49
+ exports.INCOMING_CALL_POLICY_REPEAT_TIMES_REFUSAL = "An incoming call policy that repeats must ring again at least once: set Repeat Policy Times to a whole number of 1 or more, or turn off Repeat Policy If No One Answers.";
50
+ /*
51
+ * The refusal for a pair that says it rings again without a whole number of
52
+ * times of 1 or more, or null: the switch off, on with the number not given,
53
+ * or on with 1 or more.
54
+ */
55
+ function getIncomingCallPolicyRepeatRefusal(policy) {
56
+ if (policy.repeatPolicyIfNoOneAnswers !== true) {
57
+ return null;
58
+ }
59
+ // Not given: the column's default, 1.
60
+ if (policy.repeatPolicyIfNoOneAnswersTimes === undefined) {
61
+ return null;
62
+ }
63
+ return (0, OnCallDutyPolicyRepeat_1.isRepeatCountOfAtLeastOne)(policy.repeatPolicyIfNoOneAnswersTimes)
64
+ ? null
65
+ : exports.INCOMING_CALL_POLICY_REPEAT_TIMES_REFUSAL;
66
+ }
@@ -1,2 +1,5 @@
1
1
  import commonJsModule from "./IncomingCallPolicyRepeat.js";
2
+ export const INCOMING_CALL_POLICY_REPEAT_COLUMNS = commonJsModule.INCOMING_CALL_POLICY_REPEAT_COLUMNS;
3
+ export const INCOMING_CALL_POLICY_REPEAT_TIMES_REFUSAL = commonJsModule.INCOMING_CALL_POLICY_REPEAT_TIMES_REFUSAL;
4
+ export const getIncomingCallPolicyRepeatRefusal = commonJsModule.getIncomingCallPolicyRepeatRefusal;
2
5
  export const getIncomingCallPolicyRepeatsAllowed = commonJsModule.getIncomingCallPolicyRepeatsAllowed;
@@ -58,6 +58,7 @@ export declare enum CheckOn {
58
58
  EmailReceivedAt = "Email Received",
59
59
  SnmpOidValue = "SNMP OID Value",
60
60
  SnmpOidExists = "SNMP OID Exists",
61
+ SnmpOidRatePerSecond = "SNMP OID Rate (per second)",
61
62
  SnmpResponseTime = "SNMP Response Time (in ms)",
62
63
  SnmpIsOnline = "SNMP Device Is Online",
63
64
  SnmpWalkIsSucceeding = "SNMP Walk Is Succeeding",
@@ -58,6 +58,7 @@ export declare enum CheckOn {
58
58
  EmailReceivedAt = "Email Received",
59
59
  SnmpOidValue = "SNMP OID Value",
60
60
  SnmpOidExists = "SNMP OID Exists",
61
+ SnmpOidRatePerSecond = "SNMP OID Rate (per second)",
61
62
  SnmpResponseTime = "SNMP Response Time (in ms)",
62
63
  SnmpIsOnline = "SNMP Device Is Online",
63
64
  SnmpWalkIsSucceeding = "SNMP Walk Is Succeeding",
@@ -83,6 +83,15 @@ var CheckOn;
83
83
  // SNMP monitors.
84
84
  CheckOn["SnmpOidValue"] = "SNMP OID Value";
85
85
  CheckOn["SnmpOidExists"] = "SNMP OID Exists";
86
+ /*
87
+ * How fast a counter OID (Counter32, Counter64) grew, per second, between
88
+ * the device's last two polls that read it. A counter only ever grows
89
+ * until it wraps or the device restarts, so its value against a threshold
90
+ * stays crossed once crossed: its rate is what says how busy, how lossy
91
+ * or how full of errors something is now. Not evaluated until the device
92
+ * has been polled twice, nor on a poll whose counter went backwards.
93
+ */
94
+ CheckOn["SnmpOidRatePerSecond"] = "SNMP OID Rate (per second)";
86
95
  CheckOn["SnmpResponseTime"] = "SNMP Response Time (in ms)";
87
96
  /*
88
97
  * Device reachability: true when the device answered ping OR its SNMP
@@ -206,7 +206,7 @@ const databaseMetricCatalog = [
206
206
  id: "database-rollback-percent",
207
207
  metricType: MonitorMetricType_1.default.DatabaseRollbackPercent,
208
208
  friendlyName: "Rollback Ratio",
209
- description: "Share of transactions that rolled back rather than committed. A step change usually means the application started throwing where it used to succeed.",
209
+ description: "Share of transactions since the previous check that rolled back rather than committed. A step change usually means the application started throwing where it used to succeed.",
210
210
  category: DatabaseMetricCategory.Throughput,
211
211
  group: DatabaseMetricGroup.Throughput,
212
212
  defaultAggregation: AggregationType_1.default.Avg,
@@ -296,7 +296,7 @@ const databaseMetricCatalog = [
296
296
  id: "database-cache-hit-percent",
297
297
  metricType: MonitorMetricType_1.default.DatabaseCacheHitPercent,
298
298
  friendlyName: "Cache Hit Ratio",
299
- description: "Share of block reads served from the buffer cache instead of disk. A sustained fall means the working set no longer fits in memory.",
299
+ description: "Share of block reads since the previous check served from the buffer cache instead of disk. A sustained fall means the working set no longer fits in memory.",
300
300
  category: DatabaseMetricCategory.CacheAndIo,
301
301
  group: DatabaseMetricGroup.Throughput,
302
302
  defaultAggregation: AggregationType_1.default.Avg,
@@ -0,0 +1,20 @@
1
+ import MonitorStep from "./MonitorStep.mjs";
2
+ import MonitorStepLogMonitor from "./MonitorStepLogMonitor.mjs";
3
+ import { KubernetesAlertTemplateArgs } from "./KubernetesAlertTemplates.mjs";
4
+ export declare const KUBERNETES_WARNING_EVENTS_TEMPLATE_ID: string;
5
+ export declare const KUBERNETES_CLUSTER_NAME_LOG_ATTRIBUTE: string;
6
+ export declare const KUBERNETES_WARNING_EVENTS_WINDOW_SECONDS: number;
7
+ export declare const KUBERNETES_WARNING_EVENTS_GROUP_BY: Array<string>;
8
+ export type KubernetesEventAlertTemplateCategory = "Events";
9
+ export interface KubernetesEventAlertTemplate {
10
+ id: string;
11
+ name: string;
12
+ summary: string;
13
+ description: string;
14
+ category: KubernetesEventAlertTemplateCategory;
15
+ severity: "Critical" | "Warning";
16
+ getMonitorStep: (args: KubernetesAlertTemplateArgs) => MonitorStep;
17
+ }
18
+ export declare function buildKubernetesWarningEventsLogMonitor(clusterIdentifier: string): MonitorStepLogMonitor;
19
+ export declare function getAllKubernetesEventAlertTemplates(): Array<KubernetesEventAlertTemplate>;
20
+ export declare function getKubernetesWarningEventsTemplate(): KubernetesEventAlertTemplate;
@@ -0,0 +1,20 @@
1
+ import MonitorStep from "./MonitorStep";
2
+ import MonitorStepLogMonitor from "./MonitorStepLogMonitor";
3
+ import { KubernetesAlertTemplateArgs } from "./KubernetesAlertTemplates";
4
+ export declare const KUBERNETES_WARNING_EVENTS_TEMPLATE_ID: string;
5
+ export declare const KUBERNETES_CLUSTER_NAME_LOG_ATTRIBUTE: string;
6
+ export declare const KUBERNETES_WARNING_EVENTS_WINDOW_SECONDS: number;
7
+ export declare const KUBERNETES_WARNING_EVENTS_GROUP_BY: Array<string>;
8
+ export type KubernetesEventAlertTemplateCategory = "Events";
9
+ export interface KubernetesEventAlertTemplate {
10
+ id: string;
11
+ name: string;
12
+ summary: string;
13
+ description: string;
14
+ category: KubernetesEventAlertTemplateCategory;
15
+ severity: "Critical" | "Warning";
16
+ getMonitorStep: (args: KubernetesAlertTemplateArgs) => MonitorStep;
17
+ }
18
+ export declare function buildKubernetesWarningEventsLogMonitor(clusterIdentifier: string): MonitorStepLogMonitor;
19
+ export declare function getAllKubernetesEventAlertTemplates(): Array<KubernetesEventAlertTemplate>;
20
+ export declare function getKubernetesWarningEventsTemplate(): KubernetesEventAlertTemplate;
@@ -0,0 +1,232 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.KUBERNETES_WARNING_EVENTS_GROUP_BY = exports.KUBERNETES_WARNING_EVENTS_WINDOW_SECONDS = exports.KUBERNETES_CLUSTER_NAME_LOG_ATTRIBUTE = exports.KUBERNETES_WARNING_EVENTS_TEMPLATE_ID = void 0;
40
+ exports.buildKubernetesWarningEventsLogMonitor = buildKubernetesWarningEventsLogMonitor;
41
+ exports.getAllKubernetesEventAlertTemplates = getAllKubernetesEventAlertTemplates;
42
+ exports.getKubernetesWarningEventsTemplate = getKubernetesWarningEventsTemplate;
43
+ const ObjectID_1 = __importDefault(require("../ObjectID"));
44
+ const FilterCondition_1 = __importDefault(require("../Filter/FilterCondition"));
45
+ const KubernetesEvent_1 = __importStar(require("../Kubernetes/KubernetesEvent"));
46
+ const CriteriaFilter_1 = require("./CriteriaFilter");
47
+ const MonitorCriteria_1 = __importDefault(require("./MonitorCriteria"));
48
+ const MonitorCriteriaInstance_1 = __importDefault(require("./MonitorCriteriaInstance"));
49
+ const MonitorStep_1 = __importDefault(require("./MonitorStep"));
50
+ /*
51
+ * THE KUBERNETES WARNING EVENTS ALERT.
52
+ *
53
+ * Issue #5179 found where a cluster's warning events - kernel-monitor's
54
+ * OOMKilling on a node, an HPA's FailedGetResourceMetric - were lost, and
55
+ * put them on the cluster's Events page. Being told when one happens took a
56
+ * Logs monitor built by hand from a recipe in the docs (#5201's follow-up:
57
+ * "a built-in monitor template"). This is that monitor, offered on every
58
+ * cluster's Recommendations page and from its Events page.
59
+ *
60
+ * Kubernetes events are logs, stamped by ingest with what each one says
61
+ * (KubernetesEvent.ts), so the template is a Logs monitor - not a
62
+ * Kubernetes monitor, which reads metrics, and not one of
63
+ * KubernetesAlertTemplates, which the Kubernetes monitor's Quick Setup
64
+ * builds Kubernetes steps from:
65
+ *
66
+ * - the cluster's Warning events: its records (event.domain k8s,
67
+ * k8s.resource.name events), of this cluster (resource.k8s.cluster.name),
68
+ * of type Warning (k8s.event.type);
69
+ * - grouped by namespace, kind, object and reason, so every object that
70
+ * warns raises its own alert - an OOM kill on one node never hides behind
71
+ * another node's - and each says what and where;
72
+ * - over the last five minutes: a warning opens its alert at the next
73
+ * check, a repeating one (FailedGetResourceMetric, every 15 seconds while
74
+ * the HPA cannot read its metric) keeps it open, and five quiet minutes
75
+ * resolve it. A record Kubernetes sends when it deletes an Event an hour
76
+ * later is dated when the Event last happened, so it never reopens one.
77
+ *
78
+ * These attribute keys are stored in customers' logs and monitors: never
79
+ * rename one.
80
+ */
81
+ exports.KUBERNETES_WARNING_EVENTS_TEMPLATE_ID = "k8s-warning-events";
82
+ // The resource attribute every record of a cluster's agent carries.
83
+ exports.KUBERNETES_CLUSTER_NAME_LOG_ATTRIBUTE = "resource.k8s.cluster.name";
84
+ // How far back each check looks: a warning stays open while it repeats.
85
+ exports.KUBERNETES_WARNING_EVENTS_WINDOW_SECONDS = 300;
86
+ // One alert per object and reason that warns.
87
+ exports.KUBERNETES_WARNING_EVENTS_GROUP_BY = [
88
+ KubernetesEvent_1.default.Namespace,
89
+ KubernetesEvent_1.default.ObjectKind,
90
+ KubernetesEvent_1.default.ObjectName,
91
+ KubernetesEvent_1.default.Reason,
92
+ ];
93
+ // The Logs monitor's query: this cluster's Warning events, grouped.
94
+ function buildKubernetesWarningEventsLogMonitor(clusterIdentifier) {
95
+ return {
96
+ attributes: {
97
+ [KubernetesEvent_1.default.Domain]: KubernetesEvent_1.KUBERNETES_EVENT_DOMAIN,
98
+ [KubernetesEvent_1.default.ResourceName]: KubernetesEvent_1.KUBERNETES_EVENTS_RESOURCE_NAME,
99
+ [exports.KUBERNETES_CLUSTER_NAME_LOG_ATTRIBUTE]: clusterIdentifier,
100
+ [KubernetesEvent_1.default.Type]: KubernetesEvent_1.KubernetesEventType.Warning,
101
+ },
102
+ body: "",
103
+ severityTexts: [],
104
+ telemetryServiceIds: [],
105
+ lastXSecondsOfLogs: exports.KUBERNETES_WARNING_EVENTS_WINDOW_SECONDS,
106
+ groupByAttributes: [...exports.KUBERNETES_WARNING_EVENTS_GROUP_BY],
107
+ };
108
+ }
109
+ function buildWarningEventsCriteria(args) {
110
+ const unhealthy = new MonitorCriteriaInstance_1.default();
111
+ const title = `[K8s] Warning Event - ${args.monitorName}`;
112
+ /*
113
+ * The group - namespace, kind, object and reason - is the alert's series
114
+ * and is named under its title (SeriesContextEnricher); the message is on
115
+ * the cluster's Events page, and in the root cause.
116
+ */
117
+ const description = `Kubernetes reported a warning event on ${args.monitorName}. It names the object and the reason; the message is in the root cause and on the cluster's Events page.`;
118
+ unhealthy.data = {
119
+ id: ObjectID_1.default.generate().toString(),
120
+ monitorStatusId: args.offlineMonitorStatusId,
121
+ filterCondition: FilterCondition_1.default.Any,
122
+ filters: [
123
+ {
124
+ checkOn: CriteriaFilter_1.CheckOn.LogCount,
125
+ filterType: CriteriaFilter_1.FilterType.GreaterThan,
126
+ value: 0,
127
+ },
128
+ ],
129
+ incidents: [
130
+ {
131
+ title: title,
132
+ description: description,
133
+ incidentSeverityId: args.defaultIncidentSeverityId,
134
+ autoResolveIncident: true,
135
+ id: ObjectID_1.default.generate().toString(),
136
+ onCallPolicyIds: [],
137
+ },
138
+ ],
139
+ alerts: [
140
+ {
141
+ title: title,
142
+ description: description,
143
+ alertSeverityId: args.defaultAlertSeverityId,
144
+ autoResolveAlert: true,
145
+ id: ObjectID_1.default.generate().toString(),
146
+ onCallPolicyIds: [],
147
+ },
148
+ ],
149
+ changeMonitorStatus: true,
150
+ /*
151
+ * Both, as every template ships: the create form's Alert / Incident /
152
+ * Both choice (an alert unless someone picks otherwise) decides which
153
+ * of the two a monitor made from it raises (MonitorRecommendationUtil).
154
+ */
155
+ createIncidents: true,
156
+ createAlerts: true,
157
+ name: `${args.monitorName} - Warning event reported`,
158
+ description: "Kubernetes reported a warning event in the last 5 minutes.",
159
+ };
160
+ const healthy = new MonitorCriteriaInstance_1.default();
161
+ healthy.data = {
162
+ id: ObjectID_1.default.generate().toString(),
163
+ monitorStatusId: args.onlineMonitorStatusId,
164
+ filterCondition: FilterCondition_1.default.Any,
165
+ filters: [
166
+ {
167
+ checkOn: CriteriaFilter_1.CheckOn.LogCount,
168
+ filterType: CriteriaFilter_1.FilterType.EqualTo,
169
+ value: 0,
170
+ },
171
+ ],
172
+ incidents: [],
173
+ alerts: [],
174
+ changeMonitorStatus: true,
175
+ createIncidents: false,
176
+ createAlerts: false,
177
+ name: "Healthy",
178
+ description: "No warning event in the last 5 minutes.",
179
+ };
180
+ const criteria = new MonitorCriteria_1.default();
181
+ criteria.data = {
182
+ monitorCriteriaInstanceArray: [unhealthy, healthy],
183
+ };
184
+ return criteria;
185
+ }
186
+ const warningEventsTemplate = {
187
+ id: exports.KUBERNETES_WARNING_EVENTS_TEMPLATE_ID,
188
+ name: "Warning Events",
189
+ summary: "Kubernetes reports a warning event: one alert per object and reason.",
190
+ /*
191
+ * No backticks: the description is drawn as plain text on the
192
+ * recommendation card.
193
+ */
194
+ description: "Alert when Kubernetes reports a Warning event about the cluster - an OOMKilling on a node, a BackOff on a pod, a FailedMount on a volume, a FailedGetResourceMetric on an HPA. Each object and reason raises its own alert, which resolves after 5 minutes without a new warning about it. It is a Logs monitor over the events the Kubernetes agent sends: edit its filter to watch only some reasons.",
195
+ category: "Events",
196
+ severity: "Warning",
197
+ getMonitorStep: (args) => {
198
+ const monitorStep = new MonitorStep_1.default();
199
+ monitorStep.data = {
200
+ id: ObjectID_1.default.generate().toString(),
201
+ monitorDestination: undefined,
202
+ doNotFollowRedirects: undefined,
203
+ monitorDestinationPort: undefined,
204
+ monitorCriteria: buildWarningEventsCriteria(args),
205
+ requestType: "GET",
206
+ requestHeaders: undefined,
207
+ requestBody: undefined,
208
+ customCode: undefined,
209
+ screenSizeTypes: undefined,
210
+ browserTypes: undefined,
211
+ retryCountOnError: undefined,
212
+ logMonitor: buildKubernetesWarningEventsLogMonitor(args.clusterIdentifier),
213
+ traceMonitor: undefined,
214
+ metricMonitor: undefined,
215
+ exceptionMonitor: undefined,
216
+ snmpMonitor: undefined,
217
+ dnsMonitor: undefined,
218
+ domainMonitor: undefined,
219
+ externalStatusPageMonitor: undefined,
220
+ kubernetesMonitor: undefined,
221
+ };
222
+ return monitorStep;
223
+ },
224
+ };
225
+ // Every Kubernetes alert built on the cluster's events, not its metrics.
226
+ function getAllKubernetesEventAlertTemplates() {
227
+ return [warningEventsTemplate];
228
+ }
229
+ // The Warning Events template.
230
+ function getKubernetesWarningEventsTemplate() {
231
+ return warningEventsTemplate;
232
+ }
@@ -0,0 +1,8 @@
1
+ import commonJsModule from "./KubernetesEventAlertTemplates.js";
2
+ export const KUBERNETES_CLUSTER_NAME_LOG_ATTRIBUTE = commonJsModule.KUBERNETES_CLUSTER_NAME_LOG_ATTRIBUTE;
3
+ export const KUBERNETES_WARNING_EVENTS_GROUP_BY = commonJsModule.KUBERNETES_WARNING_EVENTS_GROUP_BY;
4
+ export const KUBERNETES_WARNING_EVENTS_TEMPLATE_ID = commonJsModule.KUBERNETES_WARNING_EVENTS_TEMPLATE_ID;
5
+ export const KUBERNETES_WARNING_EVENTS_WINDOW_SECONDS = commonJsModule.KUBERNETES_WARNING_EVENTS_WINDOW_SECONDS;
6
+ export const buildKubernetesWarningEventsLogMonitor = commonJsModule.buildKubernetesWarningEventsLogMonitor;
7
+ export const getAllKubernetesEventAlertTemplates = commonJsModule.getAllKubernetesEventAlertTemplates;
8
+ export const getKubernetesWarningEventsTemplate = commonJsModule.getKubernetesWarningEventsTemplate;
@@ -755,7 +755,13 @@ class MonitorTypeHelper {
755
755
  {
756
756
  monitorType: MonitorType.Traces,
757
757
  title: "Traces",
758
- description: "Alert on span latency and error rate from any source.",
758
+ /*
759
+ * A Traces monitor counts the spans that match its filters (its one
760
+ * criteria is Span Count): it cannot read a span's duration, so its
761
+ * card promises no latency. Latency is alerted on through a Metrics
762
+ * monitor on a request duration metric, which answers "latency".
763
+ */
764
+ description: "Alert on the number of matching spans, like failed requests, from any source.",
759
765
  icon: IconProp_1.default.Waterfall,
760
766
  keywords: [
761
767
  "trace",
@@ -764,7 +770,9 @@ class MonitorTypeHelper {
764
770
  "opentelemetry",
765
771
  "distributed tracing",
766
772
  "apm",
767
- "latency",
773
+ "span count",
774
+ "failed requests",
775
+ "error spans",
768
776
  ],
769
777
  },
770
778
  {
@@ -781,6 +789,8 @@ class MonitorTypeHelper {
781
789
  "histogram",
782
790
  "timeseries",
783
791
  "prometheus",
792
+ "latency",
793
+ "request duration",
784
794
  ],
785
795
  },
786
796
  {
@@ -14,6 +14,7 @@ const DockerSwarmAlertTemplates_1 = require("../DockerSwarmAlertTemplates");
14
14
  const HostAlertTemplates_1 = require("../HostAlertTemplates");
15
15
  const IotAlertTemplates_1 = require("../IotAlertTemplates");
16
16
  const KubernetesAlertTemplates_1 = require("../KubernetesAlertTemplates");
17
+ const KubernetesEventAlertTemplates_1 = require("../KubernetesEventAlertTemplates");
17
18
  const PodmanAlertTemplates_1 = require("../PodmanAlertTemplates");
18
19
  const ProxmoxAlertTemplates_1 = require("../ProxmoxAlertTemplates");
19
20
  const RumAlertTemplates_1 = require("../RumAlertTemplates");
@@ -44,7 +45,7 @@ function normalize(data) {
44
45
  * `any` and would not catch a renamed field.
45
46
  */
46
47
  function getKubernetesRecommendations() {
47
- return (0, KubernetesAlertTemplates_1.getAllKubernetesAlertTemplates)().map((template) => {
48
+ const metricRecommendations = (0, KubernetesAlertTemplates_1.getAllKubernetesAlertTemplates)().map((template) => {
48
49
  return normalize({
49
50
  resourceType: MonitorRecommendationTypes_1.MonitorRecommendationResourceType.Kubernetes,
50
51
  monitorType: MonitorType_1.default.Kubernetes,
@@ -61,6 +62,29 @@ function getKubernetesRecommendations() {
61
62
  },
62
63
  });
63
64
  });
65
+ /*
66
+ * A cluster's warning events are logs (KubernetesEventAlertTemplates), so
67
+ * their alert is a Logs monitor scoped to the cluster - offered beside the
68
+ * metric templates, last, under its own Events heading.
69
+ */
70
+ const eventRecommendations = (0, KubernetesEventAlertTemplates_1.getAllKubernetesEventAlertTemplates)().map((template) => {
71
+ return normalize({
72
+ resourceType: MonitorRecommendationTypes_1.MonitorRecommendationResourceType.Kubernetes,
73
+ monitorType: MonitorType_1.default.Logs,
74
+ template: template,
75
+ getMonitorStep: (args) => {
76
+ return template.getMonitorStep({
77
+ clusterIdentifier: args.resourceIdentifier,
78
+ onlineMonitorStatusId: args.onlineMonitorStatusId,
79
+ offlineMonitorStatusId: args.offlineMonitorStatusId,
80
+ defaultIncidentSeverityId: args.defaultIncidentSeverityId,
81
+ defaultAlertSeverityId: args.defaultAlertSeverityId,
82
+ monitorName: args.monitorName,
83
+ });
84
+ },
85
+ });
86
+ });
87
+ return [...metricRecommendations, ...eventRecommendations];
64
88
  }
65
89
  function getHostRecommendations() {
66
90
  return (0, HostAlertTemplates_1.getAllHostAlertTemplates)().map((template) => {
@@ -397,7 +421,8 @@ function getAllDatabaseRecommendations() {
397
421
  const RESOURCE_TYPE_DEFINITIONS = [
398
422
  {
399
423
  resourceType: MonitorRecommendationTypes_1.MonitorRecommendationResourceType.Kubernetes,
400
- monitorTypes: [MonitorType_1.default.Kubernetes],
424
+ // Metric templates, and the warning events' Logs monitor.
425
+ monitorTypes: [MonitorType_1.default.Kubernetes, MonitorType_1.default.Logs],
401
426
  resourceLabel: "Kubernetes Cluster",
402
427
  identifierFieldName: "clusterIdentifier",
403
428
  icon: IconProp_1.default.Kubernetes,
@@ -39,6 +39,7 @@ export default class MonitorRecommendationUtil {
39
39
  private static getRecommendationConfigKind;
40
40
  private static getTelemetryResourceIdentifier;
41
41
  private static getAttributeScopedResourceIdentifier;
42
+ private static getLogScopedResourceIdentifier;
42
43
  private static getConfigValues;
43
44
  private static getStableRecordKey;
44
45
  private static getQueryAttributeKey;
@@ -39,6 +39,7 @@ export default class MonitorRecommendationUtil {
39
39
  private static getRecommendationConfigKind;
40
40
  private static getTelemetryResourceIdentifier;
41
41
  private static getAttributeScopedResourceIdentifier;
42
+ private static getLogScopedResourceIdentifier;
42
43
  private static getConfigValues;
43
44
  private static getStableRecordKey;
44
45
  private static getQueryAttributeKey;
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const MonitorStepExceptionMonitor_1 = require("../MonitorStepExceptionMonitor");
7
7
  const MonitorSteps_1 = __importDefault(require("../MonitorSteps"));
8
8
  const DatabaseAlertTemplates_1 = require("../DatabaseAlertTemplates");
9
+ const KubernetesEventAlertTemplates_1 = require("../KubernetesEventAlertTemplates");
9
10
  const MonitorRecommendationSeverityMapper_1 = __importDefault(require("./MonitorRecommendationSeverityMapper"));
10
11
  const MonitorRecommendationTypes_1 = require("./MonitorRecommendationTypes");
11
12
  class MonitorRecommendationUtil {
@@ -207,6 +208,7 @@ class MonitorRecommendationUtil {
207
208
  config.arrayIdentifier ||
208
209
  this.getTelemetryResourceIdentifier(config) ||
209
210
  this.getAttributeScopedResourceIdentifier(config) ||
211
+ this.getLogScopedResourceIdentifier(configKind, config) ||
210
212
  "";
211
213
  const metricNames = [];
212
214
  const metricAliases = [];
@@ -272,6 +274,7 @@ class MonitorRecommendationUtil {
272
274
  "metricMonitor",
273
275
  "traceMonitor",
274
276
  "exceptionMonitor",
277
+ "logMonitor",
275
278
  ];
276
279
  const data = monitorStep.data;
277
280
  return kinds.find((kind) => {
@@ -313,6 +316,21 @@ class MonitorRecommendationUtil {
313
316
  }
314
317
  return Array.from(values).sort().join(",");
315
318
  }
319
+ /*
320
+ * The cluster a Logs step is scoped to by its attribute filter - a
321
+ * Kubernetes cluster's warning events (KubernetesEventAlertTemplates). The
322
+ * whole filter is part of the fingerprint through `configValues` anyway;
323
+ * this makes the step's resource as explicit as a Kubernetes monitor's
324
+ * clusterIdentifier, so "which resource does this monitor watch" has the
325
+ * same answer for both.
326
+ */
327
+ static getLogScopedResourceIdentifier(configKind, config) {
328
+ if (configKind !== "logMonitor") {
329
+ return "";
330
+ }
331
+ const value = (config.attributes || {})[KubernetesEventAlertTemplates_1.KUBERNETES_CLUSTER_NAME_LOG_ATTRIBUTE];
332
+ return typeof value === "string" ? value.trim() : "";
333
+ }
316
334
  /*
317
335
  * Query inputs that do not live in a metric view. They must participate in
318
336
  * coverage identity: an all-span trace monitor does not cover an error-span
@@ -320,7 +338,7 @@ class MonitorRecommendationUtil {
320
338
  * metric scoped to one RUM application.
321
339
  */
322
340
  static getConfigValues(configKind, config) {
323
- var _a, _b, _c;
341
+ var _a, _b, _c, _d;
324
342
  const values = [];
325
343
  if (config.metricViewConfig) {
326
344
  values.push(`rollingTime=${String((_a = config.rollingTime) !== null && _a !== void 0 ? _a : "")}`);
@@ -338,6 +356,18 @@ class MonitorRecommendationUtil {
338
356
  .sort()
339
357
  .join(",")}`, `message=${config.message || ""}`, `entityKeys=${(config.entityKeys || []).slice().sort().join(",")}`, `includeResolved=${String(Boolean(config.includeResolved))}`, `includeArchived=${String(Boolean(config.includeArchived))}`, `lastXSecondsOfExceptions=${String((_c = config.lastXSecondsOfExceptions) !== null && _c !== void 0 ? _c : "")}`);
340
358
  }
359
+ /*
360
+ * Everything a Logs step asks: the logs it counts, over how long, and
361
+ * what it splits them by. A monitor counting every warning of a cluster
362
+ * does not cover one that splits them per object - nor one over another
363
+ * window, nor one resolved by a log.
364
+ */
365
+ if (configKind === "logMonitor") {
366
+ values.push(`attributes=${this.getStableRecordKey(config.attributes || {})}`, `severityTexts=${(config.severityTexts || []).map(String).sort().join(",")}`, `body=${config.body || ""}`, `entityKeys=${(config.entityKeys || []).slice().sort().join(",")}`, `lastXSecondsOfLogs=${String((_d = config.lastXSecondsOfLogs) !== null && _d !== void 0 ? _d : "")}`, `groupByAttributes=${(config.groupByAttributes || [])
367
+ .slice()
368
+ .sort()
369
+ .join(",")}`, `resolvedByAttributes=${this.getStableRecordKey(config.resolvedByAttributes || {})}`);
370
+ }
341
371
  return values;
342
372
  }
343
373
  static getStableRecordKey(record) {
@@ -1,5 +1,5 @@
1
1
  import ObjectID from "../../ObjectID.mjs";
2
- import { CriteriaFilter, FilterType } from "../CriteriaFilter.mjs";
2
+ import { CheckOn, CriteriaFilter, FilterType } from "../CriteriaFilter.mjs";
3
3
  import MonitorCriteriaInstance from "../MonitorCriteriaInstance.mjs";
4
4
  import { SnmpTableDefinition } from "./SnmpTable.mjs";
5
5
  export interface NetworkDeviceAlertPackItem {
@@ -21,6 +21,8 @@ export default class NetworkDeviceAlertPackUtil {
21
21
  name: string;
22
22
  filterType: FilterType;
23
23
  value: string | number | undefined;
24
+ checkOn?: CheckOn.SnmpOidValue | CheckOn.SnmpOidRatePerSecond | undefined;
25
+ description?: string | undefined;
24
26
  }): MonitorCriteriaInstance;
25
27
  static buildCriteriaInstances(context?: NetworkDeviceAlertPackContext): Array<MonitorCriteriaInstance>;
26
28
  }
@@ -1,5 +1,5 @@
1
1
  import ObjectID from "../../ObjectID";
2
- import { CriteriaFilter, FilterType } from "../CriteriaFilter";
2
+ import { CheckOn, CriteriaFilter, FilterType } from "../CriteriaFilter";
3
3
  import MonitorCriteriaInstance from "../MonitorCriteriaInstance";
4
4
  import { SnmpTableDefinition } from "./SnmpTable";
5
5
  export interface NetworkDeviceAlertPackItem {
@@ -21,6 +21,8 @@ export default class NetworkDeviceAlertPackUtil {
21
21
  name: string;
22
22
  filterType: FilterType;
23
23
  value: string | number | undefined;
24
+ checkOn?: CheckOn.SnmpOidValue | CheckOn.SnmpOidRatePerSecond | undefined;
25
+ description?: string | undefined;
24
26
  }): MonitorCriteriaInstance;
25
27
  static buildCriteriaInstances(context?: NetworkDeviceAlertPackContext): Array<MonitorCriteriaInstance>;
26
28
  }
@@ -200,7 +200,7 @@ class NetworkDeviceAlertPackUtil {
200
200
  filterCondition: FilterCondition_1.default.All,
201
201
  filters: [
202
202
  {
203
- checkOn: CriteriaFilter_1.CheckOn.SnmpOidValue,
203
+ checkOn: data.checkOn || CriteriaFilter_1.CheckOn.SnmpOidValue,
204
204
  filterType: data.filterType,
205
205
  value: data.value,
206
206
  snmpMonitorOptions: { oid: oid },
@@ -213,7 +213,8 @@ class NetworkDeviceAlertPackUtil {
213
213
  changeMonitorStatus: false,
214
214
  isEnabled: true,
215
215
  name: data.name,
216
- description: `The value the device reports for ${data.name === oid ? oid : `${data.name} (${oid})`}.`,
216
+ description: data.description ||
217
+ `The value the device reports for ${data.name === oid ? oid : `${data.name} (${oid})`}.`,
217
218
  };
218
219
  return instance;
219
220
  }
@@ -14,6 +14,7 @@ export interface SnmpOidResponse {
14
14
  name?: string | undefined;
15
15
  value: string | number | null;
16
16
  type: SnmpDataType;
17
+ ratePerSecond?: number | undefined;
17
18
  }
18
19
  export default interface SnmpMonitorResponse {
19
20
  isOnline: boolean;