feat: Add investigations app backend (#98084)

* add initial structure for investigations app backedn

* update version

* Fix codegen & paths

Signed-off-by: Igor Suleymanov <igor.suleymanov@grafana.com>

* Fix Go workspace and CODEOWNERS

Signed-off-by: Igor Suleymanov <igor.suleymanov@grafana.com>

* update kinds for investigation

* update dockerfile

* update codeowners

* update dependabot

* update golangci

* add investigation app and watcher

* run make update-workspace

* run make update-workspace

* register investigation app

* add investigation app to wireset

* add investigations app provider to api initializer

* fix imports

* update feature toggle

* fix cue definition and api initializer

* clean up removing unecessary components

* remove watcher feature toggle

* add investigations backend behind feature toggle

* revert change

---------

Signed-off-by: Igor Suleymanov <igor.suleymanov@grafana.com>
Co-authored-by: Igor Suleymanov <igor.suleymanov@grafana.com>
This commit is contained in:
Jackson Coelho
2024-12-18 10:31:03 +02:00
committed by GitHub
co-authored by Igor Suleymanov
parent e8b6d43110
commit f46c07aba7
30 changed files with 1748 additions and 6 deletions
+14 -2
View File
@@ -5,10 +5,12 @@ import (
"github.com/grafana/grafana/pkg/infra/log"
"github.com/grafana/grafana/pkg/registry"
"github.com/grafana/grafana/pkg/registry/apps/investigation"
"github.com/grafana/grafana/pkg/registry/apps/playlist"
"github.com/grafana/grafana/pkg/services/apiserver"
"github.com/grafana/grafana/pkg/services/apiserver/builder"
"github.com/grafana/grafana/pkg/services/apiserver/builder/runner"
"github.com/grafana/grafana/pkg/services/featuremgmt"
"k8s.io/client-go/rest"
)
@@ -25,7 +27,9 @@ type Service struct {
func ProvideRegistryServiceSink(
registrar builder.APIRegistrar,
restConfigProvider apiserver.RestConfigProvider,
features featuremgmt.FeatureToggles,
playlistAppProvider *playlist.PlaylistAppProvider,
investigationAppProvider *investigation.InvestigationAppProvider,
) (*Service, error) {
cfgWrapper := func(ctx context.Context) *rest.Config {
cfg := restConfigProvider.GetRestConfig(ctx)
@@ -40,11 +44,19 @@ func ProvideRegistryServiceSink(
RestConfigGetter: cfgWrapper,
APIRegistrar: registrar,
}
runner, err := runner.NewAPIGroupRunner(cfg, playlistAppProvider)
var apiGroupRunner *runner.APIGroupRunner
var err error
if features.IsEnabledGlobally(featuremgmt.FlagInvestigationsBackend) {
apiGroupRunner, err = runner.NewAPIGroupRunner(cfg, playlistAppProvider, investigationAppProvider)
} else {
apiGroupRunner, err = runner.NewAPIGroupRunner(cfg, playlistAppProvider)
}
if err != nil {
return nil, err
}
return &Service{runner: runner, log: log.New("app-registry")}, nil
return &Service{runner: apiGroupRunner, log: log.New("app-registry")}, nil
}
func (s *Service) Run(ctx context.Context) error {
@@ -0,0 +1,30 @@
package investigation
import (
"github.com/grafana/grafana-app-sdk/app"
"github.com/grafana/grafana-app-sdk/simple"
"github.com/grafana/grafana/apps/investigation/pkg/apis"
investigationv1alpha1 "github.com/grafana/grafana/apps/investigation/pkg/apis/investigation/v1alpha1"
investigationapp "github.com/grafana/grafana/apps/investigation/pkg/app"
"github.com/grafana/grafana/pkg/services/apiserver/builder/runner"
"github.com/grafana/grafana/pkg/setting"
)
type InvestigationAppProvider struct {
app.Provider
cfg *setting.Cfg
}
func RegisterApp(
cfg *setting.Cfg,
) *InvestigationAppProvider {
provider := &InvestigationAppProvider{
cfg: cfg,
}
appCfg := &runner.AppBuilderConfig{
OpenAPIDefGetter: investigationv1alpha1.GetOpenAPIDefinitions,
ManagedKinds: investigationapp.GetKinds(),
}
provider.Provider = simple.NewAppProvider(apis.LocalManifest(), appCfg, investigationapp.New)
return provider
}
+2
View File
@@ -3,10 +3,12 @@ package appregistry
import (
"github.com/google/wire"
"github.com/grafana/grafana/pkg/registry/apps/investigation"
"github.com/grafana/grafana/pkg/registry/apps/playlist"
)
var WireSet = wire.NewSet(
ProvideRegistryServiceSink,
playlist.RegisterApp,
investigation.RegisterApp,
)
+7
View File
@@ -1696,6 +1696,13 @@ var (
Owner: grafanaObservabilityLogsSquad,
Expression: "true",
},
{
Name: "investigationsBackend",
Description: "Enable the investigations backend API",
Stage: FeatureStageExperimental,
Owner: grafanaAppPlatformSquad,
Expression: "false",
},
}
)
+1
View File
@@ -226,3 +226,4 @@ feedbackButton,experimental,@grafana/grafana-operator-experience-squad,false,fal
elasticsearchCrossClusterSearch,preview,@grafana/aws-datasources,false,false,false
unifiedHistory,experimental,@grafana/grafana-frontend-platform,false,false,true
lokiLabelNamesQueryApi,GA,@grafana/observability-logs,false,false,false
investigationsBackend,experimental,@grafana/grafana-app-platform-squad,false,false,false
1 Name Stage Owner requiresDevMode RequiresRestart FrontendOnly
226 elasticsearchCrossClusterSearch preview @grafana/aws-datasources false false false
227 unifiedHistory experimental @grafana/grafana-frontend-platform false false true
228 lokiLabelNamesQueryApi GA @grafana/observability-logs false false false
229 investigationsBackend experimental @grafana/grafana-app-platform-squad false false false
+4
View File
@@ -914,4 +914,8 @@ const (
// FlagLokiLabelNamesQueryApi
// Defaults to using the Loki `/labels` API instead of `/series`
FlagLokiLabelNamesQueryApi = "lokiLabelNamesQueryApi"
// FlagInvestigationsBackend
// Enable the investigations backend API
FlagInvestigationsBackend = "investigationsBackend"
)
+27
View File
@@ -1832,6 +1832,33 @@
"codeowner": "@grafana/observability-metrics"
}
},
{
"metadata": {
"name": "investigationsBackend",
"resourceVersion": "1734447689720",
"creationTimestamp": "2024-12-17T15:01:29Z"
},
"spec": {
"description": "Enable the investigations backend API",
"stage": "experimental",
"codeowner": "@grafana/grafana-app-platform-squad",
"expression": "false"
}
},
{
"metadata": {
"name": "investigationsWatcher",
"resourceVersion": "1734443690044",
"creationTimestamp": "2024-12-17T13:54:50Z",
"deletionTimestamp": "2024-12-17T14:54:34Z"
},
"spec": {
"description": "Enables experimental watcher for investigations",
"stage": "experimental",
"codeowner": "@grafana/grafana-app-platform-squad",
"requiresRestart": true
}
},
{
"metadata": {
"name": "jaegerBackendMigration",
+4 -3
View File
@@ -21,8 +21,8 @@
// | example-with-style.geojson | application/geo+json | 3332 |
// | usa-states.geojson | application/geo+json | 89263 |
// +----------------------------+----------------------+---------------+
//
//
//
//
// 🌟 This was machine generated. Do not edit. 🌟
{
"status": 200,
@@ -87,4 +87,5 @@
}
}
]
}
}