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,
)