Skip to content

Commit 38ee6c9

Browse files
committed
Synced with main
1 parent a42e81e commit 38ee6c9

File tree

6 files changed

+156
-6
lines changed

6 files changed

+156
-6
lines changed

api/src/main/java/io/kafbat/ui/mapper/DynamicConfigMapper.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import io.kafbat.ui.model.ApplicationConfigPropertiesDTO;
1010
import io.kafbat.ui.model.ApplicationConfigPropertiesKafkaClustersInnerDTO;
1111
import io.kafbat.ui.model.ApplicationConfigPropertiesRbacRolesInnerPermissionsInnerDTO;
12+
import io.kafbat.ui.model.RbacPermissionDTO;
1213
import io.kafbat.ui.model.rbac.Permission;
1314
import io.kafbat.ui.util.DynamicConfigOperations;
1415
import java.util.Optional;
@@ -26,6 +27,9 @@ public interface DynamicConfigMapper {
2627
@Mapping(target = "kafka.clusters[].metrics.store", ignore = true)
2728
ApplicationConfigPropertiesDTO toDto(DynamicConfigOperations.PropertiesStructure propertiesStructure);
2829

30+
@Mapping(target = "parsedActions", ignore = true)
31+
Permission toPermission(RbacPermissionDTO dto);
32+
2933
default String map(Resource resource) {
3034
return resource.getFilename();
3135
}

contract-typespec/api/clusters.tsp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ alias ClusterFeature =
5555
| "TOPIC_DELETION"
5656
| "KAFKA_ACL_VIEW"
5757
| "KAFKA_ACL_EDIT"
58-
| "CLIENT_QUOTA_MANAGEMENT";
58+
| "CLIENT_QUOTA_MANAGEMENT"
59+
| "GRAPHS_ENABLED";
5960

6061
enum ServerStatus {
6162
ONLINE,

contract-typespec/api/config.tsp

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,11 @@ model ApplicationConfig {
115115
value?: string;
116116
regex?: boolean = false;
117117
}[];
118-
permissions?: {
119-
resource?: ResourceType;
120-
value?: string;
121-
actions?: Action[];
122-
}[];
118+
permissions?: RbacPermission[];
123119
}[];
120+
defaultRole?: {
121+
permissions?: RbacPermission[];
122+
}
124123
};
125124
webclient?: {
126125
maxInMemoryBufferSize?: string;
@@ -135,6 +134,14 @@ model ApplicationConfig {
135134
};
136135
adminClientTimeout?: int32;
137136
internalTopicPrefix?: string;
137+
defaultMetricsStorage?: ClusterMetricsStoreConfig;
138+
cache?: {
139+
enabled?: boolean;
140+
@format("duration")
141+
connectCacheExpiry?: string;
142+
@format("duration")
143+
connectClusterCacheExpiry?: string;
144+
};
138145
clusters?: {
139146
name?: string;
140147
bootstrapServers?: string;
@@ -177,6 +184,8 @@ model ApplicationConfig {
177184
password?: string;
178185
keystoreLocation?: string;
179186
keystorePassword?: string;
187+
prometheusExpose?: boolean;
188+
store?: ClusterMetricsStoreConfig;
180189
};
181190
properties?: Record<unknown>;
182191
consumerProperties?: Record<unknown>;
@@ -231,6 +240,7 @@ model ClusterConfigValidation {
231240
schemaRegistry?: ApplicationPropertyValidation;
232241
kafkaConnects?: Record<ApplicationPropertyValidation>;
233242
ksqldb?: ApplicationPropertyValidation;
243+
prometheusStorage?: ApplicationPropertyValidation;
234244
}
235245

236246
alias ApplicationFeature =
@@ -291,3 +301,22 @@ enum ResourceType {
291301
AUDIT,
292302
CLIENT_QUOTAS,
293303
}
304+
305+
model ClusterMetricsStoreConfig {
306+
prometheus?: PrometheusStorage;
307+
}
308+
309+
model PrometheusStorage {
310+
url?: string;
311+
remoteWrite?: boolean;
312+
pushGatewayUrl?: string;
313+
pushGatewayUsername?: string;
314+
pushGatewayPassword?: string;
315+
pushGatewayJobName?: string;
316+
}
317+
318+
model RbacPermission {
319+
resource?: ResourceType;
320+
value?: string;
321+
actions?: Action[];
322+
}

contract-typespec/api/graphs.tsp

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
import "@typespec/openapi";
2+
import "./responses.tsp";
3+
4+
namespace Api;
5+
6+
using TypeSpec.Http;
7+
using OpenAPI;
8+
9+
@route("/api/clusters/{clusterName}/graphs")
10+
@tag("Graphs")
11+
interface GraphsApi {
12+
@get
13+
@operationId("getGraphsList")
14+
@summary("getGraphsList")
15+
getGraphsList(
16+
@path clusterName: string
17+
): GraphDescriptions;
18+
19+
@post
20+
@operationId("getGraphData")
21+
@summary("getGraphData")
22+
getGraphData(
23+
@path clusterName: string,
24+
@body request: GraphDataRequest
25+
) : PrometheusApiQueryResponse
26+
}
27+
28+
model GraphDescriptions {
29+
graphs?: Array<GraphDescription>;
30+
}
31+
32+
model GraphDescription {
33+
@doc("Id that should be used to query data on API level")
34+
id: string;
35+
type?: "range" | "instant";
36+
@doc("""
37+
ISO_8601 duration string (for "range" graphs only)
38+
""")
39+
defaultPeriod?: string;
40+
parameters?: Array<GraphParameter>;
41+
}
42+
43+
model GraphParameter {
44+
name: string;
45+
}
46+
47+
model GraphDataRequest {
48+
id?: string;
49+
parameters?: Record<string>;
50+
from?: offsetDateTime;
51+
to?: offsetDateTime;
52+
}
53+
54+
model PrometheusApiBaseResponse {
55+
status: "success" | "error";
56+
error?: string;
57+
errorType?: string;
58+
warnings?: Array<string>;
59+
}
60+
61+
model PrometheusApiQueryResponse extends PrometheusApiBaseResponse {
62+
data?: PrometheusApiQueryResponseData;
63+
}
64+
65+
model PrometheusApiQueryResponseData {
66+
resultType: "matrix" | "vector" | "scalar" | "string";
67+
@doc("""
68+
Depending on resultType format can vary:
69+
"vector":
70+
[
71+
{
72+
"metric": { "<label_name>": "<label_value>", ... },
73+
"value": [ <unix_time>, "<sample_value>" ],
74+
"histogram": [ <unix_time>, <histogram> ]
75+
}, ...
76+
]
77+
"matrix":
78+
[
79+
{
80+
"metric": { "<label_name>": "<label_value>", ... },
81+
"values": [ [ <unix_time>, "<sample_value>" ], ... ],
82+
"histograms": [ [ <unix_time>, <histogram> ], ... ]
83+
}, ...
84+
]
85+
"scalar":
86+
[ <unix_time>, "<scalar_value>" ]
87+
"string":
88+
[ <unix_time>, "<string_value>" ]
89+
""")
90+
result?: Array<unknown>;
91+
}

contract-typespec/api/main.tsp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import "./acls.tsp";
1111
import "./quotas.tsp";
1212
import "./auth.tsp";
1313
import "./config.tsp";
14+
import "./graphs.tsp";
15+
import "./prometheus.tsp";
1416

1517
import "@typespec/http";
1618
import "@typespec/rest";
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import "@typespec/openapi";
2+
import "./models.tsp";
3+
import "./responses.tsp";
4+
5+
namespace Api;
6+
7+
using TypeSpec.Http;
8+
using OpenAPI;
9+
10+
@route("/metrics")
11+
@tag("PrometheusExpose")
12+
interface PrometheusExposeApi {
13+
@get
14+
@summary("exposeAllMetrics")
15+
@operationId("exposeAllMetrics")
16+
exposeAllMetrics(): string;
17+
18+
@get
19+
@route("/{clusterName}")
20+
@summary("exposeClusterMetrics")
21+
@operationId("exposeClusterMetrics")
22+
exposeClusterMetrics(@path clusterName: string): string;
23+
}

0 commit comments

Comments
 (0)