Documentation ¶
Overview ¶
Package dal is the Data Access Layer between the Application and PostgreSQL database.
Index ¶
- Variables
- type AccessToken
- func (t *AccessToken) AllAccessTokens(tx *sqlx.Tx) ([]*AccessTokenRow, error)
- func (t *AccessToken) AllByClusterID(tx *sqlx.Tx, clusterID int64) ([]*AccessTokenRow, error)
- func (t *AccessToken) Create(tx *sqlx.Tx, userID, clusterID int64, level string) (*AccessTokenRow, error)
- func (t *AccessToken) GetByAccessToken(tx *sqlx.Tx, token string) (*AccessTokenRow, error)
- func (t *AccessToken) GetByClusterID(tx *sqlx.Tx, clusterID int64) (*AccessTokenRow, error)
- func (t *AccessToken) GetByID(tx *sqlx.Tx, id int64) (*AccessTokenRow, error)
- func (t *AccessToken) GetByUserID(tx *sqlx.Tx, userID int64) (*AccessTokenRow, error)
- type AccessTokenRow
- type AgentResourcePayload
- type Base
- func (b *Base) DeleteByClusterIDAndID(tx *sqlx.Tx, clusterID, id int64) (result sql.Result, err error)
- func (b *Base) DeleteByID(tx *sqlx.Tx, id int64) (result sql.Result, err error)
- func (b *Base) DeleteFromTable(tx *sqlx.Tx, where string) (result sql.Result, err error)
- func (b *Base) GetPGDB() (*sqlx.DB, error)
- func (b *Base) InsertIntoTable(tx *sqlx.Tx, data map[string]interface{}) (sql.Result, error)
- func (b *Base) NewExplicitID() int64
- func (b *Base) UpdateByID(tx *sqlx.Tx, data map[string]interface{}, id int64) (result sql.Result, err error)
- func (b *Base) UpdateByKeyValueString(tx *sqlx.Tx, data map[string]interface{}, key, value string) (result sql.Result, err error)
- func (b *Base) UpdateFromTable(tx *sqlx.Tx, data map[string]interface{}, where string) (result sql.Result, err error)
- type BaseRow
- type Check
- func (c *Check) AddTrigger(tx *sqlx.Tx, checkRow *CheckRow, trigger CheckTrigger) ([]CheckTrigger, error)
- func (c *Check) All(tx *sqlx.Tx) ([]*CheckRow, error)
- func (c *Check) AllByClusterID(tx *sqlx.Tx, clusterID int64) ([]*CheckRow, error)
- func (c *Check) AllSplitToDaemons(tx *sqlx.Tx, daemons []string) (map[string][]*CheckRow, error)
- func (c *Check) Create(tx *sqlx.Tx, clusterID int64, data map[string]interface{}) (*CheckRow, error)
- func (c *Check) DeleteTrigger(tx *sqlx.Tx, checkRow *CheckRow, trigger CheckTrigger) ([]CheckTrigger, error)
- func (c *Check) GetByID(tx *sqlx.Tx, id int64) (*CheckRow, error)
- func (c *Check) UpdateTrigger(tx *sqlx.Tx, checkRow *CheckRow, trigger CheckTrigger) ([]CheckTrigger, error)
- type CheckExpression
- type CheckRow
- func (checkRow *CheckRow) BuildEmailTriggerContent(lastViolation *TSCheckRow, templateRoot string) (string, error)
- func (checkRow *CheckRow) GetExpressions() ([]CheckExpression, error)
- func (checkRow *CheckRow) GetHostsList() ([]string, error)
- func (checkRow *CheckRow) GetTriggers() []CheckTrigger
- func (checkRow *CheckRow) RunEmailTrigger(ctx context.Context, trigger CheckTrigger, lastViolation *TSCheckRow, ...) (err error)
- func (checkRow *CheckRow) RunPagerDutyTrigger(ctx context.Context, trigger CheckTrigger, lastViolation *TSCheckRow) (err error)
- func (checkRow *CheckRow) RunSMSTrigger(ctx context.Context, trigger CheckTrigger, lastViolation *TSCheckRow, ...) (err error)
- func (checkRow *CheckRow) RunTriggers(ctx context.Context) error
- func (checkRow *CheckRow) UnmarshalTriggers() ([]CheckTrigger, error)
- type CheckRowsWithError
- type CheckTrigger
- type CheckTriggerAction
- type Cluster
- func (c *Cluster) All(tx *sqlx.Tx) ([]*ClusterRow, error)
- func (c *Cluster) AllByUserID(tx *sqlx.Tx, userId int64) ([]*ClusterRow, error)
- func (c *Cluster) AllSplitToDaemons(tx *sqlx.Tx, daemons []string) (map[string][]*ClusterRow, error)
- func (c *Cluster) Create(tx *sqlx.Tx, creator *UserRow, name string) (*ClusterRow, error)
- func (c *Cluster) GetByID(tx *sqlx.Tx, id int64) (*ClusterRow, error)
- func (c *Cluster) RemoveMember(tx *sqlx.Tx, id int64, user *UserRow) error
- func (c *Cluster) UpdateMember(tx *sqlx.Tx, id int64, user *UserRow, level string, enabled bool) error
- type ClusterMember
- type ClusterRow
- func (cr *ClusterRow) GetDataRetention() map[string]int
- func (cr *ClusterRow) GetDeletedFromUNIXTimestampForInsert(tableName string) int64
- func (cr *ClusterRow) GetDeletedFromUNIXTimestampForSelect(tableName string) int64
- func (cr *ClusterRow) GetLevelByUserID(id int64) string
- func (cr *ClusterRow) GetMembers() []ClusterMember
- func (cr *ClusterRow) GetTTLDurationForInsert(tableName string) time.Duration
- type Graph
- func (g *Graph) AllByClusterID(tx *sqlx.Tx, clusterID int64) ([]*GraphRow, error)
- func (g *Graph) AllGraphs(tx *sqlx.Tx) ([]*GraphRow, error)
- func (g *Graph) Create(tx *sqlx.Tx, clusterID int64, data map[string]interface{}) (*GraphRow, error)
- func (g *Graph) DeleteMetricFromGraphs(tx *sqlx.Tx, clusterID, metricID int64) error
- func (g *Graph) GetByClusterIDAndID(tx *sqlx.Tx, clusterID, id int64) (*GraphRow, error)
- func (g *Graph) GetByID(tx *sqlx.Tx, id int64) (*GraphRow, error)
- func (g *Graph) UpdateMetricsByClusterIDAndID(tx *sqlx.Tx, clusterID, id int64, metricsJSON []byte) (*GraphRow, error)
- type GraphRow
- type GraphRowsWithError
- type Host
- func (h *Host) AllByClusterID(tx *sqlx.Tx, clusterID int64) ([]*HostRow, error)
- func (h *Host) AllByClusterIDAndHostnames(tx *sqlx.Tx, clusterID int64, hostnames []string) ([]*HostRow, error)
- func (h *Host) AllByClusterIDAndUpdatedInterval(tx *sqlx.Tx, clusterID int64, updatedInterval string) ([]*HostRow, error)
- func (h *Host) AllByClusterIDQueryAndUpdatedInterval(tx *sqlx.Tx, clusterID int64, resourcedQuery, updatedInterval string) ([]*HostRow, error)
- func (h *Host) AllCompactByClusterIDQueryAndUpdatedInterval(tx *sqlx.Tx, clusterID int64, resourcedQuery, updatedInterval string) ([]*HostRow, error)
- func (h *Host) CountByClusterIDAndUpdatedInterval(tx *sqlx.Tx, clusterID int64, updatedInterval string) (int, error)
- func (h *Host) CreateOrUpdate(tx *sqlx.Tx, accessTokenRow *AccessTokenRow, jsonData []byte) (*HostRow, error)
- func (h *Host) GetByHostname(tx *sqlx.Tx, hostname string) (*HostRow, error)
- func (h *Host) GetByID(tx *sqlx.Tx, id int64) (*HostRow, error)
- func (h *Host) GetPGDB() (*sqlx.DB, error)
- func (h *Host) UpdateMasterTagsByHostname(tx *sqlx.Tx, hostname string, tags map[string]interface{}) error
- func (h *Host) UpdateMasterTagsByID(tx *sqlx.Tx, id int64, tags map[string]interface{}) error
- type HostRow
- type HostRowsWithError
- type IPGDBGetter
- type InsertResult
- type Metric
- func (m *Metric) AllByClusterID(tx *sqlx.Tx, clusterID int64) ([]*MetricRow, error)
- func (m *Metric) AllByClusterIDAsMap(tx *sqlx.Tx, clusterID int64) (map[string]int64, error)
- func (m *Metric) CreateOrUpdate(tx *sqlx.Tx, clusterID int64, key string) (*MetricRow, error)
- func (m *Metric) GetByClusterIDAndKey(tx *sqlx.Tx, clusterID int64, key string) (*MetricRow, error)
- func (m *Metric) GetByID(tx *sqlx.Tx, id int64) (*MetricRow, error)
- type MetricRow
- type MetricRowsWithError
- type MetricsMapWithError
- type SavedQuery
- func (sq *SavedQuery) AllByClusterID(tx *sqlx.Tx, clusterID int64) ([]*SavedQueryRow, error)
- func (sq *SavedQuery) AllByClusterIDAndType(tx *sqlx.Tx, clusterID int64, savedQueryType string) ([]*SavedQueryRow, error)
- func (sq *SavedQuery) CreateOrUpdate(tx *sqlx.Tx, accessTokenRow *AccessTokenRow, savedQueryType, savedQuery string) (*SavedQueryRow, error)
- func (sq *SavedQuery) GetByAccessTokenAndQuery(tx *sqlx.Tx, accessTokenRow *AccessTokenRow, savedQueryType, savedQuery string) (*SavedQueryRow, error)
- func (sq *SavedQuery) GetByID(tx *sqlx.Tx, id int64) (*SavedQueryRow, error)
- type SavedQueryRow
- type SavedQueryRowsWithError
- type TSBase
- type TSCheck
- func (ts *TSCheck) AllViolationsByClusterIDCheckIDAndInterval(tx *sqlx.Tx, clusterID, CheckID, createdIntervalMinute, deletedFrom int64) ([]*TSCheckRow, error)
- func (ts *TSCheck) Create(tx *sqlx.Tx, clusterID, CheckID int64, result bool, ...) error
- func (ts *TSCheck) GetPGDB() (*sqlx.DB, error)
- func (ts *TSCheck) LastByClusterIDCheckIDAndLimit(tx *sqlx.Tx, clusterID, checkID, limit int64) ([]*TSCheckRow, error)
- func (ts *TSCheck) LastByClusterIDCheckIDAndResult(tx *sqlx.Tx, clusterID, checkID int64, result bool) (*TSCheckRow, error)
- type TSCheckRow
- type TSEvent
- func (ts *TSEvent) AllBandsByClusterIDAndCreatedFromRangeForHighchart(tx *sqlx.Tx, clusterID, from, to, deletedFrom int64) ([]shared.TSEventHighchartLinePayload, error)
- func (ts *TSEvent) AllLinesByClusterIDAndCreatedFromRangeForHighchart(tx *sqlx.Tx, clusterID, from, to, deletedFrom int64) ([]shared.TSEventHighchartLinePayload, error)
- func (ts *TSEvent) Create(tx *sqlx.Tx, id, clusterID, fromUnix, toUnix int64, description string, ...) (*TSEventRow, error)
- func (ts *TSEvent) CreateFromJSON(tx *sqlx.Tx, id, clusterID int64, jsonData []byte, deletedFrom int64) (*TSEventRow, error)
- func (ts *TSEvent) DeleteDeleted(tx *sqlx.Tx, clusterID int64) error
- func (ts *TSEvent) GetByID(tx *sqlx.Tx, id int64) (*TSEventRow, error)
- func (ts *TSEvent) GetPGDB() (*sqlx.DB, error)
- type TSEventRow
- type TSLog
- func (ts *TSLog) AllByClusterIDAndRange(tx *sqlx.Tx, clusterID int64, from, to, deletedFrom int64) ([]*TSLogRow, error)
- func (ts *TSLog) AllByClusterIDRangeAndQuery(tx *sqlx.Tx, clusterID int64, from, to int64, resourcedQuery string, ...) ([]*TSLogRow, error)
- func (ts *TSLog) CountByClusterIDFromTimestampHostAndQuery(tx *sqlx.Tx, clusterID int64, from int64, hostname, resourcedQuery string, ...) (int64, error)
- func (ts *TSLog) Create(tx *sqlx.Tx, clusterID int64, hostname string, tags map[string]string, ...) (err error)
- func (ts *TSLog) CreateFromJSON(tx *sqlx.Tx, clusterID int64, jsonData []byte, deletedFrom int64) error
- func (ts *TSLog) GetPGDB() (*sqlx.DB, error)
- func (ts *TSLog) LastByClusterID(tx *sqlx.Tx, clusterID int64) (*TSLogRow, error)
- type TSLogRow
- type TSLogRowsWithError
- type TSMetric
- func (ts *TSMetric) AllByMetricIDAndRange(tx *sqlx.Tx, clusterID, metricID, from, to, deletedFrom int64) ([]*TSMetricRow, error)
- func (ts *TSMetric) AllByMetricIDAndRangeForHighchart(tx *sqlx.Tx, clusterID, metricID, from, to, deletedFrom int64) ([]*shared.TSMetricHighchartPayload, error)
- func (ts *TSMetric) AllByMetricIDHostAndRange(tx *sqlx.Tx, clusterID, metricID int64, host string, ...) ([]*TSMetricRow, error)
- func (ts *TSMetric) AllByMetricIDHostAndRangeForHighchart(tx *sqlx.Tx, clusterID, metricID int64, host string, ...) (*shared.TSMetricHighchartPayload, error)
- func (ts *TSMetric) Create(tx *sqlx.Tx, clusterID, metricID int64, host, key string, value float64, ...) error
- func (ts *TSMetric) CreateByHostRow(tx *sqlx.Tx, hostRow shared.IHostRow, metricsMap map[string]int64, ...) error
- func (ts *TSMetric) GetAggregateXMinutesByMetricIDAndHostname(tx *sqlx.Tx, clusterID, metricID int64, minutes int, hostname string) (*shared.TSMetricAggregateRow, error)
- func (ts *TSMetric) GetPGDB() (*sqlx.DB, error)
- type TSMetricRow
- type User
- func (u *User) AllUsers(tx *sqlx.Tx) ([]*UserRow, error)
- func (u *User) GetByEmail(tx *sqlx.Tx, email string) (*UserRow, error)
- func (u *User) GetByEmailVerificationToken(tx *sqlx.Tx, emailVerificationToken string) (*UserRow, error)
- func (u *User) GetByID(tx *sqlx.Tx, id int64) (*UserRow, error)
- func (u *User) GetUserByEmailAndPassword(tx *sqlx.Tx, email, password string) (*UserRow, error)
- func (u *User) Signup(tx *sqlx.Tx, email, password, passwordAgain string) (*UserRow, error)
- func (u *User) SignupRandomPassword(tx *sqlx.Tx, email string) (*UserRow, error)
- func (u *User) UpdateEmailAndPasswordById(tx *sqlx.Tx, userId int64, email, password, passwordAgain string) (*UserRow, error)
- func (u *User) UpdateEmailVerification(tx *sqlx.Tx, emailVerificationToken string) (*UserRow, error)
- type UserRow
Constants ¶
This section is empty.
Variables ¶
var PROJECT_EPOCH = 1451606400
Functions ¶
This section is empty.
Types ¶
type AccessToken ¶
type AccessToken struct {
Base
}
func NewAccessToken ¶
func NewAccessToken(ctx context.Context) *AccessToken
func (*AccessToken) AllAccessTokens ¶
func (t *AccessToken) AllAccessTokens(tx *sqlx.Tx) ([]*AccessTokenRow, error)
AllAccessTokens returns all access tokens.
func (*AccessToken) AllByClusterID ¶
func (t *AccessToken) AllByClusterID(tx *sqlx.Tx, clusterID int64) ([]*AccessTokenRow, error)
AllAccessTokens returns all access tokens by cluster id.
func (*AccessToken) Create ¶
func (t *AccessToken) Create(tx *sqlx.Tx, userID, clusterID int64, level string) (*AccessTokenRow, error)
func (*AccessToken) GetByAccessToken ¶
func (t *AccessToken) GetByAccessToken(tx *sqlx.Tx, token string) (*AccessTokenRow, error)
GetByAccessToken returns one record by token.
func (*AccessToken) GetByClusterID ¶
func (t *AccessToken) GetByClusterID(tx *sqlx.Tx, clusterID int64) (*AccessTokenRow, error)
GetByClusterID returns one record by cluster_id.
func (*AccessToken) GetByID ¶
func (t *AccessToken) GetByID(tx *sqlx.Tx, id int64) (*AccessTokenRow, error)
GetByID returns one record by id.
func (*AccessToken) GetByUserID ¶
func (t *AccessToken) GetByUserID(tx *sqlx.Tx, userID int64) (*AccessTokenRow, error)
GetByUserID returns one record by user_id.
type AccessTokenRow ¶
type AgentResourcePayload ¶
type Base ¶
func (*Base) DeleteByClusterIDAndID ¶
func (*Base) DeleteByID ¶
func (*Base) DeleteFromTable ¶
func (*Base) InsertIntoTable ¶
func (*Base) NewExplicitID ¶
NewExplicitID uses UNIX timestamp in microseconds as ID.
func (*Base) UpdateByID ¶
func (*Base) UpdateByKeyValueString ¶
type BaseRow ¶
type BaseRow struct { }
func (*BaseRow) JSONAttrFloat64 ¶
func (br *BaseRow) JSONAttrFloat64(field sqlx_types.JSONText, attr string) float64
func (*BaseRow) JSONAttrString ¶
func (br *BaseRow) JSONAttrString(field sqlx_types.JSONText, attr string) string
type Check ¶
type Check struct {
Base
}
func (*Check) AddTrigger ¶
func (c *Check) AddTrigger(tx *sqlx.Tx, checkRow *CheckRow, trigger CheckTrigger) ([]CheckTrigger, error)
func (*Check) AllByClusterID ¶
AllByClusterID returns all rows by cluster_id.
func (*Check) AllSplitToDaemons ¶
AllSplitToDaemons returns all rows divided into daemons equally.
func (*Check) DeleteTrigger ¶
func (c *Check) DeleteTrigger(tx *sqlx.Tx, checkRow *CheckRow, trigger CheckTrigger) ([]CheckTrigger, error)
func (*Check) UpdateTrigger ¶
func (c *Check) UpdateTrigger(tx *sqlx.Tx, checkRow *CheckRow, trigger CheckTrigger) ([]CheckTrigger, error)
type CheckExpression ¶
type CheckExpression struct { Type string MinHost int Metric string Operator string Value float64 PrevRange int PrevAggr string Search string Protocol string Port string Headers string Username string Password string HTTPMethod string HTTPBody string Result struct { Value bool Message string BadHostnames []string GoodHostnames []string } }
type CheckRow ¶
type CheckRow struct { ID int64 `db:"id"` ClusterID int64 `db:"cluster_id"` Name string `db:"name"` Interval string `db:"interval"` IsSilenced bool `db:"is_silenced"` HostsQuery string `db:"hosts_query"` HostsList sqlx_types.JSONText `db:"hosts_list"` Expressions sqlx_types.JSONText `db:"expressions"` Triggers sqlx_types.JSONText `db:"triggers"` LastResultHosts sqlx_types.JSONText `db:"last_result_hosts"` LastResultExpressions sqlx_types.JSONText `db:"last_result_expressions"` }
func (*CheckRow) BuildEmailTriggerContent ¶
func (checkRow *CheckRow) BuildEmailTriggerContent(lastViolation *TSCheckRow, templateRoot string) (string, error)
func (*CheckRow) GetExpressions ¶
func (checkRow *CheckRow) GetExpressions() ([]CheckExpression, error)
func (*CheckRow) GetHostsList ¶
func (*CheckRow) GetTriggers ¶
func (checkRow *CheckRow) GetTriggers() []CheckTrigger
func (*CheckRow) RunEmailTrigger ¶
func (checkRow *CheckRow) RunEmailTrigger(ctx context.Context, trigger CheckTrigger, lastViolation *TSCheckRow, violationsCount int) (err error)
func (*CheckRow) RunPagerDutyTrigger ¶
func (checkRow *CheckRow) RunPagerDutyTrigger(ctx context.Context, trigger CheckTrigger, lastViolation *TSCheckRow) (err error)
func (*CheckRow) RunSMSTrigger ¶
func (checkRow *CheckRow) RunSMSTrigger(ctx context.Context, trigger CheckTrigger, lastViolation *TSCheckRow, violationsCount int) (err error)
func (*CheckRow) RunTriggers ¶
func (checkRow *CheckRow) RunTriggers(appConfig config.GeneralConfig, coreDB *sqlx.DB, tsCheckDB *sqlx.DB, mailr *mailer.Mailer) error {
func (*CheckRow) UnmarshalTriggers ¶
func (checkRow *CheckRow) UnmarshalTriggers() ([]CheckTrigger, error)
type CheckRowsWithError ¶
type CheckTrigger ¶
type CheckTrigger struct { ID int64 LowViolationsCount int64 HighViolationsCount int64 CreatedIntervalMinute int64 Action CheckTriggerAction }
type CheckTriggerAction ¶
type Cluster ¶
type Cluster struct {
Base
}
func NewCluster ¶
func (*Cluster) All ¶
func (c *Cluster) All(tx *sqlx.Tx) ([]*ClusterRow, error)
All returns all clusters rows.
func (*Cluster) AllByUserID ¶
AllByUserID returns all clusters rows by user ID.
func (*Cluster) AllSplitToDaemons ¶
func (c *Cluster) AllSplitToDaemons(tx *sqlx.Tx, daemons []string) (map[string][]*ClusterRow, error)
AllSplitToDaemons returns all rows divided into daemons equally.
func (*Cluster) RemoveMember ¶
RemoveMember from a cluster.
type ClusterRow ¶
type ClusterRow struct { ID int64 `db:"id"` Name string `db:"name"` CreatorID int64 `db:"creator_id"` CreatorEmail string `db:"creator_email"` DataRetention sqlx_types.JSONText `db:"data_retention"` Members sqlx_types.JSONText `db:"members"` }
func (*ClusterRow) GetDataRetention ¶
func (cr *ClusterRow) GetDataRetention() map[string]int
GetDataRetention returns DataRetention in map
func (*ClusterRow) GetDeletedFromUNIXTimestampForInsert ¶
func (cr *ClusterRow) GetDeletedFromUNIXTimestampForInsert(tableName string) int64
GetDeletedFromUNIXTimestampForInsert returns UNIX timestamp for timeseries data on insert.
func (*ClusterRow) GetDeletedFromUNIXTimestampForSelect ¶
func (cr *ClusterRow) GetDeletedFromUNIXTimestampForSelect(tableName string) int64
GetDeletedFromUNIXTimestampForSelect returns UNIX timestamp from which data should be queried.
func (*ClusterRow) GetLevelByUserID ¶
func (cr *ClusterRow) GetLevelByUserID(id int64) string
GetLevelByUserID returns a specific cluster member level keyed by user id.
func (*ClusterRow) GetMembers ¶
func (cr *ClusterRow) GetMembers() []ClusterMember
GetMembers returns Members in map
func (*ClusterRow) GetTTLDurationForInsert ¶
func (cr *ClusterRow) GetTTLDurationForInsert(tableName string) time.Duration
GetTTLDurationForInsert returns TTL duration for timeseries data on insert.
type Graph ¶
type Graph struct {
Base
}
func (*Graph) AllByClusterID ¶
AllByClusterID returns all rows by cluster_id.
func (*Graph) DeleteMetricFromGraphs ¶
DeleteMetricFromGraphs deletes a particular metric from all rows by cluster_id.
func (*Graph) GetByClusterIDAndID ¶
GetByClusterIDAndID returns one record by id.
type GraphRow ¶
type GraphRow struct { ID int64 `db:"id"` ClusterID int64 `db:"cluster_id"` Name string `db:"name"` Description string `db:"description"` Range string `db:"range"` Metrics sqlx_types.JSONText `db:"metrics"` }
func (*GraphRow) MetricsFromJSON ¶
func (*GraphRow) MetricsFromJSONGroupByN ¶
func (*GraphRow) MetricsFromJSONGroupByThree ¶
type GraphRowsWithError ¶
type Host ¶
type Host struct { Base // contains filtered or unexported fields }
func (*Host) AllByClusterID ¶
AllByClusterID returns all rows.
func (*Host) AllByClusterIDAndHostnames ¶
func (h *Host) AllByClusterIDAndHostnames(tx *sqlx.Tx, clusterID int64, hostnames []string) ([]*HostRow, error)
AllByClusterIDAndHostnames returns all rows by hostnames.
func (*Host) AllByClusterIDAndUpdatedInterval ¶
func (h *Host) AllByClusterIDAndUpdatedInterval(tx *sqlx.Tx, clusterID int64, updatedInterval string) ([]*HostRow, error)
AllByClusterIDAndUpdatedInterval returns all rows.
func (*Host) AllByClusterIDQueryAndUpdatedInterval ¶
func (h *Host) AllByClusterIDQueryAndUpdatedInterval(tx *sqlx.Tx, clusterID int64, resourcedQuery, updatedInterval string) ([]*HostRow, error)
AllByClusterIDQueryAndUpdatedInterval returns all rows by resourced query.
func (*Host) AllCompactByClusterIDQueryAndUpdatedInterval ¶
func (h *Host) AllCompactByClusterIDQueryAndUpdatedInterval(tx *sqlx.Tx, clusterID int64, resourcedQuery, updatedInterval string) ([]*HostRow, error)
AllCompactByClusterIDQueryAndUpdatedInterval returns all rows by resourced query.
func (*Host) CountByClusterIDAndUpdatedInterval ¶
func (h *Host) CountByClusterIDAndUpdatedInterval(tx *sqlx.Tx, clusterID int64, updatedInterval string) (int, error)
CountByClusterIDAndUpdatedInterval returns the count of all rows.
func (*Host) CreateOrUpdate ¶
func (h *Host) CreateOrUpdate(tx *sqlx.Tx, accessTokenRow *AccessTokenRow, jsonData []byte) (*HostRow, error)
CreateOrUpdate performs insert/update for one host data.
func (*Host) GetByHostname ¶
GetByHostname returns record by hostname.
type HostRow ¶
type HostRow struct { ID int64 `db:"id" json:"-"` AccessTokenID int64 `db:"access_token_id" json:"-"` ClusterID int64 `db:"cluster_id"` Hostname string `db:"hostname"` Updated time.Time `db:"updated"` Tags sqlx_types.JSONText `db:"tags" json:",omitempty"` MasterTags sqlx_types.JSONText `db:"master_tags" json:",omitempty"` Data sqlx_types.JSONText `db:"data" json:",omitempty"` }
func (*HostRow) DataAsFlatKeyValue ¶
func (*HostRow) GetClusterID ¶
func (*HostRow) GetHostname ¶
func (*HostRow) GetMasterTags ¶
type HostRowsWithError ¶
type IPGDBGetter ¶
type InsertResult ¶
type InsertResult struct {
// contains filtered or unexported fields
}
func (*InsertResult) LastInsertId ¶
func (ir *InsertResult) LastInsertId() (int64, error)
func (*InsertResult) RowsAffected ¶
func (ir *InsertResult) RowsAffected() (int64, error)
type Metric ¶
type Metric struct {
Base
}
func (*Metric) AllByClusterID ¶
AllByClusterID returns all rows.
func (*Metric) AllByClusterIDAsMap ¶
AllByClusterIDAsMap returns all rows.
func (*Metric) CreateOrUpdate ¶
func (*Metric) GetByClusterIDAndKey ¶
GetByClusterIDAndKey returns one record by cluster_id and key.
type MetricRowsWithError ¶
type MetricsMapWithError ¶
type SavedQuery ¶
type SavedQuery struct {
Base
}
func NewSavedQuery ¶
func NewSavedQuery(ctx context.Context) *SavedQuery
func (*SavedQuery) AllByClusterID ¶
func (sq *SavedQuery) AllByClusterID(tx *sqlx.Tx, clusterID int64) ([]*SavedQueryRow, error)
AllByClusterID returns all saved_query rows.
func (*SavedQuery) AllByClusterIDAndType ¶
func (sq *SavedQuery) AllByClusterIDAndType(tx *sqlx.Tx, clusterID int64, savedQueryType string) ([]*SavedQueryRow, error)
AllByClusterIDAndType returns all saved_query rows.
func (*SavedQuery) CreateOrUpdate ¶
func (sq *SavedQuery) CreateOrUpdate(tx *sqlx.Tx, accessTokenRow *AccessTokenRow, savedQueryType, savedQuery string) (*SavedQueryRow, error)
CreateOrUpdate performs insert/update for one savedQuery data.
func (*SavedQuery) GetByAccessTokenAndQuery ¶
func (sq *SavedQuery) GetByAccessTokenAndQuery(tx *sqlx.Tx, accessTokenRow *AccessTokenRow, savedQueryType, savedQuery string) (*SavedQueryRow, error)
GetByAccessTokenAndQuery returns record by savedQuery.
func (*SavedQuery) GetByID ¶
func (sq *SavedQuery) GetByID(tx *sqlx.Tx, id int64) (*SavedQueryRow, error)
GetByID returns record by id.
type SavedQueryRow ¶
type SavedQueryRowsWithError ¶
type SavedQueryRowsWithError struct { SavedQueries []*SavedQueryRow Error error }
type TSCheck ¶
type TSCheck struct {
TSBase
}
func (*TSCheck) AllViolationsByClusterIDCheckIDAndInterval ¶
func (ts *TSCheck) AllViolationsByClusterIDCheckIDAndInterval(tx *sqlx.Tx, clusterID, CheckID, createdIntervalMinute, deletedFrom int64) ([]*TSCheckRow, error)
AllViolationsByClusterIDCheckIDAndInterval returns all ts_checks rows since last good marker.
func (*TSCheck) Create ¶
func (ts *TSCheck) Create(tx *sqlx.Tx, clusterID, CheckID int64, result bool, expressions []CheckExpression, deletedFrom int64) error
Create a new record.
func (*TSCheck) LastByClusterIDCheckIDAndLimit ¶
func (ts *TSCheck) LastByClusterIDCheckIDAndLimit(tx *sqlx.Tx, clusterID, checkID, limit int64) ([]*TSCheckRow, error)
LastByClusterIDCheckIDAndLimit returns a row by cluster_id, check_id and result.
func (*TSCheck) LastByClusterIDCheckIDAndResult ¶
func (ts *TSCheck) LastByClusterIDCheckIDAndResult(tx *sqlx.Tx, clusterID, checkID int64, result bool) (*TSCheckRow, error)
LastByClusterIDCheckIDAndResult returns a row by cluster_id, check_id and result.
type TSCheckRow ¶
type TSCheckRow struct { ClusterID int64 `db:"cluster_id"` CheckID int64 `db:"check_id"` Created time.Time `db:"created"` Deleted time.Time `db:"deleted"` Result bool `db:"result"` Expressions sqlx_types.JSONText `db:"expressions"` }
func (*TSCheckRow) GetExpressionsWithoutError ¶
func (tsCheckRow *TSCheckRow) GetExpressionsWithoutError() []CheckExpression
type TSEvent ¶
type TSEvent struct {
TSBase
}
func (*TSEvent) AllBandsByClusterIDAndCreatedFromRangeForHighchart ¶
func (ts *TSEvent) AllBandsByClusterIDAndCreatedFromRangeForHighchart(tx *sqlx.Tx, clusterID, from, to, deletedFrom int64) ([]shared.TSEventHighchartLinePayload, error)
AllBandsByClusterIDAndCreatedFromRangeForHighchart returns all rows with time stretch between created_from and created_to.
func (*TSEvent) AllLinesByClusterIDAndCreatedFromRangeForHighchart ¶
func (ts *TSEvent) AllLinesByClusterIDAndCreatedFromRangeForHighchart(tx *sqlx.Tx, clusterID, from, to, deletedFrom int64) ([]shared.TSEventHighchartLinePayload, error)
AllLinesByClusterIDAndCreatedFromRangeForHighchart returns all rows given created_from range.
func (*TSEvent) Create ¶
func (ts *TSEvent) Create(tx *sqlx.Tx, id, clusterID, fromUnix, toUnix int64, description string, deletedFrom int64) (*TSEventRow, error)
Create a new record.
func (*TSEvent) CreateFromJSON ¶
func (*TSEvent) DeleteDeleted ¶
DeleteDeleted deletes all record older than x days ago.
type TSEventRow ¶
type TSLog ¶
type TSLog struct {
TSBase
}
func (*TSLog) AllByClusterIDAndRange ¶
func (ts *TSLog) AllByClusterIDAndRange(tx *sqlx.Tx, clusterID int64, from, to, deletedFrom int64) ([]*TSLogRow, error)
AllByClusterIDAndRange returns all logs within time range.
func (*TSLog) AllByClusterIDRangeAndQuery ¶
func (ts *TSLog) AllByClusterIDRangeAndQuery(tx *sqlx.Tx, clusterID int64, from, to int64, resourcedQuery string, deletedFrom int64) ([]*TSLogRow, error)
AllByClusterIDRangeAndQuery returns all rows by cluster id, unix timestamp range, and resourced query.
func (*TSLog) CountByClusterIDFromTimestampHostAndQuery ¶
func (ts *TSLog) CountByClusterIDFromTimestampHostAndQuery(tx *sqlx.Tx, clusterID int64, from int64, hostname, resourcedQuery string, deletedFrom int64) (int64, error)
CountByClusterIDFromTimestampHostAndQuery returns count by cluster id, from unix timestamp, host, and resourced query.
func (*TSLog) Create ¶
func (ts *TSLog) Create(tx *sqlx.Tx, clusterID int64, hostname string, tags map[string]string, loglines []shared.AgentLoglinePayload, filename string, deletedFrom int64) (err error)
Create a new record.
func (*TSLog) CreateFromJSON ¶
type TSLogRow ¶
type TSLogRow struct { ClusterID int64 `db:"cluster_id"` Created time.Time `db:"created"` Deleted time.Time `db:"deleted"` Hostname string `db:"hostname"` Tags sqlx_types.JSONText `db:"tags"` Filename string `db:"filename"` Logline string `db:"logline"` }
func (*TSLogRow) CreatedUnix ¶
type TSLogRowsWithError ¶
type TSMetric ¶
type TSMetric struct {
TSBase
}
func (*TSMetric) AllByMetricIDAndRange ¶
func (*TSMetric) AllByMetricIDAndRangeForHighchart ¶
func (*TSMetric) AllByMetricIDHostAndRange ¶
func (*TSMetric) AllByMetricIDHostAndRangeForHighchart ¶
func (*TSMetric) Create ¶
func (ts *TSMetric) Create(tx *sqlx.Tx, clusterID, metricID int64, host, key string, value float64, deletedFrom int64) error
Create a new record.
func (*TSMetric) CreateByHostRow ¶
func (*TSMetric) GetAggregateXMinutesByMetricIDAndHostname ¶
type TSMetricRow ¶
type User ¶
type User struct {
Base
}
func (*User) GetByEmail ¶
GetByEmail returns record by email.
func (*User) GetByEmailVerificationToken ¶
func (u *User) GetByEmailVerificationToken(tx *sqlx.Tx, emailVerificationToken string) (*UserRow, error)
GetByEmailVerificationToken returns record by email_verification_token.
func (*User) GetUserByEmailAndPassword ¶
GetByEmail returns record by email but checks password first.
func (*User) SignupRandomPassword ¶
SignupRandomPassword create a new record of user with random password.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package querybuilder parses ResourceD query and turn it into PostgreSQL query.
|
Package querybuilder parses ResourceD query and turn it into PostgreSQL query. |