mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
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:
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user