Skip to content

Commit c12bde0

Browse files
authored
feat: add events query endpoint and schemas to logs adapter (#686)
* feat: add events query endpoint and schemas to logs adapter Signed-off-by: Akila-I <akila.99g@gmail.com> * fix: add 404 error response for alert rule not found in API spec Signed-off-by: Akila-I <akila.99g@gmail.com> --------- Signed-off-by: Akila-I <akila.99g@gmail.com>
1 parent 0fc10f8 commit c12bde0

1 file changed

Lines changed: 165 additions & 0 deletions

File tree

static/api-specs/observability-logs-adapter-api.yaml

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,67 @@ paths:
118118
errorCode: "OBS-V1-L-29"
119119
message: ""
120120

121+
/api/v1/events/query:
122+
post:
123+
tags:
124+
- Events
125+
summary: Query events
126+
description: Query Kubernetes events from the observer service
127+
operationId: queryEvents
128+
requestBody:
129+
required: true
130+
content:
131+
application/json:
132+
schema:
133+
$ref: "#/components/schemas/EventsQueryRequest"
134+
responses:
135+
"200":
136+
description: Events queried successfully
137+
content:
138+
application/json:
139+
schema:
140+
$ref: "#/components/schemas/EventsQueryResponse"
141+
"400":
142+
description: Invalid request
143+
content:
144+
application/json:
145+
schema:
146+
$ref: "#/components/schemas/ErrorResponse"
147+
example:
148+
title: "badRequest"
149+
errorCode: ""
150+
message: "Missing required fields 'startTime' and 'endTime'"
151+
"401":
152+
description: Unauthorized
153+
content:
154+
application/json:
155+
schema:
156+
$ref: "#/components/schemas/ErrorResponse"
157+
example:
158+
title: "unauthorized"
159+
errorCode: ""
160+
message: "Invalid or missing token"
161+
"403":
162+
description: Forbidden
163+
content:
164+
application/json:
165+
schema:
166+
$ref: "#/components/schemas/ErrorResponse"
167+
example:
168+
title: "forbidden"
169+
errorCode: ""
170+
message: "Subject <xyz> has no permission to view events of Namespace foo, Project bar, Component baz in Environment development"
171+
"500":
172+
description: Internal Server Error
173+
content:
174+
application/json:
175+
schema:
176+
$ref: "#/components/schemas/ErrorResponse"
177+
example:
178+
title: "internalServerError"
179+
errorCode: "OBS-V1-E-01"
180+
message: ""
181+
121182
/api/v1alpha1/alerts/rules:
122183
post:
123184
tags:
@@ -255,6 +316,12 @@ paths:
255316
application/json:
256317
schema:
257318
$ref: "#/components/schemas/ErrorResponse"
319+
"404":
320+
description: Alert rule not found
321+
content:
322+
application/json:
323+
schema:
324+
$ref: "#/components/schemas/ErrorResponse"
258325
"500":
259326
description: Internal Server Error
260327
content:
@@ -438,6 +505,104 @@ components:
438505
type: integer
439506
description: The time taken to query the logs in milliseconds
440507

508+
# Request schema for events
509+
EventsQueryRequest:
510+
type: object
511+
properties:
512+
startTime:
513+
type: string
514+
description: The start time of the query
515+
format: date-time
516+
endTime:
517+
type: string
518+
description: The end time of the query
519+
format: date-time
520+
limit:
521+
type: integer
522+
default: 100
523+
minimum: 1
524+
maximum: 1000
525+
description: The maximum number of items to return
526+
sortOrder:
527+
type: string
528+
description: The sort order of the query
529+
enum:
530+
- asc
531+
- desc
532+
default: desc
533+
searchScope:
534+
oneOf:
535+
- $ref: "#/components/schemas/ComponentSearchScope"
536+
- $ref: "#/components/schemas/WorkflowSearchScope"
537+
required: [startTime, endTime, searchScope]
538+
539+
# Response schemas for events
540+
EventEntry:
541+
type: object
542+
properties:
543+
timestamp:
544+
type: string
545+
description: The timestamp of the event
546+
format: date-time
547+
body:
548+
type: string
549+
description: The event message
550+
reason:
551+
type: string
552+
description: The short, machine-readable reason for the event (e.g. SawCompletedJob)
553+
metadata:
554+
type: object
555+
description: The metadata of the event
556+
properties:
557+
componentName:
558+
type: string
559+
description: The OpenChoreo component name the event is associated with
560+
projectName:
561+
type: string
562+
description: The OpenChoreo project name the event is associated with
563+
environmentName:
564+
type: string
565+
description: The OpenChoreo environment name the event is associated with
566+
namespaceName:
567+
type: string
568+
description: The OpenChoreo namespace name the event is associated with
569+
componentUid:
570+
type: string
571+
description: The OpenChoreo component UID the event is associated with
572+
format: uuid
573+
projectUid:
574+
type: string
575+
description: The OpenChoreo project UID the event is associated with
576+
format: uuid
577+
environmentUid:
578+
type: string
579+
description: The OpenChoreo environment UID the event is associated with
580+
format: uuid
581+
objectKind:
582+
type: string
583+
description: The kind of the Kubernetes object the event involves (e.g. CronJob)
584+
objectName:
585+
type: string
586+
description: The name of the Kubernetes object the event involves
587+
objectNamespace:
588+
type: string
589+
description: The namespace of the Kubernetes object the event involves
590+
591+
EventsQueryResponse:
592+
type: object
593+
properties:
594+
events:
595+
type: array
596+
items:
597+
$ref: "#/components/schemas/EventEntry"
598+
description: The events queried successfully
599+
total:
600+
type: integer
601+
description: The total number of matching events, capped at 1000
602+
tookMs:
603+
type: integer
604+
description: The time taken to query the events in milliseconds
605+
441606
# Request schemas for alert rules
442607
AlertRuleRequest:
443608
type: object

0 commit comments

Comments
 (0)