query

package
v1.0.329 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2024 License: Apache-2.0 Imports: 28 Imported by: 23

Documentation

Index

Constants

View Source
const DefaultDepth = 5

Variables

View Source
var (
	// Default search window
	DefaultCheckQueryWindow = "1h"
)
View Source
var DefaultQueryTimeout = 30 * time.Second
View Source
var LocalFilter = "deleted_at is NULL AND agent_id = '00000000-0000-0000-0000-000000000000' OR agent_id IS NULL"
View Source
var SyncComponentCacheJob = &job.Job{
	Name:       "SyncComponentCache",
	Schedule:   "@every 5m",
	JobHistory: true,
	Retention:  job.RetentionHour,
	Fn: func(ctx job.JobRuntime) error {
		return SyncComponentCache(ctx.Context)
	},
}
View Source
var SyncConfigCacheJob = &job.Job{
	Name:       "SyncConfigCache",
	Schedule:   "@every 5m",
	JobHistory: true,
	Retention:  job.RetentionHour,
	Fn: func(ctx job.JobRuntime) error {
		return SyncConfigCache(ctx.Context)
	},
}

Functions

func ArtifactsByCheck added in v1.0.225

func ArtifactsByCheck(ctx context.Context, checkID uuid.UUID, checkTime time.Time) ([]models.Artifact, error)

func ArtifactsByPlaybookRun added in v1.0.225

func ArtifactsByPlaybookRun(ctx context.Context, runID uuid.UUID) ([]models.Artifact, error)

func CheckSummary

func CheckSummary(ctx context.Context, opts ...CheckSummaryOptions) ([]models.CheckSummary, error)

func CheckSummaryByID

func CheckSummaryByID(ctx context.Context, checkID string) (*models.CheckSummary, error)

func ClearCache added in v1.0.317

func ClearCache()

func ComponentFromCache added in v1.0.324

func ComponentFromCache(ctx context.Context, id string) (models.Component, error)

func Config

func Config(ctx context.Context, sqlQuery string) ([]map[string]any, error)

Query executes a SQL query against the "config_" tables in the database.

func ConfigIDsByTypeFromCache added in v1.0.318

func ConfigIDsByTypeFromCache(ctx context.Context, id, typ string) ([]string, error)

func ConfigItemFromCache added in v1.0.318

func ConfigItemFromCache(ctx context.Context, id string) (models.ConfigItem, error)

func ConfigRelationsFromCache added in v1.0.318

func ConfigRelationsFromCache(ctx context.Context, id string) ([]string, error)

func FindAgent added in v1.0.274

func FindAgent(ctx context.Context, name string) (*models.Agent, error)

func FindCachedAgent added in v1.0.324

func FindCachedAgent(ctx context.Context, identifier string) (*models.Agent, error)

func FindCachedCanary added in v1.0.324

func FindCachedCanary(ctx context.Context, id string) (*models.Canary, error)

func FindCachedCheck added in v1.0.324

func FindCachedCheck(ctx context.Context, id string) (*models.Check, error)

func FindCheckIDs added in v1.0.324

func FindCheckIDs(ctx context.Context, resourceSelectors ...types.ResourceSelector) ([]uuid.UUID, error)

func FindChecks added in v1.0.324

func FindChecks(ctx context.Context, resourceSelectors ...types.ResourceSelector) ([]models.Check, error)

func FindComponentIDs added in v1.0.324

func FindComponentIDs(ctx context.Context, resourceSelectors ...types.ResourceSelector) ([]uuid.UUID, error)

func FindComponents added in v1.0.324

func FindComponents(ctx context.Context, resourceSelectors ...types.ResourceSelector) ([]models.Component, error)

func FindConfig added in v1.0.253

func FindConfig(ctx context.Context, query types.ConfigQuery) (*models.ConfigItem, error)

func FindConfigForComponent added in v1.0.253

func FindConfigForComponent(ctx context.Context, componentID, configType string) ([]models.ConfigItem, error)

func FindConfigIDs added in v1.0.294

func FindConfigIDs(ctx context.Context, config types.ConfigQuery) ([]uuid.UUID, error)

func FindConfigIDsByResourceSelector added in v1.0.324

func FindConfigIDsByResourceSelector(ctx context.Context, resourceSelectors ...types.ResourceSelector) ([]uuid.UUID, error)

func FindConfigs added in v1.0.254

func FindConfigs(ctx context.Context, config types.ConfigQuery) ([]models.ConfigItem, error)

func FindConfigsByResourceSelector added in v1.0.324

func FindConfigsByResourceSelector(ctx context.Context, resourceSelectors ...types.ResourceSelector) ([]models.ConfigItem, error)

func FindPerson added in v1.0.324

func FindPerson(ctx context.Context, identifier string, opts ...GetterOption) (*models.Person, error)

FindPerson looks up a person by the given identifier which can either be

  • UUID
  • email

func FindTeam added in v1.0.324

func FindTeam(ctx context.Context, identifier string, opts ...GetterOption) (*models.Team, error)

FindTeam looks up a team by the given identifier which can either be

  • UUID
  • team name

func FlushGettersCache added in v1.0.327

func FlushGettersCache()

func GetAllResourceIDsOfAgent added in v1.0.274

func GetAllResourceIDsOfAgent(ctx context.Context, table, from string, size int, agentID uuid.UUID) ([]string, error)

func GetCachedComponent added in v1.0.324

func GetCachedComponent(ctx context.Context, id string) (*models.Component, error)

func GetCachedConfig added in v1.0.324

func GetCachedConfig(ctx context.Context, id string) (*models.ConfigItem, error)

func GetCachedIncident added in v1.0.324

func GetCachedIncident(ctx context.Context, id string) (*models.Incident, error)

func GetChecksByIDs added in v1.0.324

func GetChecksByIDs(ctx context.Context, ids []uuid.UUID) ([]models.Check, error)

func GetComponent

func GetComponent(ctx context.Context, id string) (*models.Component, error)

func GetComponentsByIDs added in v1.0.324

func GetComponentsByIDs(ctx context.Context, ids []uuid.UUID) ([]models.Component, error)

func GetConfigsByIDs added in v1.0.324

func GetConfigsByIDs(ctx context.Context, ids []uuid.UUID) ([]models.ConfigItem, error)

func SyncComponentCache added in v1.0.324

func SyncComponentCache(ctx context.Context) error

func SyncConfigCache added in v1.0.318

func SyncConfigCache(ctx context.Context) error

func TraverseConfig added in v1.0.318

func TraverseConfig(ctx context.Context, id, relationType string) *models.ConfigItem

Types

type CheckQueryParams added in v1.0.260

type CheckQueryParams struct {
	Check           string
	CanaryID        string
	Start, End      string
	IncludeMessages bool
	IncludeDetails  bool

	StatusCount    int
	Labels         map[string]string
	Trace          bool
	WindowDuration time.Duration
	// contains filtered or unexported fields
}

func (CheckQueryParams) ExecuteDetails added in v1.0.260

func (q CheckQueryParams) ExecuteDetails(ctx context.Context) ([]Timeseries, types.Uptime, types.Latency, error)

func (CheckQueryParams) GetEndTime added in v1.0.260

func (q CheckQueryParams) GetEndTime() *time.Time

func (CheckQueryParams) GetStartTime added in v1.0.260

func (q CheckQueryParams) GetStartTime() *time.Time

func (CheckQueryParams) GetWhereClause added in v1.0.260

func (q CheckQueryParams) GetWhereClause() (string, map[string]interface{}, error)

func (*CheckQueryParams) Init added in v1.0.260

func (q *CheckQueryParams) Init(queryParams url.Values) error

func (CheckQueryParams) String added in v1.0.260

func (q CheckQueryParams) String() string

func (*CheckQueryParams) Validate added in v1.0.260

func (q *CheckQueryParams) Validate() error

type CheckSummaryOptions

type CheckSummaryOptions struct {
	Timeout    time.Duration
	CheckID    *uuid.UUID
	SortBy     CheckSummarySortBy
	DeleteFrom *time.Time

	// Labels apply to both the canary and check labels
	Labels map[string]string
}

func OrderByName

func OrderByName() CheckSummaryOptions

type CheckSummarySortBy

type CheckSummarySortBy string
var CheckSummarySortByName CheckSummarySortBy = "name"

type GetterOption added in v1.0.324

type GetterOption uint8
const (
	GetterOptionNoCache GetterOption = iota + 1
)

type GetterOptions added in v1.0.324

type GetterOptions []GetterOption

func (GetterOptions) IsSet added in v1.0.324

func (t GetterOptions) IsSet(option GetterOption) bool

type Tags

type Tags map[string][]string

Map of tag keys to the list of available values

type Timeseries added in v1.0.260

type Timeseries struct {
	Key      string `json:"key,omitempty"`
	Time     string `json:"time,omitempty"`
	Status   bool   `json:"status,omitempty"`
	Message  string `json:"message,omitempty"`
	Error    string `json:"error,omitempty"`
	Duration int    `json:"duration"`
	// Count is the number of times the check has been run in the specified time window
	Count  int `json:"count,omitempty"`
	Passed int `json:"passed,omitempty"`
	Failed int `json:"failed,omitempty"`
}

type TopologyOptions

type TopologyOptions struct {
	ID      string
	Owner   string
	Labels  map[string]string
	AgentID string
	Flatten bool
	Depth   int
	// TODO: Filter status and types in DB Query
	Types  []string
	Status []string

	SortBy    TopologyQuerySortBy
	SortOrder string
	NoCache   bool
	// contains filtered or unexported fields
}

func (TopologyOptions) CacheKey added in v1.0.317

func (opt TopologyOptions) CacheKey() string

func (TopologyOptions) String

func (opt TopologyOptions) String() string

type TopologyQuerySortBy added in v1.0.298

type TopologyQuerySortBy string
const (
	TopologyQuerySortByName  TopologyQuerySortBy = "name"
	TopologyQuerySortByField TopologyQuerySortBy = "field:"
)

type TopologyResponse

type TopologyResponse struct {
	Components     models.Components `json:"components"`
	HealthStatuses []string          `json:"healthStatuses"`
	Teams          []string          `json:"teams"`
	Tags           Tags              `json:"tags"`
	Types          []string          `json:"types"`
}

func Topology

func Topology(ctx context.Context, params TopologyOptions) (*TopologyResponse, error)

Jump to

Keyboard shortcuts

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