feat(statistics): добавить раздел статистики трафика
Docker images / prepare-release (push) Successful in 10s
Docker images / backend-test (push) Successful in 2m19s
Docker images / frontend-image (push) Successful in 4m47s
Docker images / updater-image (push) Successful in 48s
Docker images / backend-image (push) Successful in 2m53s
Docker images / notify-webhook (push) Skipped
Docker images / publish-release (push) Successful in 13s
Docker images / prepare-release (push) Successful in 10s
Docker images / backend-test (push) Successful in 2m19s
Docker images / frontend-image (push) Successful in 4m47s
Docker images / updater-image (push) Successful in 48s
Docker images / backend-image (push) Successful in 2m53s
Docker images / notify-webhook (push) Skipped
Docker images / publish-release (push) Successful in 13s
Куб IPFIX час+день с AND-слайсами и экраном отчётности /statistics, живой /traffic не меняем. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
@@ -49,6 +49,10 @@
|
||||
"./geoip": {
|
||||
"types": "./dist/geoip.d.ts",
|
||||
"default": "./dist/geoip.js"
|
||||
},
|
||||
"./statistics": {
|
||||
"types": "./dist/statistics.d.ts",
|
||||
"default": "./dist/statistics.js"
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
|
||||
@@ -7,3 +7,4 @@ export * from "./wireguard.js"
|
||||
export * from "./users.js"
|
||||
export * from "./traffic-flow.js"
|
||||
export * from "./geoip.js"
|
||||
export * from "./statistics.js"
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
import { z } from "zod"
|
||||
|
||||
export const statisticsBreakdownRowSchema = z.object({
|
||||
id: z.string(),
|
||||
label: z.string(),
|
||||
bytes: z.number().nonnegative(),
|
||||
packets: z.number().nonnegative(),
|
||||
bps: z.number().nonnegative(),
|
||||
percent: z.number().nonnegative(),
|
||||
})
|
||||
|
||||
export const statisticsSeriesPointSchema = z.object({
|
||||
t: z.string(),
|
||||
bytes: z.number().nonnegative(),
|
||||
})
|
||||
|
||||
export const statisticsKpisSchema = z.object({
|
||||
bytes: z.number().nonnegative(),
|
||||
packets: z.number().nonnegative(),
|
||||
avgBps: z.number().nonnegative(),
|
||||
users: z.number().int().nonnegative(),
|
||||
servers: z.number().int().nonnegative(),
|
||||
ifaces: z.number().int().nonnegative(),
|
||||
topCountry: z.string(),
|
||||
topService: z.string(),
|
||||
})
|
||||
|
||||
export const statisticsQuerySchema = z.object({
|
||||
from: z.string().min(1),
|
||||
to: z.string().min(1),
|
||||
serverId: z.coerce.number().int().positive().optional(),
|
||||
userId: z.string().min(1).optional(),
|
||||
iface: z.string().min(1).optional(),
|
||||
country: z.string().min(2).max(2).optional(),
|
||||
service: z.string().min(1).optional(),
|
||||
asn: z.coerce.number().int().optional(),
|
||||
})
|
||||
|
||||
export const statisticsDtoSchema = z.object({
|
||||
from: z.string(),
|
||||
to: z.string(),
|
||||
grain: z.enum(["hour", "day"]),
|
||||
kpis: statisticsKpisSchema,
|
||||
series: z.array(statisticsSeriesPointSchema),
|
||||
users: z.array(statisticsBreakdownRowSchema),
|
||||
servers: z.array(statisticsBreakdownRowSchema),
|
||||
interfaces: z.array(statisticsBreakdownRowSchema),
|
||||
countries: z.array(statisticsBreakdownRowSchema),
|
||||
services: z.array(statisticsBreakdownRowSchema),
|
||||
asns: z.array(statisticsBreakdownRowSchema),
|
||||
})
|
||||
|
||||
export type StatisticsBreakdownRow = z.infer<typeof statisticsBreakdownRowSchema>
|
||||
export type StatisticsSeriesPoint = z.infer<typeof statisticsSeriesPointSchema>
|
||||
export type StatisticsKpis = z.infer<typeof statisticsKpisSchema>
|
||||
export type StatisticsQuery = z.infer<typeof statisticsQuerySchema>
|
||||
export type StatisticsDto = z.infer<typeof statisticsDtoSchema>
|
||||
@@ -244,6 +244,8 @@ export const flowPurgeDtoSchema = z.object({
|
||||
minuteStats: z.number().int().nonnegative(),
|
||||
minuteDims: z.number().int().nonnegative(),
|
||||
dailyDims: z.number().int().nonnegative(),
|
||||
hourFacts: z.number().int().nonnegative().optional(),
|
||||
dailyFacts: z.number().int().nonnegative().optional(),
|
||||
}),
|
||||
fileBytesBefore: z.number().int().nonnegative(),
|
||||
fileBytesAfter: z.number().int().nonnegative(),
|
||||
|
||||
Reference in New Issue
Block a user