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 AgentLogPayload
- type AgentLoglinePayload
- 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) 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 (a *Check) AddTrigger(tx *sqlx.Tx, checkRow *CheckRow, trigger CheckTrigger) ([]CheckTrigger, error)
- func (a *Check) All(tx *sqlx.Tx) ([]*CheckRow, error)
- func (a *Check) AllByClusterID(tx *sqlx.Tx, clusterID int64) ([]*CheckRow, error)
- func (a *Check) AllSplitToDaemons(tx *sqlx.Tx, daemons []string) (map[string][]*CheckRow, error)
- func (a *Check) Create(tx *sqlx.Tx, clusterID int64, data map[string]interface{}) (*CheckRow, error)
- func (a *Check) DeleteTrigger(tx *sqlx.Tx, checkRow *CheckRow, trigger CheckTrigger) ([]CheckTrigger, error)
- func (a *Check) GetByID(tx *sqlx.Tx, id int64) (*CheckRow, error)
- func (a *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) CheckHTTP(hostname, scheme, port, method, user, pass string, headers map[string]string, ...) (resp *http.Response, err error)
- func (checkRow *CheckRow) CheckPing(hostname string) (outBytes []byte, err error)
- func (checkRow *CheckRow) CheckSSH(hostname, port, user string) (outBytes []byte, err error)
- func (checkRow *CheckRow) EvalExpressions(dbs *config.DBConfig) ([]CheckExpression, bool, error)
- func (checkRow *CheckRow) EvalHTTPExpression(hostRows []*HostRow, expression CheckExpression) CheckExpression
- func (checkRow *CheckRow) EvalLogDataExpression(dbs *config.DBConfig, hostRows []*HostRow, expression CheckExpression) CheckExpression
- func (checkRow *CheckRow) EvalPingExpression(hostRows []*HostRow, expression CheckExpression) CheckExpression
- func (checkRow *CheckRow) EvalRawHostDataExpression(hostRows []*HostRow, expression CheckExpression) CheckExpression
- func (checkRow *CheckRow) EvalRelativeHostDataExpression(dbs *config.DBConfig, hostRows []*HostRow, expression CheckExpression) CheckExpression
- func (checkRow *CheckRow) EvalSSHExpression(hostRows []*HostRow, expression CheckExpression) CheckExpression
- func (checkRow *CheckRow) GetExpressions() ([]CheckExpression, error)
- func (checkRow *CheckRow) GetHostsList() ([]string, error)
- func (checkRow *CheckRow) GetTriggers() []CheckTrigger
- func (checkRow *CheckRow) RunEmailTrigger(trigger CheckTrigger, lastViolation *TSCheckRow, violationsCount int, ...) (err error)
- func (checkRow *CheckRow) RunPagerDutyTrigger(trigger CheckTrigger, lastViolation *TSCheckRow) (err error)
- func (checkRow *CheckRow) RunSMSTrigger(trigger CheckTrigger, lastViolation *TSCheckRow, violationsCount int, ...) (err error)
- func (checkRow *CheckRow) RunTriggers(appConfig config.GeneralConfig, coreDB *sqlx.DB, tsCheckDB *sqlx.DB, ...) 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
- 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) UpdateMasterTagsByID(tx *sqlx.Tx, id int64, tags map[string]interface{}) error
- type HostRow
- type HostRowsWithError
- type InsertResult
- type Metadata
- func (metadata *Metadata) AllByClusterID(tx *sqlx.Tx, clusterID int64) ([]*MetadataRow, error)
- func (metadata *Metadata) CreateOrUpdate(tx *sqlx.Tx, clusterID int64, key string, data []byte) (*MetadataRow, error)
- func (metadata *Metadata) DeleteByClusterIDAndKey(tx *sqlx.Tx, clusterID int64, key string) (*MetadataRow, error)
- func (metadata *Metadata) GetByClusterIDAndKey(tx *sqlx.Tx, clusterID int64, key string) (*MetadataRow, error)
- func (metadata *Metadata) UpdateByClusterIDAndKey(tx *sqlx.Tx, clusterID int64, key string, data []byte) (*MetadataRow, error)
- type MetadataRow
- type Metric
- func (d *Metric) AllByClusterID(tx *sqlx.Tx, clusterID int64) ([]*MetricRow, error)
- func (d *Metric) AllByClusterIDAsMap(tx *sqlx.Tx, clusterID int64) (map[string]int64, error)
- func (d *Metric) CreateOrUpdate(tx *sqlx.Tx, clusterID int64, key string) (*MetricRow, error)
- func (d *Metric) GetByClusterIDAndKey(tx *sqlx.Tx, clusterID int64, key string) (*MetricRow, error)
- func (d *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) 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) ([]TSEventHighchartLinePayload, error)
- func (ts *TSEvent) AllLinesByClusterIDAndCreatedFromRangeForHighchart(tx *sqlx.Tx, clusterID, from, to, deletedFrom int64) ([]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)
- type TSEventCreatePayload
- type TSEventHighchartLinePayload
- 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) LastByClusterID(tx *sqlx.Tx, clusterID int64) (*TSLogRow, error)
- type TSLogRow
- type TSLogRowsWithError
- type TSMetric
- func (ts *TSMetric) AggregateEveryXMinutes(tx *sqlx.Tx, clusterID int64, minutes int) ([]*TSMetricSelectAggregateRow, error)
- func (ts *TSMetric) AggregateEveryXMinutesPerHost(tx *sqlx.Tx, clusterID int64, minutes int) ([]*TSMetricSelectAggregateRow, error)
- func (ts *TSMetric) AllByMetricIDAndRange(tx *sqlx.Tx, clusterID, metricID int64, from, to, deletedFrom int64) ([]*TSMetricRow, error)
- func (ts *TSMetric) AllByMetricIDAndRangeForHighchart(tx *sqlx.Tx, clusterID, metricID, from, to, deletedFrom int64) ([]*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, ...) (*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 *HostRow, metricsMap map[string]int64, deletedFrom int64) error
- func (ts *TSMetric) GetAggregateXMinutesByHostnameAndKey(tx *sqlx.Tx, clusterID int64, minutes int, hostname, key string) (*TSMetricSelectAggregateRow, error)
- type TSMetricAggr15m
- func (ts *TSMetricAggr15m) AllByMetricIDAndRange(tx *sqlx.Tx, clusterID, metricID, from, to, deletedFrom int64) ([]*TSMetricAggr15mRow, error)
- func (ts *TSMetricAggr15m) AllByMetricIDAndRangeForHighchart(tx *sqlx.Tx, clusterID, metricID, from, to, deletedFrom int64, aggr string) ([]*TSMetricHighchartPayload, error)
- func (ts *TSMetricAggr15m) AllByMetricIDHostAndRange(tx *sqlx.Tx, clusterID, metricID int64, host string, ...) ([]*TSMetricAggr15mRow, error)
- func (ts *TSMetricAggr15m) AllByMetricIDHostAndRangeForHighchart(tx *sqlx.Tx, clusterID, metricID int64, host string, ...) ([]*TSMetricHighchartPayload, error)
- func (ts *TSMetricAggr15m) CreateByHostRow(tx *sqlx.Tx, hostRow *HostRow, metricsMap map[string]int64, ...) error
- func (ts *TSMetricAggr15m) CreateByHostRowPerHost(tx *sqlx.Tx, hostRow *HostRow, metricsMap map[string]int64, ...) error
- func (ts *TSMetricAggr15m) InsertOrUpdate(tx *sqlx.Tx, clusterID, metricID int64, metricKey string, ...) (err error)
- func (ts *TSMetricAggr15m) InsertOrUpdateMany(tx *sqlx.Tx, clusterID, metricID int64, metricKey string, ...) (err error)
- func (ts *TSMetricAggr15m) TransformForHighchart(tx *sqlx.Tx, tsMetricRows []*TSMetricAggr15mRow, aggr string) ([]*TSMetricHighchartPayload, error)
- type TSMetricAggr15mRow
- type TSMetricHighchartPayload
- type TSMetricRow
- type TSMetricSelectAggregateRow
- 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(db *sqlx.DB) *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 AgentLogPayload ¶
type AgentLogPayload struct { Host struct { Name string Tags map[string]string } Data struct { Loglines []AgentLoglinePayload Filename string } }
type AgentLoglinePayload ¶
type AgentResourcePayload ¶
type Base ¶
type Base struct {
// contains filtered or unexported fields
}
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 (a *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 (a *Check) DeleteTrigger(tx *sqlx.Tx, checkRow *CheckRow, trigger CheckTrigger) ([]CheckTrigger, error)
func (*Check) UpdateTrigger ¶
func (a *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) EvalExpressions ¶
EvalExpressions reduces the result of expression into a single true/false. 1st value: List of all CheckExpression containing results. 2nd value: The value of all expressions. 3rd value: Error
func (*CheckRow) EvalHTTPExpression ¶
func (checkRow *CheckRow) EvalHTTPExpression(hostRows []*HostRow, expression CheckExpression) CheckExpression
func (*CheckRow) EvalLogDataExpression ¶
func (checkRow *CheckRow) EvalLogDataExpression(dbs *config.DBConfig, hostRows []*HostRow, expression CheckExpression) CheckExpression
func (*CheckRow) EvalPingExpression ¶
func (checkRow *CheckRow) EvalPingExpression(hostRows []*HostRow, expression CheckExpression) CheckExpression
func (*CheckRow) EvalRawHostDataExpression ¶
func (checkRow *CheckRow) EvalRawHostDataExpression(hostRows []*HostRow, expression CheckExpression) CheckExpression
func (*CheckRow) EvalRelativeHostDataExpression ¶
func (checkRow *CheckRow) EvalRelativeHostDataExpression(dbs *config.DBConfig, hostRows []*HostRow, expression CheckExpression) CheckExpression
func (*CheckRow) EvalSSHExpression ¶
func (checkRow *CheckRow) EvalSSHExpression(hostRows []*HostRow, expression CheckExpression) CheckExpression
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(trigger CheckTrigger, lastViolation *TSCheckRow, violationsCount int, mailr *mailer.Mailer, appConfig config.GeneralConfig) (err error)
func (*CheckRow) RunPagerDutyTrigger ¶
func (checkRow *CheckRow) RunPagerDutyTrigger(trigger CheckTrigger, lastViolation *TSCheckRow) (err error)
func (*CheckRow) RunSMSTrigger ¶
func (checkRow *CheckRow) RunSMSTrigger(trigger CheckTrigger, lastViolation *TSCheckRow, violationsCount int, mailr *mailer.Mailer, appConfig config.GeneralConfig) (err error)
func (*CheckRow) RunTriggers ¶
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
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
}
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 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 Metadata ¶
type Metadata struct {
Base
}
func NewMetadata ¶
func (*Metadata) AllByClusterID ¶
AllByClusterID returns all metadata rows.
func (*Metadata) CreateOrUpdate ¶
func (metadata *Metadata) CreateOrUpdate(tx *sqlx.Tx, clusterID int64, key string, data []byte) (*MetadataRow, error)
CreateOrUpdate performs insert/update for one metadata data.
func (*Metadata) DeleteByClusterIDAndKey ¶
func (metadata *Metadata) DeleteByClusterIDAndKey(tx *sqlx.Tx, clusterID int64, key string) (*MetadataRow, error)
DeleteByClusterIDAndKey updates record by cluster_id and key.
func (*Metadata) GetByClusterIDAndKey ¶
func (metadata *Metadata) GetByClusterIDAndKey(tx *sqlx.Tx, clusterID int64, key string) (*MetadataRow, error)
GetByClusterIDAndKey returns record by cluster_id and key.
func (*Metadata) UpdateByClusterIDAndKey ¶
func (metadata *Metadata) UpdateByClusterIDAndKey(tx *sqlx.Tx, clusterID int64, key string, data []byte) (*MetadataRow, error)
UpdateByClusterIDAndKey updates record by cluster_id and key.
type MetadataRow ¶
type MetadataRow struct { ClusterID int64 `db:"cluster_id" json:"-"` Key string `db:"key"` Data sqlx_types.JSONText `db:"data"` }
func (*MetadataRow) DataString ¶
func (metadataRow *MetadataRow) DataString() string
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(db *sqlx.DB) *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 NewTSCheck ¶
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 NewTSEvent ¶
func (*TSEvent) AllBandsByClusterIDAndCreatedFromRangeForHighchart ¶
func (ts *TSEvent) AllBandsByClusterIDAndCreatedFromRangeForHighchart(tx *sqlx.Tx, clusterID, from, to, deletedFrom int64) ([]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) ([]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 TSEventCreatePayload ¶
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 withing 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 []AgentLoglinePayload, filename string, deletedFrom int64) (err error)
Create a new record.
func (*TSLog) CreateFromJSON ¶
type TSLogRow ¶
type TSLogRowsWithError ¶
type TSMetric ¶
type TSMetric struct {
TSBase
}
func NewTSMetric ¶
func (*TSMetric) AggregateEveryXMinutes ¶
func (*TSMetric) AggregateEveryXMinutesPerHost ¶
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) GetAggregateXMinutesByHostnameAndKey ¶
type TSMetricAggr15m ¶
type TSMetricAggr15m struct {
TSBase
}
func NewTSMetricAggr15m ¶
func NewTSMetricAggr15m(db *sqlx.DB) *TSMetricAggr15m
func (*TSMetricAggr15m) AllByMetricIDAndRange ¶
func (ts *TSMetricAggr15m) AllByMetricIDAndRange(tx *sqlx.Tx, clusterID, metricID, from, to, deletedFrom int64) ([]*TSMetricAggr15mRow, error)
func (*TSMetricAggr15m) AllByMetricIDAndRangeForHighchart ¶
func (ts *TSMetricAggr15m) AllByMetricIDAndRangeForHighchart(tx *sqlx.Tx, clusterID, metricID, from, to, deletedFrom int64, aggr string) ([]*TSMetricHighchartPayload, error)
func (*TSMetricAggr15m) AllByMetricIDHostAndRange ¶
func (ts *TSMetricAggr15m) AllByMetricIDHostAndRange(tx *sqlx.Tx, clusterID, metricID int64, host string, from, to, deletedFrom int64) ([]*TSMetricAggr15mRow, error)
func (*TSMetricAggr15m) AllByMetricIDHostAndRangeForHighchart ¶
func (ts *TSMetricAggr15m) AllByMetricIDHostAndRangeForHighchart(tx *sqlx.Tx, clusterID, metricID int64, host string, from, to, deletedFrom int64, aggr string) ([]*TSMetricHighchartPayload, error)
func (*TSMetricAggr15m) CreateByHostRow ¶
func (ts *TSMetricAggr15m) CreateByHostRow(tx *sqlx.Tx, hostRow *HostRow, metricsMap map[string]int64, selectAggrRows []*TSMetricSelectAggregateRow, deletedFrom int64) error
CreateByHostRow creates new rows given host data.
func (*TSMetricAggr15m) CreateByHostRowPerHost ¶
func (ts *TSMetricAggr15m) CreateByHostRowPerHost(tx *sqlx.Tx, hostRow *HostRow, metricsMap map[string]int64, selectAggrRows []*TSMetricSelectAggregateRow, deletedFrom int64) error
CreateByHostRowPerHost creates new rows given host data per host.
func (*TSMetricAggr15m) InsertOrUpdate ¶
func (ts *TSMetricAggr15m) InsertOrUpdate(tx *sqlx.Tx, clusterID, metricID int64, metricKey string, selectAggrRow *TSMetricSelectAggregateRow, deletedFrom int64) (err error)
InsertOrUpdate a new record.
func (*TSMetricAggr15m) InsertOrUpdateMany ¶
func (ts *TSMetricAggr15m) InsertOrUpdateMany(tx *sqlx.Tx, clusterID, metricID int64, metricKey string, selectAggrRows []*TSMetricSelectAggregateRow, deletedFrom int64) (err error)
InsertOrUpdateMany multiple records.
func (*TSMetricAggr15m) TransformForHighchart ¶
func (ts *TSMetricAggr15m) TransformForHighchart(tx *sqlx.Tx, tsMetricRows []*TSMetricAggr15mRow, aggr string) ([]*TSMetricHighchartPayload, error)
type TSMetricAggr15mRow ¶
type TSMetricAggr15mRow struct { ClusterID int64 `db:"cluster_id"` MetricID int64 `db:"metric_id"` Created time.Time `db:"created"` Deleted time.Time `db:"deleted"` Key string `db:"key"` Host sql.NullString `db:"host"` Avg float64 `db:"avg"` Max float64 `db:"max"` Min float64 `db:"min"` Sum float64 `db:"sum"` }
type TSMetricHighchartPayload ¶
type TSMetricHighchartPayload struct { Name string `json:"name"` Data [][]interface{} `json:"data"` }
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.