Skip to content

Commit

Permalink
go reports-service: Add title to each incident
Browse files Browse the repository at this point in the history
  • Loading branch information
XxRoloxX committed Nov 3, 2024
1 parent 9db048b commit d931942
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 19 deletions.
23 changes: 16 additions & 7 deletions go/services/reports/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ components:
properties:
node:
type: string
precision:
type: string
accuracy:
$ref: "#/components/schemas/Accuracy"
customPrompt:
type: string
incidents:
Expand All @@ -179,8 +179,8 @@ components:
properties:
applicationName:
type: string
precision:
type: string
accuracy:
$ref: "#/components/schemas/Accuracy"
customPrompt:
type: string
incidents:
Expand All @@ -193,6 +193,8 @@ components:
properties:
id:
type: string
title:
type: string
category:
type: string
clusterId:
Expand All @@ -215,6 +217,8 @@ components:
properties:
id:
type: string
title:
type: string
clusterId:
type: string
applicationName:
Expand Down Expand Up @@ -303,7 +307,8 @@ components:
properties:
applicationName:
type: string
precision:
accuracy:
$ref: "#/components/schemas/Accuracy"
type: string
customPrompt:
type: string
Expand All @@ -313,8 +318,8 @@ components:
properties:
nodeName:
type: string
precision:
type: string
accuracy:
$ref: "#/components/schemas/Accuracy"
customPrompt:
type: string
reportsPostParams:
Expand Down Expand Up @@ -346,6 +351,10 @@ components:
enum: [1, 2, 3]
description: 1 = Low, 2 = Medium, 3 = High

Accuracy:
type: string
enum: [HIGH, MEDIUM, LOW]

ReportState:
type: string
enum: [failed_to_generate, awaiting_generation, generated]
Expand Down
2 changes: 2 additions & 0 deletions go/services/reports/internal/services/reports_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ func (s *ReportsService) getApplicationIncidentFromInsight(insight insights.Appl

ApplicationName: insight.Metadata[0].ApplicationName,
ClusterId: insight.Metadata[0].ClusterId,
Title: insight.Insight.Title,
Category: insight.Insight.Category,
Summary: insight.Insight.Summary,
Recommendation: insight.Insight.Recommendation,
Expand Down Expand Up @@ -499,6 +500,7 @@ func (s *ReportsService) getNodeIncidentFromInsight(insight insights.NodeInsight
return &repositories.NodeIncident{
ClusterId: insight.Metadata[0].ClusterId,
NodeName: insight.Metadata[0].NodeName,
Title: insight.Insight.Title,
Category: insight.Insight.Category,
Summary: insight.Insight.Summary,
Recommendation: insight.Insight.Recommendation,
Expand Down
5 changes: 3 additions & 2 deletions go/services/reports/pkg/insights/application_insights.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type ScheduledApplicationInsights struct {

type ApplicationLogsInsight struct {
ApplicationName string `json:"applicationName"`
IncidentName string `json:"name"`
Title string `json:"title"`
Category string `json:"category"`
Summary string `json:"summary"`
Recommendation string `json:"recommendation"`
Expand Down Expand Up @@ -420,7 +420,8 @@ func (g *OpenAiInsightsGenerator) createMessagesFromApplicationLogs(
find logs which might suggest any kind of errors or issues. Try to give a possible reason,
category of an issue, urgency and possible resolution.
Source is an fragment of a the provided log that you are referencing in summary and recommendation.
Always declare a unmodified sources with every insight you give.
Always declare a unmodified sources with every insight you give. Title is a max few word summary of the insight.
Summary itself might be longer (max 50 words).
Always give a recommendation on how to resolve the issue. Always give a source. Never repeat insights, ie.
if you once use the source do not create an insight for it again. One insight per source. If you recognize the
same events on different containers/pods. For each incident assign urgency as an integer number between 0 and 2.
Expand Down
20 changes: 10 additions & 10 deletions go/services/reports/pkg/insights/node_insights.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import (
)

type NodeLogsInsight struct {
Name string `json:"name"`
NodeName string `json:"nodeName"`
Title string `json:"title"`
Category string `json:"category"`
Summary string `json:"summary"`
Recommendation string `json:"recommendation"`
Expand Down Expand Up @@ -87,19 +88,17 @@ func MapNodeNameToConfiguration(configurations []*NodeInsightConfiguration) map[
}

func FilterByNodesAccuracy(logsByNode map[string][]*repositories.NodeLogsDocument, configurationByNode map[string]*NodeInsightConfiguration) {
for application, logs := range logsByNode {
// Check if application configuration is in params
config, ok := configurationByNode[application]
for node, logs := range logsByNode {
config, ok := configurationByNode[node]
var accuracy Accuracy
if !ok {
// By default the app has low accuracy
accuracy = Accuracy__Low
// By default the node is not included
delete(logsByNode, node)
} else {
accuracy = config.Accuracy
filter := NewAccuracyFilter[*repositories.NodeLogsDocument](accuracy)
logsByNode[node] = filter.Filter(logs)
}

filter := NewAccuracyFilter[*repositories.NodeLogsDocument](accuracy)
logsByNode[application] = filter.Filter(logs)
}
}

Expand Down Expand Up @@ -284,7 +283,8 @@ func (g *OpenAiInsightsGenerator) createMessagesFromNodeLogs(
find logs which might suggest any kind of errors or issues. Try to give a possible reason,
category of an issue, urgency and possible resolution.
Source is an fragment of a the provided log that you are referencing in summary and recommendation.
Always declare a unmodified source log with every insight you give.
Always declare a unmodified source log with every insight you give. Title is a few word summary of the insight.
Summary itself might be longer (max 50 words).
Always give a recommendation on how to resolve the issue. Always give a source. Never repeat insights, ie.
if you once use the source do not create an insight for it again. One insight per source. Do not duplicate insights,
only mention the same issue once. For each incident assign urgency as an integer number between 0 and 2.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type ApplicationIncidentSource struct {

type ApplicationIncident struct {
Id string `bson:"_id,omitempty" json:"id"`
Title string `bson:"title" json:"title"`
ApplicationName string `bson:"applicationName" json:"applicationName"`
ClusterId string `bson:"clusterId" json:"clusterId"`
Category string `bson:"category" json:"category"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type NodeIncidentSource struct {

type NodeIncident struct {
Id string `bson:"_id,omitempty" json:"id"`
Title string `bson:"title" json:"title"`
ClusterId string `bson:"clusterId" json:"clusterId"`
NodeName string `bson:"nodeName" json:"nodeName"`
Category string `bson:"category" json:"category"`
Expand Down

0 comments on commit d931942

Please sign in to comment.