Glue: Add DB migration & support provisioning for user-defined correlations config (#55560)

* Allow provisioning correlation config

* Simplify code

* Fix reading correlations test

* Fix linting errors

* Fix linting errors

* remove simpleJson

* Clean up

* Fix tests

* Update swagger docs

* Fix linting

* Fix linting

* Clean up swagger definitions

Co-authored-by: Elfo404 <me@giordanoricci.com>
This commit is contained in:
Piotr Jamróz
2022-09-27 11:08:02 +02:00
committed by GitHub
parent a49fcbdbbc
commit becdf10f0e
10 changed files with 207 additions and 8 deletions

View File

@@ -16,6 +16,7 @@ func (s CorrelationsService) createCorrelation(ctx context.Context, cmd CreateCo
TargetUID: cmd.TargetUID,
Label: cmd.Label,
Description: cmd.Description,
Config: cmd.Config,
}
err := s.SQLStore.WithTransactionalDbSession(ctx, func(session *sqlstore.DBSession) error {

View File

@@ -13,7 +13,22 @@ var (
ErrUpdateCorrelationEmptyParams = errors.New("not enough parameters to edit correlation")
)
// CorrelationConfigTarget is the target data query specific to target data source (Correlation.TargetUID)
// swagger:model
type CorrelationConfigTarget struct{}
// swagger:model
type CorrelationConfig struct {
// Field used to attach the correlation link
// required:true
Field string `json:"field"`
// Target data query
// required:true
Target CorrelationConfigTarget `json:"target"`
}
// Correlation is the model for correlations definitions
// swagger:model
type Correlation struct {
// Unique identifier of the correlation
// example: 50xhMlg9k
@@ -30,6 +45,9 @@ type Correlation struct {
// Description of the correlation
// example: Logs to Traces
Description string `json:"description" xorm:"description"`
// Correlation Configuration
// example: { field: "job", target: { query: "job=app" } }
Config CorrelationConfig `json:"config" xorm:"jsonb config"`
}
// CreateCorrelationResponse is the response struct for CreateCorrelationCommand
@@ -56,6 +74,9 @@ type CreateCorrelationCommand struct {
// Optional description of the correlation
// example: Logs to Traces
Description string `json:"description"`
// Arbitrary configuration object handled in frontend
// example: { field: "job", target: { query: "job=app" } }
Config CorrelationConfig `json:"config"`
}
// swagger:model