Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce Insights feature #4071

Merged
merged 2 commits into from
Dec 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ spec:
| filestore | [FileStore](#filestore) | File storage for storing deployment logs and application states. | Yes |
| cache | [Cache](#cache) | Internal cache configuration. | No |
| address | string | The address to the control plane. This is required if SSO is enabled. | No |
| insightCollector | [InsightCollector](#insightcollector) | Option to run collector of Insights feature. | No |
| sharedSSOConfigs | [][SharedSSOConfig](#sharedssoconfig) | List of shared SSO configurations that can be used by any projects. | No |
| projects | [][Project](#project) | List of debugging/quickstart projects. Please note that do not use this to configure the projects running in the production. | No |

Expand Down Expand Up @@ -118,6 +119,28 @@ Must be one of the following objects:
| username | string | The username string. | Yes |
| passwordHash | string | The bcrypt hashed value of the password string. | Yes |

## InsightCollector

| Field | Type | Description | Required |
|-|-|-|-|
| application | [InsightCollectorApplication](#insightcollectorapplication) | Application metrics collector. | No |
| deployment | [InsightCollectorDeployment](#insightcollectordeployment) | Deployment metrics collector. | No |

## InsightCollectorApplication

| Field | Type | Description | Required |
|-|-|-|-|
| enabled | bool | Whether to enable. Default is `true` | No |
| schedule | string | When collector will be executed. Default is `0 * * * *` | No |

## InsightCollectorDeployment

| Field | Type | Description | Required |
|-|-|-|-|
| enabled | bool | Whether to enable. Default is `true` | No |
| schedule | string | When collector will be executed. Default is `30 * * * *` | No |
| chunkMaxCount | int | The maximum number of deployment items could be stored in a chunk. Default is `1000` | No |

## SharedSSOConfig

| Field | Type | Description | Required |
Expand Down
4 changes: 2 additions & 2 deletions pkg/app/ops/insightcollector/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (c *Collector) Run(ctx context.Context) error {
c.logger.Info("start running insight collector", zap.Any("config", c.cfg))
cr := cron.New(cron.WithLocation(time.UTC))

if c.cfg.Application.Enabled {
if *c.cfg.Application.Enabled {
_, err := cr.AddFunc(c.cfg.Application.Schedule, func() {
c.applicationDataCol.Execute(ctx)
})
Expand All @@ -76,7 +76,7 @@ func (c *Collector) Run(ctx context.Context) error {
c.logger.Info("added a cron job to collect app data")
}

if c.cfg.Deployment.Enabled {
if *c.cfg.Deployment.Enabled {
_, err := cr.AddFunc(c.cfg.Deployment.Schedule, func() {
c.completedDeploymentDataCol.Execute(ctx)
})
Expand Down
4 changes: 0 additions & 4 deletions pkg/app/server/grpcapi/web_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1535,10 +1535,6 @@ func (a *WebAPI) GetInsightData(ctx context.Context, req *webservice.GetInsightD
return nil, err
}

if !config.FeatureFlagEnabled(config.FeatureFlagInsights) {
return nil, status.Error(codes.Unimplemented, "Unimplemented")
}

var points []*model.InsightDataPoint

switch req.MetricsKind {
Expand Down
5 changes: 2 additions & 3 deletions pkg/config/control_plane.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ type ControlPlaneSpec struct {
// The configuration of cache for control plane.
Cache ControlPlaneCache `json:"cache"`
// The configuration of insight collector.
// TODO: Enable collecting insight by default once this feature reached Beta.
InsightCollector ControlPlaneInsightCollector `json:"insightCollector"`
// List of debugging/quickstart projects defined in Control Plane configuration.
// Please note that do not use this to configure the projects running in the production.
Expand Down Expand Up @@ -189,13 +188,13 @@ type ControlPlaneInsightCollector struct {
}

type InsightCollectorApplication struct {
Enabled bool `json:"enabled" default:"true"`
Enabled *bool `json:"enabled" default:"true"`
// Default is running every hour.
Schedule string `json:"schedule" default:"0 * * * *"`
}

type InsightCollectorDeployment struct {
Enabled bool `json:"enabled"`
Enabled *bool `json:"enabled" default:"true"`
// Default is running every hour.
Schedule string `json:"schedule" default:"30 * * * *"`
ChunkMaxCount int `json:"chunkMaxCount" default:"1000"`
Expand Down
4 changes: 2 additions & 2 deletions pkg/config/control_plane_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ func TestControlPlaneConfig(t *testing.T) {
},
InsightCollector: ControlPlaneInsightCollector{
Application: InsightCollectorApplication{
Enabled: true,
Enabled: newBoolPointer(true),
Schedule: "0 * * * *",
},
Deployment: InsightCollectorDeployment{
Enabled: true,
Enabled: newBoolPointer(true),
Schedule: "0 10 * * *",
ChunkMaxCount: 1000,
},
Expand Down