File size: 13,085 Bytes
9373c61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5cfe5c4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
package com.dalab.policyengine.dto;

import java.time.Instant;
import java.util.List;
import java.util.Map;

import com.dalab.policyengine.model.EventSeverity;
import com.dalab.policyengine.model.EventType;

/**

 * DTO for Event Center analytics and metrics dashboard.

 */
public class EventAnalyticsDTO {

    // Summary metrics
    private Long totalEventsToday;
    private Long totalEventsThisWeek;
    private Long totalEventsThisMonth;
    private Long totalActiveSubscriptions;
    private Long totalUsersWithSubscriptions;

    // Event distribution by type
    private List<EventTypeCount> eventsByType;

    // Event distribution by severity
    private List<EventSeverityCount> eventsBySeverity;

    // Event distribution by source service
    private List<SourceServiceCount> eventsBySourceService;

    // Top active subscriptions
    private List<TopSubscription> topActiveSubscriptions;

    // Recent event trends (hourly for last 24 hours)
    private List<EventTrendPoint> recentTrends;

    // Response time metrics
    private ResponseTimeMetrics responseMetrics;

    // Alert statistics
    private AlertStatistics alertStats;

    // Time range for this analytics report
    private Instant fromTime;
    private Instant toTime;
    private Instant generatedAt;

    // Constructors
    public EventAnalyticsDTO() {
        this.generatedAt = Instant.now();
    }

    public EventAnalyticsDTO(Instant fromTime, Instant toTime) {
        this.fromTime = fromTime;
        this.toTime = toTime;
        this.generatedAt = Instant.now();
    }

    // Getters and Setters

    public Long getTotalEventsToday() {
        return totalEventsToday;
    }

    public void setTotalEventsToday(Long totalEventsToday) {
        this.totalEventsToday = totalEventsToday;
    }

    public Long getTotalEventsThisWeek() {
        return totalEventsThisWeek;
    }

    public void setTotalEventsThisWeek(Long totalEventsThisWeek) {
        this.totalEventsThisWeek = totalEventsThisWeek;
    }

    public Long getTotalEventsThisMonth() {
        return totalEventsThisMonth;
    }

    public void setTotalEventsThisMonth(Long totalEventsThisMonth) {
        this.totalEventsThisMonth = totalEventsThisMonth;
    }

    public Long getTotalActiveSubscriptions() {
        return totalActiveSubscriptions;
    }

    public void setTotalActiveSubscriptions(Long totalActiveSubscriptions) {
        this.totalActiveSubscriptions = totalActiveSubscriptions;
    }

    public Long getTotalUsersWithSubscriptions() {
        return totalUsersWithSubscriptions;
    }

    public void setTotalUsersWithSubscriptions(Long totalUsersWithSubscriptions) {
        this.totalUsersWithSubscriptions = totalUsersWithSubscriptions;
    }

    public List<EventTypeCount> getEventsByType() {
        return eventsByType;
    }

    public void setEventsByType(List<EventTypeCount> eventsByType) {
        this.eventsByType = eventsByType;
    }

    public List<EventSeverityCount> getEventsBySeverity() {
        return eventsBySeverity;
    }

    public void setEventsBySeverity(List<EventSeverityCount> eventsBySeverity) {
        this.eventsBySeverity = eventsBySeverity;
    }

    public List<SourceServiceCount> getEventsBySourceService() {
        return eventsBySourceService;
    }

    public void setEventsBySourceService(List<SourceServiceCount> eventsBySourceService) {
        this.eventsBySourceService = eventsBySourceService;
    }

    public List<TopSubscription> getTopActiveSubscriptions() {
        return topActiveSubscriptions;
    }

    public void setTopActiveSubscriptions(List<TopSubscription> topActiveSubscriptions) {
        this.topActiveSubscriptions = topActiveSubscriptions;
    }

    public List<EventTrendPoint> getRecentTrends() {
        return recentTrends;
    }

    public void setRecentTrends(List<EventTrendPoint> recentTrends) {
        this.recentTrends = recentTrends;
    }

    public ResponseTimeMetrics getResponseMetrics() {
        return responseMetrics;
    }

    public void setResponseMetrics(ResponseTimeMetrics responseMetrics) {
        this.responseMetrics = responseMetrics;
    }

    public AlertStatistics getAlertStats() {
        return alertStats;
    }

    public void setAlertStats(AlertStatistics alertStats) {
        this.alertStats = alertStats;
    }

    public Instant getFromTime() {
        return fromTime;
    }

    public void setFromTime(Instant fromTime) {
        this.fromTime = fromTime;
    }

    public Instant getToTime() {
        return toTime;
    }

    public void setToTime(Instant toTime) {
        this.toTime = toTime;
    }

    public Instant getGeneratedAt() {
        return generatedAt;
    }

    public void setGeneratedAt(Instant generatedAt) {
        this.generatedAt = generatedAt;
    }

    @Override
    public String toString() {
        return "EventAnalyticsDTO{" +
                "totalEventsToday=" + totalEventsToday +
                ", totalEventsThisWeek=" + totalEventsThisWeek +
                ", totalEventsThisMonth=" + totalEventsThisMonth +
                ", totalActiveSubscriptions=" + totalActiveSubscriptions +
                ", fromTime=" + fromTime +
                ", toTime=" + toTime +
                ", generatedAt=" + generatedAt +
                '}';
    }

    // Nested classes for analytics data structures

    public static class EventTypeCount {
        private EventType eventType;
        private Long count;
        private Double percentage;

        public EventTypeCount() {}

        public EventTypeCount(EventType eventType, Long count) {
            this.eventType = eventType;
            this.count = count;
        }

        public EventType getEventType() { return eventType; }
        public void setEventType(EventType eventType) { this.eventType = eventType; }
        public Long getCount() { return count; }
        public void setCount(Long count) { this.count = count; }
        public Double getPercentage() { return percentage; }
        public void setPercentage(Double percentage) { this.percentage = percentage; }
    }

    public static class EventSeverityCount {
        private EventSeverity severity;
        private Long count;
        private Double percentage;

        public EventSeverityCount() {}

        public EventSeverityCount(EventSeverity severity, Long count) {
            this.severity = severity;
            this.count = count;
        }

        public EventSeverity getSeverity() { return severity; }
        public void setSeverity(EventSeverity severity) { this.severity = severity; }
        public Long getCount() { return count; }
        public void setCount(Long count) { this.count = count; }
        public Double getPercentage() { return percentage; }
        public void setPercentage(Double percentage) { this.percentage = percentage; }
    }

    public static class SourceServiceCount {
        private String sourceService;
        private Long count;
        private Double percentage;

        public SourceServiceCount() {}

        public SourceServiceCount(String sourceService, Long count) {
            this.sourceService = sourceService;
            this.count = count;
        }

        public String getSourceService() { return sourceService; }
        public void setSourceService(String sourceService) { this.sourceService = sourceService; }
        public Long getCount() { return count; }
        public void setCount(Long count) { this.count = count; }
        public Double getPercentage() { return percentage; }
        public void setPercentage(Double percentage) { this.percentage = percentage; }
    }

    public static class TopSubscription {
        private String subscriptionName;
        private Long eventsMatched;
        private Long notificationsSent;
        private String ownerName;
        private Instant lastActivity;

        public TopSubscription() {}

        public TopSubscription(String subscriptionName, Long eventsMatched) {
            this.subscriptionName = subscriptionName;
            this.eventsMatched = eventsMatched;
        }

        public String getSubscriptionName() { return subscriptionName; }
        public void setSubscriptionName(String subscriptionName) { this.subscriptionName = subscriptionName; }
        public Long getEventsMatched() { return eventsMatched; }
        public void setEventsMatched(Long eventsMatched) { this.eventsMatched = eventsMatched; }
        public Long getNotificationsSent() { return notificationsSent; }
        public void setNotificationsSent(Long notificationsSent) { this.notificationsSent = notificationsSent; }
        public String getOwnerName() { return ownerName; }
        public void setOwnerName(String ownerName) { this.ownerName = ownerName; }
        public Instant getLastActivity() { return lastActivity; }
        public void setLastActivity(Instant lastActivity) { this.lastActivity = lastActivity; }
    }

    public static class EventTrendPoint {
        private Instant timestamp;
        private Long eventCount;
        private Long criticalCount;
        private Long highCount;
        private Long mediumCount;
        private Long lowCount;

        public EventTrendPoint() {}

        public EventTrendPoint(Instant timestamp, Long eventCount) {
            this.timestamp = timestamp;
            this.eventCount = eventCount;
        }

        public Instant getTimestamp() { return timestamp; }
        public void setTimestamp(Instant timestamp) { this.timestamp = timestamp; }
        public Long getEventCount() { return eventCount; }
        public void setEventCount(Long eventCount) { this.eventCount = eventCount; }
        public Long getCriticalCount() { return criticalCount; }
        public void setCriticalCount(Long criticalCount) { this.criticalCount = criticalCount; }
        public Long getHighCount() { return highCount; }
        public void setHighCount(Long highCount) { this.highCount = highCount; }
        public Long getMediumCount() { return mediumCount; }
        public void setMediumCount(Long mediumCount) { this.mediumCount = mediumCount; }
        public Long getLowCount() { return lowCount; }
        public void setLowCount(Long lowCount) { this.lowCount = lowCount; }
    }

    public static class ResponseTimeMetrics {
        private Double averageProcessingTimeMs;
        private Double averageNotificationTimeMs;
        private Long totalProcessedEvents;
        private Long failedNotifications;
        private Double successRate;

        public ResponseTimeMetrics() {}

        public Double getAverageProcessingTimeMs() { return averageProcessingTimeMs; }
        public void setAverageProcessingTimeMs(Double averageProcessingTimeMs) { this.averageProcessingTimeMs = averageProcessingTimeMs; }
        public Double getAverageNotificationTimeMs() { return averageNotificationTimeMs; }
        public void setAverageNotificationTimeMs(Double averageNotificationTimeMs) { this.averageNotificationTimeMs = averageNotificationTimeMs; }
        public Long getTotalProcessedEvents() { return totalProcessedEvents; }
        public void setTotalProcessedEvents(Long totalProcessedEvents) { this.totalProcessedEvents = totalProcessedEvents; }
        public Long getFailedNotifications() { return failedNotifications; }
        public void setFailedNotifications(Long failedNotifications) { this.failedNotifications = failedNotifications; }
        public Double getSuccessRate() { return successRate; }
        public void setSuccessRate(Double successRate) { this.successRate = successRate; }
    }

    public static class AlertStatistics {
        private Long totalAlertsTriggered;
        private Long totalNotificationsSent;
        private Long totalActionsExecuted;
        private Map<String, Long> alertsByChannel; // email, slack, webhook, etc.

        public AlertStatistics() {}

        public Long getTotalAlertsTriggered() { return totalAlertsTriggered; }
        public void setTotalAlertsTriggered(Long totalAlertsTriggered) { this.totalAlertsTriggered = totalAlertsTriggered; }
        public Long getTotalNotificationsSent() { return totalNotificationsSent; }
        public void setTotalNotificationsSent(Long totalNotificationsSent) { this.totalNotificationsSent = totalNotificationsSent; }
        public Long getTotalActionsExecuted() { return totalActionsExecuted; }
        public void setTotalActionsExecuted(Long totalActionsExecuted) { this.totalActionsExecuted = totalActionsExecuted; }
        public Map<String, Long> getAlertsByChannel() { return alertsByChannel; }
        public void setAlertsByChannel(Map<String, Long> alertsByChannel) { this.alertsByChannel = alertsByChannel; }
    }
}