correlations

package
v11.1.4-modfix Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 20, 2024 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	QuotaTargetSrv quota.TargetSrv = "correlations"
	QuotaTarget    quota.Target    = "correlations"
)

Variables

View Source
var (
	ErrCorrelationReadOnly           = errors.New("correlation can only be edited via provisioning")
	ErrSourceDataSourceDoesNotExists = errors.New("source data source does not exist")
	ErrTargetDataSourceDoesNotExists = errors.New("target data source does not exist")
	ErrCorrelationNotFound           = errors.New("correlation not found")
	ErrUpdateCorrelationEmptyParams  = errors.New("not enough parameters to edit correlation")
	ErrInvalidConfigType             = errors.New("invalid correlation config type")
	ErrInvalidTransformationType     = errors.New("invalid transformation type")
	ErrTransformationNotNested       = errors.New("transformations must be nested under config")
	ErrTransformationRegexReqExp     = errors.New("regex transformations require expression")
	ErrCorrelationsQuotaFailed       = errors.New("error getting correlations quota")
	ErrCorrelationsQuotaReached      = errors.New("correlations quota reached")
)
View Source
var (
	// ConfigurationPageAccess is used to protect the "Configure > correlations" tab access
	ConfigurationPageAccess = accesscontrol.EvalPermission(datasources.ActionRead)
)

Functions

This section is empty.

Types

type Correlation

type Correlation struct {
	// Unique identifier of the correlation
	// example: 50xhMlg9k
	UID string `json:"uid" xorm:"pk 'uid'"`
	// UID of the data source the correlation originates from
	// example: d0oxYRg4z
	SourceUID string `json:"sourceUID" xorm:"pk 'source_uid'"`
	// OrgID of the data source the correlation originates from
	// Example: 1
	OrgID int64 `json:"orgId" xorm:"pk 'org_id'"`
	// UID of the data source the correlation points to
	// example: PE1C5CBDA0504A6A3
	TargetUID *string `json:"targetUID" xorm:"target_uid"`
	// Label identifying the correlation
	// example: My Label
	Label string `json:"label" xorm:"label"`
	// Description of the correlation
	// example: Logs to Traces
	Description string `json:"description" xorm:"description"`
	// Correlation Configuration
	Config CorrelationConfig `json:"config" xorm:"jsonb config"`
	// Provisioned True if the correlation was created during provisioning
	Provisioned bool `json:"provisioned"`
}

Correlation is the model for correlations definitions swagger:model

type CorrelationConfig

type CorrelationConfig struct {
	// Field used to attach the correlation link
	// required:true
	// example: message
	Field string `json:"field" binding:"Required"`
	// Target type
	// required:true
	Type CorrelationConfigType `json:"type" binding:"Required"`
	// Target data query
	// required:true
	// example: {"prop1":"value1","prop2":"value"}
	Target map[string]any `json:"target" binding:"Required"`
	// Source data transformations
	// required:false
	// example: [{"type":"logfmt"}]
	Transformations Transformations `json:"transformations,omitempty"`
}

swagger:model

func (CorrelationConfig) MarshalJSON

func (c CorrelationConfig) MarshalJSON() ([]byte, error)

type CorrelationConfigType

type CorrelationConfigType string
const (
	ConfigTypeQuery CorrelationConfigType = "query"
)

func (CorrelationConfigType) Validate

func (t CorrelationConfigType) Validate() error

type CorrelationConfigUpdateDTO

type CorrelationConfigUpdateDTO struct {
	// Field used to attach the correlation link
	// example: message
	Field *string `json:"field"`
	// Target type
	Type *CorrelationConfigType `json:"type"`
	// Target data query
	// example: {"prop1":"value1","prop2":"value"}
	Target *map[string]any `json:"target"`
	// Source data transformations
	// example: [{"type": "logfmt"},{"type":"regex","expression":"(Superman|Batman)", "variable":"name"}]
	Transformations []Transformation `json:"transformations"`
}

swagger:model

func (CorrelationConfigUpdateDTO) Validate

func (c CorrelationConfigUpdateDTO) Validate() error

type CorrelationsService

type CorrelationsService struct {
	SQLStore      db.DB
	RouteRegister routing.RouteRegister

	DataSourceService datasources.DataSourceService
	AccessControl     accesscontrol.AccessControl
	QuotaService      quota.Service
	// contains filtered or unexported fields
}

func ProvideService

func ProvideService(sqlStore db.DB, routeRegister routing.RouteRegister, ds datasources.DataSourceService, ac accesscontrol.AccessControl, bus bus.Bus, qs quota.Service, cfg *setting.Cfg,
) (*CorrelationsService, error)

func (CorrelationsService) CountCorrelations

func (s CorrelationsService) CountCorrelations(ctx context.Context) (*quota.Map, error)

func (CorrelationsService) CreateCorrelation

func (CorrelationsService) CreateOrUpdateCorrelation

func (s CorrelationsService) CreateOrUpdateCorrelation(ctx context.Context, cmd CreateCorrelationCommand) error

func (CorrelationsService) DeleteCorrelation

func (s CorrelationsService) DeleteCorrelation(ctx context.Context, cmd DeleteCorrelationCommand) error

func (CorrelationsService) DeleteCorrelationsBySourceUID

func (s CorrelationsService) DeleteCorrelationsBySourceUID(ctx context.Context, cmd DeleteCorrelationsBySourceUIDCommand) error

func (CorrelationsService) DeleteCorrelationsByTargetUID

func (s CorrelationsService) DeleteCorrelationsByTargetUID(ctx context.Context, cmd DeleteCorrelationsByTargetUIDCommand) error

func (CorrelationsService) GetCorrelation

func (CorrelationsService) GetCorrelations

func (CorrelationsService) GetCorrelationsBySourceUID

func (s CorrelationsService) GetCorrelationsBySourceUID(ctx context.Context, cmd GetCorrelationsBySourceUIDQuery) ([]Correlation, error)

func (CorrelationsService) UpdateCorrelation

func (*CorrelationsService) Usage

func (s *CorrelationsService) Usage(ctx context.Context, scopeParams *quota.ScopeParameters) (*quota.Map, error)

type CreateCorrelationCommand

type CreateCorrelationCommand struct {
	// UID of the data source for which correlation is created.
	SourceUID string `json:"-"`
	OrgId     int64  `json:"-"`
	// Target data source UID to which the correlation is created. required if config.type = query
	// example: PE1C5CBDA0504A6A3
	TargetUID *string `json:"targetUID"`
	// Optional label identifying the correlation
	// example: My label
	Label string `json:"label"`
	// Optional description of the correlation
	// example: Logs to Traces
	Description string `json:"description"`
	// Arbitrary configuration object handled in frontend
	Config CorrelationConfig `json:"config" binding:"Required"`
	// True if correlation was created with provisioning. This makes it read-only.
	Provisioned bool `json:"provisioned"`
}

CreateCorrelationCommand is the command for creating a correlation swagger:model

func (CreateCorrelationCommand) Validate

func (c CreateCorrelationCommand) Validate() error

type CreateCorrelationParams

type CreateCorrelationParams struct {
	// in:body
	// required:true
	Body CreateCorrelationCommand `json:"body"`
	// in:path
	// required:true
	SourceUID string `json:"sourceUID"`
}

swagger:parameters createCorrelation

type CreateCorrelationResponse

type CreateCorrelationResponse struct {
	// in: body
	Body CreateCorrelationResponseBody `json:"body"`
}

swagger:response createCorrelationResponse

type CreateCorrelationResponseBody

type CreateCorrelationResponseBody struct {
	Result Correlation `json:"result"`
	// example: Correlation created
	Message string `json:"message"`
}

CreateCorrelationResponse is the response struct for CreateCorrelationCommand swagger:model

type DeleteCorrelationCommand

type DeleteCorrelationCommand struct {
	// UID of the correlation to be deleted.
	UID       string
	SourceUID string
	OrgId     int64
}

DeleteCorrelationCommand is the command for deleting a correlation

type DeleteCorrelationParams

type DeleteCorrelationParams struct {
	// in:path
	// required:true
	DatasourceUID string `json:"uid"`
	// in:path
	// required:true
	CorrelationUID string `json:"correlationUID"`
}

swagger:parameters deleteCorrelation

type DeleteCorrelationResponse

type DeleteCorrelationResponse struct {
	// in: body
	Body DeleteCorrelationResponseBody `json:"body"`
}

type DeleteCorrelationResponseBody

type DeleteCorrelationResponseBody struct {
	// example: Correlation deleted
	Message string `json:"message"`
}

swagger:model

type DeleteCorrelationsBySourceUIDCommand

type DeleteCorrelationsBySourceUIDCommand struct {
	SourceUID       string
	OrgId           int64
	OnlyProvisioned bool
}

type DeleteCorrelationsByTargetUIDCommand

type DeleteCorrelationsByTargetUIDCommand struct {
	TargetUID string
	OrgId     int64
}

type GetCorrelationParams

type GetCorrelationParams struct {
	// in:path
	// required:true
	DatasourceUID string `json:"sourceUID"`
	// in:path
	// required:true
	CorrelationUID string `json:"correlationUID"`
}

swagger:parameters getCorrelation

type GetCorrelationQuery

type GetCorrelationQuery struct {
	// UID of the correlation
	UID string `json:"-"`
	// UID of the source data source
	SourceUID string `json:"-"`
	OrgId     int64  `json:"-"`
}

GetCorrelationQuery is the query to retrieve a single correlation

type GetCorrelationResponse

type GetCorrelationResponse struct {
	// in: body
	Body Correlation `json:"body"`
}

type GetCorrelationsBySourceUIDParams

type GetCorrelationsBySourceUIDParams struct {
	// in:path
	// required:true
	DatasourceUID string `json:"sourceUID"`
}

swagger:parameters getCorrelationsBySourceUID

type GetCorrelationsBySourceUIDQuery

type GetCorrelationsBySourceUIDQuery struct {
	SourceUID string `json:"-"`
	OrgId     int64  `json:"-"`
}

GetCorrelationsBySourceUIDQuery is the query to retrieve all correlations originating by the given Data Source

type GetCorrelationsBySourceUIDResponse

type GetCorrelationsBySourceUIDResponse struct {
	// in: body
	Body []Correlation `json:"body"`
}

swagger:response getCorrelationsBySourceUIDResponse

type GetCorrelationsParams

type GetCorrelationsParams struct {
	// Limit the maximum number of correlations to return per page
	// in:query
	// required:false
	// default:100
	// maximum: 1000
	Limit int64 `json:"limit"`
	// Page index for starting fetching correlations
	// in:query
	// required:false
	// default:1
	Page int64 `json:"page"`
	// Source datasource UID filter to be applied to correlations
	// in:query
	// type: array
	// collectionFormat: multi
	// required:false
	SourceUIDs []string `json:"sourceUID"`
}

swagger:parameters getCorrelations

type GetCorrelationsQuery

type GetCorrelationsQuery struct {
	OrgId int64 `json:"-"`
	// Limit the maximum number of correlations to return per page
	// in:query
	// required:false
	// default:100
	Limit int64 `json:"limit"`
	// Page index for starting fetching correlations
	// in:query
	// required:false
	// default:1
	Page int64 `json:"page"`

	// Source datasource UID filter to be applied to correlations
	// in:query
	// required:false
	SourceUIDs []string `json:"sourceuid"`
}

GetCorrelationsQuery is the query to retrieve all correlations

type GetCorrelationsResponse

type GetCorrelationsResponse struct {
	// in: body
	Body []Correlation `json:"body"`
}

type GetCorrelationsResponseBody

type GetCorrelationsResponseBody struct {
	Correlations []Correlation `json:"correlations"`
	TotalCount   int64         `json:"totalCount"`
	Page         int64         `json:"page"`
	Limit        int64         `json:"limit"`
}

type Service

type Service interface {
	CreateCorrelation(ctx context.Context, cmd CreateCorrelationCommand) (Correlation, error)
	CreateOrUpdateCorrelation(ctx context.Context, cmd CreateCorrelationCommand) error
	DeleteCorrelation(ctx context.Context, cmd DeleteCorrelationCommand) error
	DeleteCorrelationsBySourceUID(ctx context.Context, cmd DeleteCorrelationsBySourceUIDCommand) error
	DeleteCorrelationsByTargetUID(ctx context.Context, cmd DeleteCorrelationsByTargetUIDCommand) error
}

type Transformation

type Transformation struct {
	//Enum: regex,logfmt
	Type       string `json:"type"`
	Expression string `json:"expression,omitempty"`
	Field      string `json:"field,omitempty"`
	MapValue   string `json:"mapValue,omitempty"`
}

type Transformations

type Transformations []Transformation

func (Transformations) Validate

func (t Transformations) Validate() error

type UpdateCorrelationCommand

type UpdateCorrelationCommand struct {
	// UID of the correlation to be updated.
	UID       string `json:"-"`
	SourceUID string `json:"-"`
	OrgId     int64  `json:"-"`

	// Optional label identifying the correlation
	// example: My label
	Label *string `json:"label"`
	// Optional description of the correlation
	// example: Logs to Traces
	Description *string `json:"description"`
	// Correlation Configuration
	Config *CorrelationConfigUpdateDTO `json:"config"`
}

UpdateCorrelationCommand is the command for updating a correlation swagger:model

func (UpdateCorrelationCommand) Validate

func (c UpdateCorrelationCommand) Validate() error

type UpdateCorrelationParams

type UpdateCorrelationParams struct {
	// in:path
	// required:true
	DatasourceUID string `json:"sourceUID"`
	// in:path
	// required:true
	CorrelationUID string `json:"correlationUID"`
	// in: body
	Body UpdateCorrelationCommand `json:"body"`
}

swagger:parameters updateCorrelation

type UpdateCorrelationResponse

type UpdateCorrelationResponse struct {
	// in: body
	Body UpdateCorrelationResponseBody `json:"body"`
}

swagger:response updateCorrelationResponse

type UpdateCorrelationResponseBody

type UpdateCorrelationResponseBody struct {
	Result Correlation `json:"result"`
	// example: Correlation updated
	Message string `json:"message"`
}

swagger:model

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL