mirror of
https://github.com/SigNoz/signoz.git
synced 2026-02-13 12:52:55 +00:00
Compare commits
1 Commits
feat/azure
...
test-gener
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c62b4d9141 |
@@ -34,7 +34,7 @@ type awsProvider struct {
|
||||
querier querier.Querier
|
||||
accountsRepo integrationstore.CloudProviderAccountsRepository
|
||||
serviceConfigRepo integrationstore.ServiceConfigDatabase
|
||||
awsServiceDefinitions *services.AWSServicesProvider
|
||||
serviceDefinitions *services.ServicesProvider[*integrationstypes.AWSDefinition]
|
||||
}
|
||||
|
||||
func NewAWSCloudProvider(
|
||||
@@ -43,7 +43,7 @@ func NewAWSCloudProvider(
|
||||
serviceConfigRepo integrationstore.ServiceConfigDatabase,
|
||||
querier querier.Querier,
|
||||
) integrationstypes.CloudProvider {
|
||||
awsServiceDefinitions, err := services.NewAWSCloudProviderServices()
|
||||
serviceDefinitions, err := services.NewAWSCloudProviderServices()
|
||||
if err != nil {
|
||||
panic("failed to initialize AWS service definitions: " + err.Error())
|
||||
}
|
||||
@@ -53,7 +53,7 @@ func NewAWSCloudProvider(
|
||||
querier: querier,
|
||||
accountsRepo: accountsRepo,
|
||||
serviceConfigRepo: serviceConfigRepo,
|
||||
awsServiceDefinitions: awsServiceDefinitions,
|
||||
serviceDefinitions: serviceDefinitions,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,10 +139,8 @@ func (a *awsProvider) getAWSAgentConfig(ctx context.Context, account *integratio
|
||||
agentConfig := &integrationstypes.AWSAgentIntegrationConfig{
|
||||
EnabledRegions: []string{},
|
||||
TelemetryCollectionStrategy: &integrationstypes.AWSCollectionStrategy{
|
||||
Provider: a.GetName(),
|
||||
AWSMetrics: &integrationstypes.AWSMetricsStrategy{},
|
||||
AWSLogs: &integrationstypes.AWSLogsStrategy{},
|
||||
S3Buckets: map[string][]string{},
|
||||
Metrics: &integrationstypes.AWSMetricsStrategy{},
|
||||
Logs: &integrationstypes.AWSLogsStrategy{},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -152,7 +150,7 @@ func (a *awsProvider) getAWSAgentConfig(ctx context.Context, account *integratio
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if accountConfig != nil && accountConfig.EnabledRegions != nil {
|
||||
if accountConfig.EnabledRegions != nil {
|
||||
agentConfig.EnabledRegions = accountConfig.EnabledRegions
|
||||
}
|
||||
|
||||
@@ -168,7 +166,7 @@ func (a *awsProvider) getAWSAgentConfig(ctx context.Context, account *integratio
|
||||
slices.Sort(configuredServices)
|
||||
|
||||
for _, svcType := range configuredServices {
|
||||
definition, err := a.awsServiceDefinitions.GetServiceDefinition(ctx, svcType)
|
||||
definition, err := a.serviceDefinitions.GetServiceDefinition(ctx, svcType)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
@@ -185,18 +183,18 @@ func (a *awsProvider) getAWSAgentConfig(ctx context.Context, account *integratio
|
||||
// S3 bucket sync; No cloudwatch logs are appended for this service type;
|
||||
// Though definition is populated with a custom cloudwatch group that helps in calculating logs connection status
|
||||
agentConfig.TelemetryCollectionStrategy.S3Buckets = serviceConfig.Logs.S3Buckets
|
||||
} else if definition.Strategy.AWSLogs != nil { // services that includes a logs subscription
|
||||
agentConfig.TelemetryCollectionStrategy.AWSLogs.Subscriptions = append(
|
||||
agentConfig.TelemetryCollectionStrategy.AWSLogs.Subscriptions,
|
||||
definition.Strategy.AWSLogs.Subscriptions...,
|
||||
} else if definition.Strategy != nil && definition.Strategy.Logs != nil { // services that includes a logs subscription
|
||||
agentConfig.TelemetryCollectionStrategy.Logs.Subscriptions = append(
|
||||
agentConfig.TelemetryCollectionStrategy.Logs.Subscriptions,
|
||||
definition.Strategy.Logs.Subscriptions...,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if serviceConfig.Metrics != nil && serviceConfig.Metrics.Enabled && definition.Strategy.AWSMetrics != nil {
|
||||
agentConfig.TelemetryCollectionStrategy.AWSMetrics.StreamFilters = append(
|
||||
agentConfig.TelemetryCollectionStrategy.AWSMetrics.StreamFilters,
|
||||
definition.Strategy.AWSMetrics.StreamFilters...,
|
||||
if serviceConfig.Metrics != nil && serviceConfig.Metrics.Enabled && definition.Strategy != nil && definition.Strategy.Metrics != nil {
|
||||
agentConfig.TelemetryCollectionStrategy.Metrics.StreamFilters = append(
|
||||
agentConfig.TelemetryCollectionStrategy.Metrics.StreamFilters,
|
||||
definition.Strategy.Metrics.StreamFilters...,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -233,7 +231,7 @@ func (a *awsProvider) ListServices(ctx context.Context, orgID string, cloudAccou
|
||||
|
||||
summaries := make([]integrationstypes.AWSServiceSummary, 0)
|
||||
|
||||
definitions, err := a.awsServiceDefinitions.ListServiceDefinitions(ctx)
|
||||
definitions, err := a.serviceDefinitions.ListServiceDefinitions(ctx)
|
||||
if err != nil {
|
||||
return nil, model.InternalError(fmt.Errorf("couldn't list aws service definitions: %w", err))
|
||||
}
|
||||
@@ -261,18 +259,17 @@ func (a *awsProvider) ListServices(ctx context.Context, orgID string, cloudAccou
|
||||
func (a *awsProvider) GetServiceDetails(ctx context.Context, req *integrationstypes.GetServiceDetailsReq) (any, error) {
|
||||
details := new(integrationstypes.GettableAWSServiceDetails)
|
||||
|
||||
awsDefinition, err := a.awsServiceDefinitions.GetServiceDefinition(ctx, req.ServiceId)
|
||||
awsDefinition, err := a.serviceDefinitions.GetServiceDefinition(ctx, req.ServiceId)
|
||||
if err != nil {
|
||||
return nil, model.InternalError(fmt.Errorf("couldn't get aws service definition: %w", err))
|
||||
}
|
||||
|
||||
details.AWSServiceDefinition = *awsDefinition
|
||||
details.Strategy.Provider = a.GetName()
|
||||
details.AWSDefinition = *awsDefinition
|
||||
if req.CloudAccountID == nil {
|
||||
return details, nil
|
||||
}
|
||||
|
||||
config, err := a.getServiceConfig(ctx, &details.AWSServiceDefinition, req.OrgID, a.GetName().String(), req.ServiceId, *req.CloudAccountID)
|
||||
config, err := a.getServiceConfig(ctx, &details.AWSDefinition, req.OrgID, a.GetName().String(), req.ServiceId, *req.CloudAccountID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -287,7 +284,7 @@ func (a *awsProvider) GetServiceDetails(ctx context.Context, req *integrationsty
|
||||
ctx,
|
||||
*req.CloudAccountID,
|
||||
req.OrgID,
|
||||
&details.AWSServiceDefinition,
|
||||
&details.AWSDefinition,
|
||||
config,
|
||||
)
|
||||
if err != nil {
|
||||
@@ -303,7 +300,7 @@ func (a *awsProvider) getServiceConnectionStatus(
|
||||
ctx context.Context,
|
||||
cloudAccountID string,
|
||||
orgID valuer.UUID,
|
||||
def *integrationstypes.AWSServiceDefinition,
|
||||
def *integrationstypes.AWSDefinition,
|
||||
serviceConfig *integrationstypes.AWSCloudServiceConfig,
|
||||
) (*integrationstypes.ServiceConnectionStatus, error) {
|
||||
if def.Strategy == nil {
|
||||
@@ -315,7 +312,7 @@ func (a *awsProvider) getServiceConnectionStatus(
|
||||
wg := sync.WaitGroup{}
|
||||
wg.Add(2)
|
||||
|
||||
if def.Strategy.AWSMetrics != nil && serviceConfig.Metrics.Enabled {
|
||||
if def.Strategy.Metrics != nil && serviceConfig.Metrics != nil && serviceConfig.Metrics.Enabled {
|
||||
go func() {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
@@ -332,7 +329,7 @@ func (a *awsProvider) getServiceConnectionStatus(
|
||||
}()
|
||||
}
|
||||
|
||||
if def.Strategy.AWSLogs != nil && serviceConfig.Logs.Enabled {
|
||||
if def.Strategy.Logs != nil && serviceConfig.Logs != nil && serviceConfig.Logs.Enabled {
|
||||
go func() {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
@@ -358,10 +355,11 @@ func (a *awsProvider) getServiceMetricsConnectionStatus(
|
||||
ctx context.Context,
|
||||
cloudAccountID string,
|
||||
orgID valuer.UUID,
|
||||
def *integrationstypes.AWSServiceDefinition,
|
||||
def *integrationstypes.AWSDefinition,
|
||||
) ([]*integrationstypes.SignalConnectionStatus, error) {
|
||||
if def.Strategy == nil ||
|
||||
len(def.Strategy.AWSMetrics.StreamFilters) < 1 ||
|
||||
def.Strategy.Metrics == nil ||
|
||||
len(def.Strategy.Metrics.StreamFilters) < 1 ||
|
||||
len(def.DataCollected.Metrics) < 1 {
|
||||
return nil, nil
|
||||
}
|
||||
@@ -449,10 +447,11 @@ func (a *awsProvider) getServiceLogsConnectionStatus(
|
||||
ctx context.Context,
|
||||
cloudAccountID string,
|
||||
orgID valuer.UUID,
|
||||
def *integrationstypes.AWSServiceDefinition,
|
||||
def *integrationstypes.AWSDefinition,
|
||||
) ([]*integrationstypes.SignalConnectionStatus, error) {
|
||||
if def.Strategy == nil ||
|
||||
len(def.Strategy.AWSLogs.Subscriptions) < 1 ||
|
||||
def.Strategy.Logs == nil ||
|
||||
len(def.Strategy.Logs.Subscriptions) < 1 ||
|
||||
len(def.DataCollected.Logs) < 1 {
|
||||
return nil, nil
|
||||
}
|
||||
@@ -536,8 +535,10 @@ func (a *awsProvider) getServiceLogsConnectionStatus(
|
||||
return statusResp, nil
|
||||
}
|
||||
|
||||
func (a *awsProvider) getServiceConfig(ctx context.Context,
|
||||
def *integrationstypes.AWSServiceDefinition, orgID valuer.UUID, cloudProvider, serviceId, cloudAccountId string,
|
||||
func (a *awsProvider) getServiceConfig(
|
||||
ctx context.Context,
|
||||
def *integrationstypes.AWSDefinition,
|
||||
orgID valuer.UUID, cloudProvider, serviceId, cloudAccountId string,
|
||||
) (*integrationstypes.AWSCloudServiceConfig, error) {
|
||||
activeAccount, err := a.accountsRepo.GetConnectedCloudAccount(ctx, orgID.String(), cloudProvider, cloudAccountId)
|
||||
if err != nil {
|
||||
@@ -560,7 +561,7 @@ func (a *awsProvider) getServiceConfig(ctx context.Context,
|
||||
}
|
||||
|
||||
if config != nil && serviceConfig.Metrics != nil && serviceConfig.Metrics.Enabled {
|
||||
def.PopulateDashboardURLs(serviceId)
|
||||
def.PopulateDashboardURLs(a.GetName(), serviceId)
|
||||
}
|
||||
|
||||
return serviceConfig, nil
|
||||
@@ -598,7 +599,7 @@ func (a *awsProvider) GetAvailableDashboards(ctx context.Context, orgID valuer.U
|
||||
|
||||
svcDashboards := make([]*dashboardtypes.Dashboard, 0)
|
||||
|
||||
allServices, err := a.awsServiceDefinitions.ListServiceDefinitions(ctx)
|
||||
allServices, err := a.serviceDefinitions.ListServiceDefinitions(ctx)
|
||||
if err != nil {
|
||||
return nil, errors.WrapInternalf(err, errors.CodeInternal, "failed to list aws service definitions")
|
||||
}
|
||||
@@ -692,7 +693,7 @@ func (a *awsProvider) GenerateConnectionArtifact(ctx context.Context, req *integ
|
||||
}
|
||||
|
||||
func (a *awsProvider) UpdateServiceConfig(ctx context.Context, req *integrationstypes.PatchableServiceConfig) (any, error) {
|
||||
definition, err := a.awsServiceDefinitions.GetServiceDefinition(ctx, req.ServiceId)
|
||||
definition, err := a.serviceDefinitions.GetServiceDefinition(ctx, req.ServiceId)
|
||||
if err != nil {
|
||||
return nil, model.InternalError(fmt.Errorf("couldn't get aws service definition: %w", err))
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ type azureProvider struct {
|
||||
logger *slog.Logger
|
||||
accountsRepo store.CloudProviderAccountsRepository
|
||||
serviceConfigRepo store.ServiceConfigDatabase
|
||||
azureServiceDefinitions *services.AzureServicesProvider
|
||||
azureServiceDefinitions *services.ServicesProvider[*integrationstypes.AzureDefinition]
|
||||
querier querier.Querier
|
||||
}
|
||||
|
||||
@@ -176,12 +176,16 @@ func (a *azureProvider) getAzureAgentConfig(ctx context.Context, account *integr
|
||||
metricsStrategyMap := make(map[string]*integrationstypes.AzureMetricsStrategy)
|
||||
logsStrategyMap := make(map[string]*integrationstypes.AzureLogsStrategy)
|
||||
|
||||
for _, metric := range definition.Strategy.AzureMetrics {
|
||||
metricsStrategyMap[metric.Name] = metric
|
||||
if definition.Strategy != nil && definition.Strategy.Metrics != nil {
|
||||
for _, metric := range definition.Strategy.Metrics {
|
||||
metricsStrategyMap[metric.Name] = metric
|
||||
}
|
||||
}
|
||||
|
||||
for _, log := range definition.Strategy.AzureLogs {
|
||||
logsStrategyMap[log.Name] = log
|
||||
if definition.Strategy != nil && definition.Strategy.Logs != nil {
|
||||
for _, log := range definition.Strategy.Logs {
|
||||
logsStrategyMap[log.Name] = log
|
||||
}
|
||||
}
|
||||
|
||||
if serviceConfig.Metrics != nil {
|
||||
@@ -206,12 +210,12 @@ func (a *azureProvider) getAzureAgentConfig(ctx context.Context, account *integr
|
||||
}
|
||||
}
|
||||
|
||||
strategy := integrationstypes.AzureCollectionStrategy{}
|
||||
strategy := &integrationstypes.AzureCollectionStrategy{
|
||||
Metrics: metrics,
|
||||
Logs: logs,
|
||||
}
|
||||
|
||||
strategy.AzureMetrics = metrics
|
||||
strategy.AzureLogs = logs
|
||||
|
||||
agentConfig.TelemetryCollectionStrategy[svcType] = &strategy
|
||||
agentConfig.TelemetryCollectionStrategy[svcType] = strategy
|
||||
}
|
||||
|
||||
return agentConfig, nil
|
||||
@@ -279,12 +283,12 @@ func (a *azureProvider) GetServiceDetails(ctx context.Context, req *integrations
|
||||
return nil, model.InternalError(fmt.Errorf("couldn't get aws service definition: %w", err))
|
||||
}
|
||||
|
||||
details.AzureServiceDefinition = *azureDefinition
|
||||
details.AzureDefinition = *azureDefinition
|
||||
if req.CloudAccountID == nil {
|
||||
return details, nil
|
||||
}
|
||||
|
||||
config, err := a.getServiceConfig(ctx, &details.AzureServiceDefinition, req.OrgID.String(), req.ServiceId, *req.CloudAccountID)
|
||||
config, err := a.getServiceConfig(ctx, azureDefinition, req.OrgID.String(), req.ServiceId, *req.CloudAccountID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -296,19 +300,23 @@ func (a *azureProvider) GetServiceDetails(ctx context.Context, req *integrations
|
||||
cfg := new(integrationstypes.AzureCloudServiceConfig)
|
||||
|
||||
logs := make([]*integrationstypes.AzureCloudServiceLogsConfig, 0)
|
||||
for _, log := range azureDefinition.Strategy.AzureLogs {
|
||||
logs = append(logs, &integrationstypes.AzureCloudServiceLogsConfig{
|
||||
Enabled: false,
|
||||
Name: log.Name,
|
||||
})
|
||||
if azureDefinition.Strategy != nil && azureDefinition.Strategy.Logs != nil {
|
||||
for _, log := range azureDefinition.Strategy.Logs {
|
||||
logs = append(logs, &integrationstypes.AzureCloudServiceLogsConfig{
|
||||
Enabled: false,
|
||||
Name: log.Name,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
metrics := make([]*integrationstypes.AzureCloudServiceMetricsConfig, 0)
|
||||
for _, metric := range azureDefinition.Strategy.AzureMetrics {
|
||||
metrics = append(metrics, &integrationstypes.AzureCloudServiceMetricsConfig{
|
||||
Enabled: false,
|
||||
Name: metric.Name,
|
||||
})
|
||||
if azureDefinition.Strategy != nil && azureDefinition.Strategy.Metrics != nil {
|
||||
for _, metric := range azureDefinition.Strategy.Metrics {
|
||||
metrics = append(metrics, &integrationstypes.AzureCloudServiceMetricsConfig{
|
||||
Enabled: false,
|
||||
Name: metric.Name,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
cfg.Logs = logs
|
||||
@@ -324,7 +332,7 @@ func (a *azureProvider) GetServiceDetails(ctx context.Context, req *integrations
|
||||
|
||||
func (a *azureProvider) getServiceConfig(
|
||||
ctx context.Context,
|
||||
definition *integrationstypes.AzureServiceDefinition,
|
||||
definition *integrationstypes.AzureDefinition,
|
||||
orgID string,
|
||||
serviceId string,
|
||||
cloudAccountId string,
|
||||
@@ -350,7 +358,7 @@ func (a *azureProvider) getServiceConfig(
|
||||
|
||||
for _, metric := range config.Metrics {
|
||||
if metric.Enabled {
|
||||
definition.PopulateDashboardURLs(serviceId)
|
||||
definition.PopulateDashboardURLs(a.GetName(), serviceId)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,77 +20,59 @@ var (
|
||||
CodeServiceDefinitionNotFound = errors.MustNewCode("service_definition_not_dound")
|
||||
)
|
||||
|
||||
type (
|
||||
AWSServicesProvider struct {
|
||||
definitions map[string]*integrationstypes.AWSServiceDefinition
|
||||
}
|
||||
AzureServicesProvider struct {
|
||||
definitions map[string]*integrationstypes.AzureServiceDefinition
|
||||
}
|
||||
)
|
||||
type ServicesProvider[T integrationstypes.Definition] struct {
|
||||
definitions map[string]T
|
||||
}
|
||||
|
||||
func (a *AzureServicesProvider) ListServiceDefinitions(ctx context.Context) (map[string]*integrationstypes.AzureServiceDefinition, error) {
|
||||
func (a *ServicesProvider[T]) ListServiceDefinitions(ctx context.Context) (map[string]T, error) {
|
||||
return a.definitions, nil
|
||||
}
|
||||
|
||||
func (a *AzureServicesProvider) GetServiceDefinition(ctx context.Context, serviceName string) (*integrationstypes.AzureServiceDefinition, error) {
|
||||
func (a *ServicesProvider[T]) GetServiceDefinition(ctx context.Context, serviceName string) (T, error) {
|
||||
def, ok := a.definitions[serviceName]
|
||||
if !ok {
|
||||
return nil, errors.NewNotFoundf(CodeServiceDefinitionNotFound, "azure service definition not found: %s", serviceName)
|
||||
return *new(T), errors.NewNotFoundf(CodeServiceDefinitionNotFound, "azure service definition not found: %s", serviceName)
|
||||
}
|
||||
|
||||
return def, nil
|
||||
}
|
||||
|
||||
func (a *AWSServicesProvider) ListServiceDefinitions(ctx context.Context) (map[string]*integrationstypes.AWSServiceDefinition, error) {
|
||||
return a.definitions, nil
|
||||
}
|
||||
|
||||
func (a *AWSServicesProvider) GetServiceDefinition(ctx context.Context, serviceName string) (*integrationstypes.AWSServiceDefinition, error) {
|
||||
def, ok := a.definitions[serviceName]
|
||||
if !ok {
|
||||
return nil, errors.NewNotFoundf(CodeServiceDefinitionNotFound, "aws service definition not found: %s", serviceName)
|
||||
}
|
||||
|
||||
return def, nil
|
||||
}
|
||||
|
||||
func NewAWSCloudProviderServices() (*AWSServicesProvider, error) {
|
||||
func NewAWSCloudProviderServices() (*ServicesProvider[*integrationstypes.AWSDefinition], error) {
|
||||
definitions, err := readAllServiceDefinitions(integrationstypes.CloudProviderAWS)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
serviceDefinitions := make(map[string]*integrationstypes.AWSServiceDefinition)
|
||||
serviceDefinitions := make(map[string]*integrationstypes.AWSDefinition)
|
||||
for id, def := range definitions {
|
||||
typedDef, ok := def.(*integrationstypes.AWSServiceDefinition)
|
||||
typedDef, ok := def.(*integrationstypes.AWSDefinition)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("invalid type for AWS service definition %s", id)
|
||||
}
|
||||
serviceDefinitions[id] = typedDef
|
||||
}
|
||||
|
||||
return &AWSServicesProvider{
|
||||
return &ServicesProvider[*integrationstypes.AWSDefinition]{
|
||||
definitions: serviceDefinitions,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func NewAzureCloudProviderServices() (*AzureServicesProvider, error) {
|
||||
func NewAzureCloudProviderServices() (*ServicesProvider[*integrationstypes.AzureDefinition], error) {
|
||||
definitions, err := readAllServiceDefinitions(integrationstypes.CloudProviderAzure)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
serviceDefinitions := make(map[string]*integrationstypes.AzureServiceDefinition)
|
||||
serviceDefinitions := make(map[string]*integrationstypes.AzureDefinition)
|
||||
for id, def := range definitions {
|
||||
typedDef, ok := def.(*integrationstypes.AzureServiceDefinition)
|
||||
typedDef, ok := def.(*integrationstypes.AzureDefinition)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("invalid type for Azure service definition %s", id)
|
||||
}
|
||||
serviceDefinitions[id] = typedDef
|
||||
}
|
||||
|
||||
return &AzureServicesProvider{
|
||||
return &ServicesProvider[*integrationstypes.AzureDefinition]{
|
||||
definitions: serviceDefinitions,
|
||||
}, nil
|
||||
}
|
||||
@@ -169,9 +151,9 @@ func readServiceDefinition(cloudProvider valuer.String, svcDirpath string) (inte
|
||||
|
||||
switch cloudProvider {
|
||||
case integrationstypes.CloudProviderAWS:
|
||||
serviceDef = &integrationstypes.AWSServiceDefinition{}
|
||||
serviceDef = &integrationstypes.AWSDefinition{}
|
||||
case integrationstypes.CloudProviderAzure:
|
||||
serviceDef = &integrationstypes.AzureServiceDefinition{}
|
||||
serviceDef = &integrationstypes.AzureDefinition{}
|
||||
default:
|
||||
// ideally this shouldn't happen hence throwing internal error
|
||||
return nil, errors.NewInternalf(errors.CodeInternal, "unsupported cloud provider: %s", cloudProvider)
|
||||
|
||||
@@ -194,7 +194,7 @@ type GettableAWSAgentCheckIn struct {
|
||||
}
|
||||
|
||||
type AWSAgentIntegrationConfig struct {
|
||||
EnabledRegions []string `json:"enabled_regions"`
|
||||
EnabledRegions []string `json:"enabled_regions"`
|
||||
TelemetryCollectionStrategy *AWSCollectionStrategy `json:"telemetry,omitempty"`
|
||||
}
|
||||
|
||||
@@ -274,7 +274,7 @@ func (a *AWSCloudServiceConfig) Marshal() ([]byte, error) {
|
||||
return serialized, nil
|
||||
}
|
||||
|
||||
func (a *AWSCloudServiceConfig) Validate(def *AWSServiceDefinition) error {
|
||||
func (a *AWSCloudServiceConfig) Validate(def *AWSDefinition) error {
|
||||
if def.Id != S3Sync && a.Logs != nil && a.Logs.S3Buckets != nil {
|
||||
return errors.NewInvalidInputf(errors.CodeInvalidInput, "s3 buckets can only be added to service-type[%s]", S3Sync)
|
||||
} else if def.Id == S3Sync && a.Logs != nil && a.Logs.S3Buckets != nil {
|
||||
@@ -288,16 +288,20 @@ func (a *AWSCloudServiceConfig) Validate(def *AWSServiceDefinition) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *AzureCloudServiceConfig) Validate(def *AzureServiceDefinition) error {
|
||||
func (a *AzureCloudServiceConfig) Validate(def *AzureDefinition) error {
|
||||
logsMap := make(map[string]bool)
|
||||
metricsMap := make(map[string]bool)
|
||||
|
||||
for _, log := range def.Strategy.AzureLogs {
|
||||
logsMap[log.Name] = true
|
||||
if def.Strategy != nil && def.Strategy.Logs != nil {
|
||||
for _, log := range def.Strategy.Logs {
|
||||
logsMap[log.Name] = true
|
||||
}
|
||||
}
|
||||
|
||||
for _, metric := range def.Strategy.AzureMetrics {
|
||||
metricsMap[metric.Name] = true
|
||||
if def.Strategy != nil && def.Strategy.Metrics != nil {
|
||||
for _, metric := range def.Strategy.Metrics {
|
||||
metricsMap[metric.Name] = true
|
||||
}
|
||||
}
|
||||
|
||||
for _, log := range a.Logs {
|
||||
@@ -623,13 +627,13 @@ type AzureServiceSummary struct {
|
||||
}
|
||||
|
||||
type GettableAWSServiceDetails struct {
|
||||
AWSServiceDefinition
|
||||
AWSDefinition
|
||||
Config *AWSCloudServiceConfig `json:"config"`
|
||||
ConnectionStatus *ServiceConnectionStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
type GettableAzureServiceDetails struct {
|
||||
AzureServiceDefinition
|
||||
AzureDefinition
|
||||
Config *AzureCloudServiceConfig `json:"config"`
|
||||
ConnectionStatus *ServiceConnectionStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
@@ -14,6 +14,51 @@ const (
|
||||
S3Sync = "s3sync"
|
||||
)
|
||||
|
||||
type AWSDefinition = ServiceDefinition[AWSCollectionStrategy]
|
||||
type AzureDefinition = ServiceDefinition[AzureCollectionStrategy]
|
||||
|
||||
var _ Definition = &AWSDefinition{}
|
||||
var _ Definition = &AzureDefinition{}
|
||||
|
||||
type ServiceDefinition[T any] struct {
|
||||
DefinitionMetadata
|
||||
Overview string `json:"overview"` // markdown
|
||||
Assets Assets `json:"assets"`
|
||||
SupportedSignals SupportedSignals `json:"supported_signals"`
|
||||
DataCollected DataCollected `json:"data_collected"`
|
||||
IngestionStatusCheck *IngestionStatusCheck `json:"ingestion_status_check,omitempty"`
|
||||
Strategy *T `json:"telemetry_collection_strategy"`
|
||||
}
|
||||
|
||||
func (def *ServiceDefinition[T]) PopulateDashboardURLs(cloudProvider CloudProviderType, svcId string) {
|
||||
for i := range def.Assets.Dashboards {
|
||||
dashboardId := def.Assets.Dashboards[i].Id
|
||||
url := "/dashboard/" + GetCloudIntegrationDashboardID(cloudProvider, svcId, dashboardId)
|
||||
def.Assets.Dashboards[i].Url = url
|
||||
}
|
||||
}
|
||||
|
||||
func (def *ServiceDefinition[T]) GetId() string {
|
||||
return def.Id
|
||||
}
|
||||
|
||||
func (def *ServiceDefinition[T]) Validate() error {
|
||||
seenDashboardIds := map[string]interface{}{}
|
||||
|
||||
if def.Strategy == nil {
|
||||
return errors.NewInternalf(errors.CodeInternal, "telemetry_collection_strategy is required")
|
||||
}
|
||||
|
||||
for _, dd := range def.Assets.Dashboards {
|
||||
if _, seen := seenDashboardIds[dd.Id]; seen {
|
||||
return errors.NewInternalf(errors.CodeInternal, "multiple dashboards found with id %s for Azure Integration", dd.Id)
|
||||
}
|
||||
seenDashboardIds[dd.Id] = nil
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type DefinitionMetadata struct {
|
||||
Id string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
@@ -23,20 +68,7 @@ type DefinitionMetadata struct {
|
||||
type Definition interface {
|
||||
GetId() string
|
||||
Validate() error
|
||||
PopulateDashboardURLs(svcId string)
|
||||
}
|
||||
|
||||
var _ Definition = &AWSServiceDefinition{}
|
||||
var _ Definition = &AzureServiceDefinition{}
|
||||
|
||||
type AWSServiceDefinition struct {
|
||||
DefinitionMetadata
|
||||
Overview string `json:"overview"` // markdown
|
||||
Assets Assets `json:"assets"`
|
||||
SupportedSignals SupportedSignals `json:"supported_signals"`
|
||||
DataCollected DataCollected `json:"data_collected"`
|
||||
Strategy *AWSCollectionStrategy `json:"telemetry_collection_strategy"`
|
||||
IngestionStatusCheck *IngestionStatusCheck `json:"ingestion_status_check"`
|
||||
PopulateDashboardURLs(cloudProvider CloudProviderType, svcId string)
|
||||
}
|
||||
|
||||
type IngestionStatusCheck struct {
|
||||
@@ -60,79 +92,6 @@ type IngestionStatusCheckAttributeFilter struct {
|
||||
Operator string `json:"operator"`
|
||||
Value string `json:"value"`
|
||||
}
|
||||
|
||||
func (def *AWSServiceDefinition) GetId() string {
|
||||
return def.Id
|
||||
}
|
||||
|
||||
func (def *AWSServiceDefinition) Validate() error {
|
||||
seenDashboardIds := map[string]interface{}{}
|
||||
|
||||
if def.Strategy == nil {
|
||||
return errors.NewInternalf(errors.CodeInternal, "telemetry_collection_strategy is required")
|
||||
}
|
||||
|
||||
for _, dd := range def.Assets.Dashboards {
|
||||
if _, seen := seenDashboardIds[dd.Id]; seen {
|
||||
return errors.NewInternalf(errors.CodeInternal, "multiple dashboards found with id %s for AWS Integration", dd.Id)
|
||||
}
|
||||
seenDashboardIds[dd.Id] = nil
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (def *AWSServiceDefinition) PopulateDashboardURLs(serviceId string) {
|
||||
for i := range def.Assets.Dashboards {
|
||||
dashboardId := def.Assets.Dashboards[i].Id
|
||||
url := "/dashboard/" + GetCloudIntegrationDashboardID(CloudProviderAWS, serviceId, dashboardId)
|
||||
def.Assets.Dashboards[i].Url = url
|
||||
}
|
||||
}
|
||||
|
||||
type AzureServiceDefinition struct {
|
||||
DefinitionMetadata
|
||||
|
||||
Overview string `json:"overview"` // markdown
|
||||
|
||||
Assets Assets `json:"assets"`
|
||||
|
||||
SupportedSignals SupportedSignals `json:"supported_signals"`
|
||||
|
||||
DataCollected DataCollected `json:"data_collected"`
|
||||
|
||||
Strategy *AzureCollectionStrategy `json:"telemetry_collection_strategy"`
|
||||
}
|
||||
|
||||
func (def *AzureServiceDefinition) PopulateDashboardURLs(svcId string) {
|
||||
for i := range def.Assets.Dashboards {
|
||||
dashboardId := def.Assets.Dashboards[i].Id
|
||||
url := "/dashboard/" + GetCloudIntegrationDashboardID(CloudProviderAzure, svcId, dashboardId)
|
||||
def.Assets.Dashboards[i].Url = url
|
||||
}
|
||||
}
|
||||
|
||||
func (def *AzureServiceDefinition) GetId() string {
|
||||
return def.Id
|
||||
}
|
||||
|
||||
func (def *AzureServiceDefinition) Validate() error {
|
||||
seenDashboardIds := map[string]interface{}{}
|
||||
|
||||
if def.Strategy == nil {
|
||||
return errors.NewInternalf(errors.CodeInternal, "telemetry_collection_strategy is required")
|
||||
}
|
||||
|
||||
for _, dd := range def.Assets.Dashboards {
|
||||
if _, seen := seenDashboardIds[dd.Id]; seen {
|
||||
return errors.NewInternalf(errors.CodeInternal, "multiple dashboards found with id %s for Azure Integration", dd.Id)
|
||||
}
|
||||
seenDashboardIds[dd.Id] = nil
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type Assets struct {
|
||||
Dashboards []Dashboard `json:"dashboards"`
|
||||
}
|
||||
@@ -160,19 +119,14 @@ type CollectedMetric struct {
|
||||
Description string `json:"description"`
|
||||
}
|
||||
|
||||
type AWSCollectionStrategy struct {
|
||||
Provider valuer.String `json:"provider"`
|
||||
|
||||
AWSMetrics *AWSMetricsStrategy `json:"aws_metrics,omitempty"`
|
||||
AWSLogs *AWSLogsStrategy `json:"aws_logs,omitempty"`
|
||||
S3Buckets map[string][]string `json:"s3_buckets,omitempty"` // Only available in S3 Sync Service Type
|
||||
}
|
||||
|
||||
type AzureCollectionStrategy struct {
|
||||
AzureMetrics []*AzureMetricsStrategy `json:"azure_metrics"`
|
||||
AzureLogs []*AzureLogsStrategy `json:"azure_logs"`
|
||||
type CollectionStrategy[MetricsStrategy any, LogsStrategy any] struct {
|
||||
Metrics MetricsStrategy `json:"metrics,omitempty"`
|
||||
Logs LogsStrategy `json:"logs,omitempty"`
|
||||
S3Buckets map[string][]string `json:"s3_buckets,omitempty"` // Only available in S3 Sync Service Type in AWS
|
||||
}
|
||||
|
||||
type AzureCollectionStrategy = CollectionStrategy[[]*AzureMetricsStrategy, []*AzureLogsStrategy]
|
||||
type AWSCollectionStrategy = CollectionStrategy[*AWSMetricsStrategy, *AWSLogsStrategy]
|
||||
type AzureResourceGroup struct {
|
||||
Name string `json:"name"`
|
||||
Region string `json:"region"`
|
||||
|
||||
Reference in New Issue
Block a user