2022-12-12 14:05:56 +01:00
import { FromSchema } from 'json-schema-to-ts' ;
export const requestsPerSecondSchema = {
$id : '#/components/schemas/requestsPerSecondSchema' ,
type : 'object' ,
2023-07-10 10:18:08 +02:00
description :
'Statistics for usage of Unleash, formatted so it can easily be used in a graph' ,
2022-12-12 14:05:56 +01:00
properties : {
status : {
type : 'string' ,
2023-07-10 10:18:08 +02:00
description :
'Whether the query against prometheus succeeded or failed' ,
enum : [ 'success' , 'failure' ] ,
example : 'success' ,
2022-12-12 14:05:56 +01:00
} ,
data : {
type : 'object' ,
2023-07-10 10:18:08 +02:00
description : 'The query result from prometheus' ,
2022-12-12 14:05:56 +01:00
properties : {
resultType : {
type : 'string' ,
2023-07-10 10:18:08 +02:00
description : 'Prometheus compatible result type.' ,
enum : [ 'matrix' , 'vector' , 'scalar' , 'string' ] ,
example : 'vector' ,
2022-12-12 14:05:56 +01:00
} ,
result : {
description :
'An array of values per metric. Each one represents a line in the graph labeled by its metric name' ,
type : 'array' ,
items : {
type : 'object' ,
2023-07-10 10:18:08 +02:00
description :
'A representation of a single metric to build a line in a graph' ,
2022-12-12 14:05:56 +01:00
properties : {
metric : {
description :
'A key value set representing the metric' ,
type : 'object' ,
properties : {
appName : {
2023-07-10 10:18:08 +02:00
description :
'Name of the application this metric relates to' ,
2022-12-12 14:05:56 +01:00
type : 'string' ,
2023-07-10 10:18:08 +02:00
example : 'mySdk' ,
2022-12-12 14:05:56 +01:00
} ,
2022-12-19 17:06:59 +01:00
endpoint : {
2023-07-10 10:18:08 +02:00
description :
'Which endpoint has been accessed' ,
2022-12-19 17:06:59 +01:00
type : 'string' ,
2023-07-10 10:18:08 +02:00
example : '/api/frontend' ,
2022-12-19 17:06:59 +01:00
} ,
2022-12-12 14:05:56 +01:00
} ,
} ,
values : {
description :
'An array of arrays. Each element of the array is an array of size 2 consisting of the 2 axis for the graph: in position zero the x axis represented as a number and position one the y axis represented as string' ,
type : 'array' ,
items : {
type : 'array' ,
2023-07-10 10:18:08 +02:00
description :
'Either the x axis represented as a number or the y axis represented as a string' ,
2022-12-12 14:05:56 +01:00
items : {
anyOf : [
2023-07-10 10:18:08 +02:00
{
type : 'string' ,
description :
'An identifier for the line in the graph' ,
} ,
{
type : 'number' ,
description :
'The number of requests at this point in time' ,
} ,
2022-12-12 14:05:56 +01:00
] ,
} ,
} ,
} ,
} ,
} ,
} ,
} ,
} ,
} ,
components : { } ,
} as const ;
export type RequestsPerSecondSchema = FromSchema <
typeof requestsPerSecondSchema
> ;