Correlations: Create first version of correlations on app platform (#110843)

* WIP

* Generate API

* use different logging, change typing as recommended

* Add feature flag and only add to installer when enabled

* add codeowner

* Lint/fmt

* fix dockerfile

* move from UID to group/name reference

* add generated code

* change from enterprise build

* build workspace

* Remove deprecated field, build api, build for enterprise, build workspace

* Not sure what caused this..

* Rebuild?

* Fix this file

* update sdk

* update sdk

* fix workspace

* fix test build

* add to go.mod

---------

Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
This commit is contained in:
Kristina
2025-09-17 08:07:45 -05:00
committed by GitHub
co-authored by Ryan McKinley
parent 82e5019333
commit a6db37c2b7
35 changed files with 1516 additions and 5 deletions
+9 -1
View File
@@ -14,6 +14,7 @@ import (
"github.com/grafana/grafana/pkg/registry/apps/advisor"
"github.com/grafana/grafana/pkg/registry/apps/alerting/notifications"
"github.com/grafana/grafana/pkg/registry/apps/alerting/rules"
"github.com/grafana/grafana/pkg/registry/apps/correlations"
"github.com/grafana/grafana/pkg/registry/apps/investigations"
"github.com/grafana/grafana/pkg/registry/apps/playlist"
"github.com/grafana/grafana/pkg/registry/apps/plugins"
@@ -33,14 +34,21 @@ func ProvideAppInstallers(
pluginsApplInstaller *plugins.PluginsAppInstaller,
shorturlAppInstaller *shorturl.ShortURLAppInstaller,
rulesAppInstaller *rules.AlertingRulesAppInstaller,
correlationsAppInstaller *correlations.CorrelationsAppInstaller,
) []appsdkapiserver.AppInstaller {
installers := []appsdkapiserver.AppInstaller{playlistAppInstaller, pluginsApplInstaller}
installers := []appsdkapiserver.AppInstaller{
playlistAppInstaller,
pluginsApplInstaller,
}
if features.IsEnabledGlobally(featuremgmt.FlagKubernetesShortURLs) {
installers = append(installers, shorturlAppInstaller)
}
if features.IsEnabledGlobally(featuremgmt.FlagKubernetesAlertingRules) && rulesAppInstaller != nil {
installers = append(installers, rulesAppInstaller)
}
if features.IsEnabledGlobally(featuremgmt.FlagKubernetesCorrelations) {
installers = append(installers, correlationsAppInstaller)
}
return installers
}
+5 -2
View File
@@ -3,17 +3,20 @@ package appregistry
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/grafana/grafana/pkg/registry/apps/alerting/rules"
"github.com/grafana/grafana/pkg/registry/apps/correlations"
"github.com/grafana/grafana/pkg/registry/apps/playlist"
"github.com/grafana/grafana/pkg/registry/apps/plugins"
"github.com/grafana/grafana/pkg/services/featuremgmt"
"github.com/stretchr/testify/require"
)
func TestProvideAppInstallers_Table(t *testing.T) {
playlistInstaller := &playlist.PlaylistAppInstaller{}
pluginsInstaller := &plugins.PluginsAppInstaller{}
rulesInstaller := &rules.AlertingRulesAppInstaller{}
correlationsAppInstaller := &correlations.CorrelationsAppInstaller{}
tests := []struct {
name string
@@ -30,7 +33,7 @@ func TestProvideAppInstallers_Table(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
features := featuremgmt.WithFeatures(tt.flags...)
got := ProvideAppInstallers(features, playlistInstaller, pluginsInstaller, nil, tt.rulesInst)
got := ProvideAppInstallers(features, playlistInstaller, pluginsInstaller, nil, tt.rulesInst, correlationsAppInstaller)
if tt.expectRulesApp {
require.Contains(t, got, tt.rulesInst)
} else {
@@ -0,0 +1,44 @@
package correlations
import (
restclient "k8s.io/client-go/rest"
"github.com/grafana/grafana-app-sdk/app"
appsdkapiserver "github.com/grafana/grafana-app-sdk/k8s/apiserver"
"github.com/grafana/grafana-app-sdk/simple"
"github.com/grafana/grafana/apps/correlations/pkg/apis"
correlationsapp "github.com/grafana/grafana/apps/correlations/pkg/app"
"github.com/grafana/grafana/pkg/services/featuremgmt"
"github.com/grafana/grafana/pkg/setting"
)
var (
_ appsdkapiserver.AppInstaller = (*CorrelationsAppInstaller)(nil)
)
type CorrelationsAppInstaller struct {
appsdkapiserver.AppInstaller
cfg *setting.Cfg
}
func RegisterAppInstaller(
cfg *setting.Cfg,
features featuremgmt.FeatureToggles,
) (*CorrelationsAppInstaller, error) {
installer := &CorrelationsAppInstaller{
cfg: cfg,
}
provider := simple.NewAppProvider(apis.LocalManifest(), nil, correlationsapp.New)
appConfig := app.Config{
KubeConfig: restclient.Config{}, // this will be overridden by the installer's InitializeApp method
ManifestData: *apis.LocalManifest().ManifestData,
}
i, err := appsdkapiserver.NewDefaultAppInstaller(provider, appConfig, &apis.GoTypeAssociator{})
if err != nil {
return nil, err
}
installer.AppInstaller = i
return installer, nil
}
+2
View File
@@ -6,6 +6,7 @@ import (
"github.com/grafana/grafana/pkg/registry/apps/advisor"
"github.com/grafana/grafana/pkg/registry/apps/alerting/notifications"
"github.com/grafana/grafana/pkg/registry/apps/alerting/rules"
"github.com/grafana/grafana/pkg/registry/apps/correlations"
"github.com/grafana/grafana/pkg/registry/apps/investigations"
"github.com/grafana/grafana/pkg/registry/apps/playlist"
"github.com/grafana/grafana/pkg/registry/apps/plugins"
@@ -21,5 +22,6 @@ var WireSet = wire.NewSet(
notifications.RegisterApp,
plugins.RegisterAppInstaller,
shorturl.RegisterAppInstaller,
correlations.RegisterAppInstaller,
rules.RegisterAppInstaller,
)
+11 -2
View File
@@ -82,6 +82,7 @@ import (
advisor2 "github.com/grafana/grafana/pkg/registry/apps/advisor"
notifications2 "github.com/grafana/grafana/pkg/registry/apps/alerting/notifications"
"github.com/grafana/grafana/pkg/registry/apps/alerting/rules"
correlations2 "github.com/grafana/grafana/pkg/registry/apps/correlations"
"github.com/grafana/grafana/pkg/registry/apps/investigations"
"github.com/grafana/grafana/pkg/registry/apps/playlist"
"github.com/grafana/grafana/pkg/registry/apps/plugins"
@@ -760,7 +761,11 @@ func Initialize(ctx context.Context, cfg *setting.Cfg, opts Options, apiOpts api
if err != nil {
return nil, err
}
v2 := appregistry.ProvideAppInstallers(featureToggles, playlistAppInstaller, pluginsAppInstaller, shortURLAppInstaller, alertingRulesAppInstaller)
correlationsAppInstaller, err := correlations2.RegisterAppInstaller(cfg, featureToggles)
if err != nil {
return nil, err
}
v2 := appregistry.ProvideAppInstallers(featureToggles, playlistAppInstaller, pluginsAppInstaller, shortURLAppInstaller, alertingRulesAppInstaller, correlationsAppInstaller)
builderMetrics := builder.ProvideBuilderMetrics(registerer)
apiserverService, err := apiserver.ProvideService(cfg, featureToggles, routeRegisterImpl, tracingService, serverLockService, sqlStore, kvStore, middlewareHandler, scopedPluginDatasourceProvider, plugincontextProvider, pluginstoreService, dualwriteService, resourceClient, inlineSecureValueSupport, eventualRestConfigProvider, v, eventualRestConfigProvider, registerer, aggregatorRunner, v2, builderMetrics)
if err != nil {
@@ -1353,7 +1358,11 @@ func InitializeForTest(ctx context.Context, t sqlutil.ITestDB, testingT interfac
if err != nil {
return nil, err
}
v2 := appregistry.ProvideAppInstallers(featureToggles, playlistAppInstaller, pluginsAppInstaller, shortURLAppInstaller, alertingRulesAppInstaller)
correlationsAppInstaller, err := correlations2.RegisterAppInstaller(cfg, featureToggles)
if err != nil {
return nil, err
}
v2 := appregistry.ProvideAppInstallers(featureToggles, playlistAppInstaller, pluginsAppInstaller, shortURLAppInstaller, alertingRulesAppInstaller, correlationsAppInstaller)
builderMetrics := builder.ProvideBuilderMetrics(registerer)
apiserverService, err := apiserver.ProvideService(cfg, featureToggles, routeRegisterImpl, tracingService, serverLockService, sqlStore, kvStore, middlewareHandler, scopedPluginDatasourceProvider, plugincontextProvider, pluginstoreService, dualwriteService, resourceClient, inlineSecureValueSupport, eventualRestConfigProvider, v, eventualRestConfigProvider, registerer, aggregatorRunner, v2, builderMetrics)
if err != nil {
+7
View File
@@ -483,6 +483,13 @@ var (
Owner: grafanaAlertingSquad,
RequiresRestart: true,
},
{
Name: "kubernetesCorrelations",
Description: "Adds support for Kubernetes correlations",
Stage: FeatureStageExperimental,
Owner: grafanaDataProSquad,
RequiresRestart: true,
},
{
Name: "dashboardDisableSchemaValidationV1",
Description: "Disable schema validation for dashboards/v1",
+1
View File
@@ -62,6 +62,7 @@ kubernetesDashboards,GA,@grafana/dashboards-squad,false,false,true
kubernetesShortURLs,experimental,@grafana/grafana-app-platform-squad,false,true,false
useKubernetesShortURLsAPI,experimental,@grafana/sharing-squad,false,false,true
kubernetesAlertingRules,experimental,@grafana/alerting-squad,false,true,false
kubernetesCorrelations,experimental,@grafana/datapro,false,true,false
dashboardDisableSchemaValidationV1,experimental,@grafana/grafana-app-platform-squad,false,false,false
dashboardDisableSchemaValidationV2,experimental,@grafana/grafana-app-platform-squad,false,false,false
dashboardSchemaValidationLogging,experimental,@grafana/grafana-app-platform-squad,false,false,false
1 Name Stage Owner requiresDevMode RequiresRestart FrontendOnly
62 kubernetesShortURLs experimental @grafana/grafana-app-platform-squad false true false
63 useKubernetesShortURLsAPI experimental @grafana/sharing-squad false false true
64 kubernetesAlertingRules experimental @grafana/alerting-squad false true false
65 kubernetesCorrelations experimental @grafana/datapro false true false
66 dashboardDisableSchemaValidationV1 experimental @grafana/grafana-app-platform-squad false false false
67 dashboardDisableSchemaValidationV2 experimental @grafana/grafana-app-platform-squad false false false
68 dashboardSchemaValidationLogging experimental @grafana/grafana-app-platform-squad false false false
+4
View File
@@ -259,6 +259,10 @@ const (
// Adds support for Kubernetes alerting and recording rules
FlagKubernetesAlertingRules = "kubernetesAlertingRules"
// FlagKubernetesCorrelations
// Adds support for Kubernetes correlations
FlagKubernetesCorrelations = "kubernetesCorrelations"
// FlagDashboardDisableSchemaValidationV1
// Disable schema validation for dashboards/v1
FlagDashboardDisableSchemaValidationV1 = "dashboardDisableSchemaValidationV1"
+13
View File
@@ -2031,6 +2031,19 @@
"hideFromDocs": true
}
},
{
"metadata": {
"name": "kubernetesCorrelations",
"resourceVersion": "1757513374180",
"creationTimestamp": "2025-09-10T14:09:34Z"
},
"spec": {
"description": "Adds support for Kubernetes correlations",
"stage": "experimental",
"codeowner": "@grafana/datapro",
"requiresRestart": true
}
},
{
"metadata": {
"name": "kubernetesDashboards",