Documentation
¶
Overview ¶
Package models contains generated Reform records and helpers.
Common order of helpers:
- unexported validators (checkXXX);
- FindAllXXX;
- FindXXXByID;
- other finder (e.g. FindNodesForAgent);
- CreateXXX;
- ChangeXXX;
- RemoveXXX.
Index ¶
- Constants
- Variables
- func ChangeActionResult(q *reform.Querier, actionID, pmmAgentID, aError, output string, done bool) error
- func CleanupOldResults(q *reform.Querier, olderThan time.Time) error
- func FindDSNByServiceIDandPMMAgentID(q *reform.Querier, serviceID, pmmAgentID, db string) (string, error)
- func FindPMMAgentsIDsWithPushMetrics(q *reform.Querier) ([]string, error)
- func FindPmmAgentIDToRunAction(pmmAgentID string, agents []*Agent) (string, error)
- func MergeLabels(node *Node, service *Service, agent *Agent) (map[string]string, error)
- func OpenDB(address, name, username, password string) (*sql.DB, error)
- func RemoveChannel(q *reform.Querier, id string) error
- func RemoveKubernetesCluster(q *reform.Querier, name string) error
- func RemoveNode(q *reform.Querier, id string, mode RemoveMode) error
- func RemoveService(q *reform.Querier, id string, mode RemoveMode) error
- func SaveSettings(q reform.DBTX, s *Settings) error
- func SetupDB(sqlDB *sql.DB, params *SetupDBParams) (*reform.DB, error)
- func ValidateSettings(params *ChangeSettingsParams) error
- type ActionResult
- func (s *ActionResult) AfterFind() error
- func (s *ActionResult) BeforeInsert() error
- func (s *ActionResult) BeforeUpdate() error
- func (s *ActionResult) HasPK() bool
- func (s *ActionResult) PKPointer() interface{}
- func (s *ActionResult) PKValue() interface{}
- func (s *ActionResult) Pointers() []interface{}
- func (s *ActionResult) SetPK(pk interface{})
- func (s ActionResult) String() string
- func (s *ActionResult) Table() reform.Table
- func (s *ActionResult) Values() []interface{}
- func (s *ActionResult) View() reform.View
- type AddDBMSServiceParams
- type Agent
- func ChangeAgent(q *reform.Querier, agentID string, params *ChangeCommonAgentParams) (*Agent, error)
- func CreateAgent(q *reform.Querier, agentType AgentType, params *CreateAgentParams) (*Agent, error)
- func CreateExternalExporter(q *reform.Querier, params *CreateExternalExporterParams) (*Agent, error)
- func CreateNodeExporter(q *reform.Querier, pmmAgentID string, customLabels map[string]string, ...) (*Agent, error)
- func CreatePMMAgent(q *reform.Querier, runsOnNodeID string, customLabels map[string]string) (*Agent, error)
- func FindAgentByID(q *reform.Querier, id string) (*Agent, error)
- func FindAgents(q *reform.Querier, filters AgentFilters) ([]*Agent, error)
- func FindAgentsByIDs(q *reform.Querier, ids []string) ([]*Agent, error)
- func FindAgentsForScrapeConfig(q *reform.Querier, pmmAgentID *string, pushMetrics bool) ([]*Agent, error)
- func FindPMMAgentsForService(q *reform.Querier, serviceID string) ([]*Agent, error)
- func FindPMMAgentsForVersion(logger *logrus.Entry, agents []*Agent, minPMMAgentVersion *version.Parsed) []*Agent
- func FindPMMAgentsRunningOnNode(q *reform.Querier, nodeID string) ([]*Agent, error)
- func RemoveAgent(q *reform.Querier, id string, mode RemoveMode) (*Agent, error)
- func (s *Agent) AfterFind() error
- func (s *Agent) BeforeInsert() error
- func (s *Agent) BeforeUpdate() error
- func (s *Agent) DSN(service *Service, dialTimeout time.Duration, database string) string
- func (s *Agent) GetCustomLabels() (map[string]string, error)
- func (s *Agent) HasPK() bool
- func (s *Agent) IsMySQLTablestatsGroupEnabled() bool
- func (s *Agent) PKPointer() interface{}
- func (s *Agent) PKValue() interface{}
- func (s *Agent) Pointers() []interface{}
- func (s *Agent) SetCustomLabels(m map[string]string) error
- func (s *Agent) SetPK(pk interface{})
- func (s Agent) String() string
- func (s *Agent) Table() reform.Table
- func (s *Agent) UnifiedLabels() (map[string]string, error)
- func (s *Agent) Values() []interface{}
- func (s *Agent) View() reform.View
- type AgentFilters
- type AgentType
- type ChangeChannelParams
- type ChangeCommonAgentParams
- type ChangeSettingsParams
- type Channel
- func ChangeChannel(q *reform.Querier, channelID string, params *ChangeChannelParams) (*Channel, error)
- func CreateChannel(q *reform.Querier, params *CreateChannelParams) (*Channel, error)
- func FindChannelByID(q *reform.Querier, id string) (*Channel, error)
- func FindChannels(q *reform.Querier) ([]Channel, error)
- func (c *Channel) AfterFind() error
- func (c *Channel) BeforeInsert() error
- func (c *Channel) BeforeUpdate() error
- func (s *Channel) HasPK() bool
- func (s *Channel) PKPointer() interface{}
- func (s *Channel) PKValue() interface{}
- func (s *Channel) Pointers() []interface{}
- func (s *Channel) SetPK(pk interface{})
- func (s Channel) String() string
- func (s *Channel) Table() reform.Table
- func (s *Channel) Values() []interface{}
- func (s *Channel) View() reform.View
- type ChannelType
- type CreateAgentParams
- type CreateChannelParams
- type CreateExternalExporterParams
- type CreateKubernetesClusterParams
- type CreateNodeParams
- type EmailConfig
- type HTTPBasicAuth
- type HTTPConfig
- type KubernetesCluster
- func (s *KubernetesCluster) AfterFind() error
- func (s *KubernetesCluster) BeforeInsert() error
- func (s *KubernetesCluster) BeforeUpdate() error
- func (s *KubernetesCluster) HasPK() bool
- func (s *KubernetesCluster) PKPointer() interface{}
- func (s *KubernetesCluster) PKValue() interface{}
- func (s *KubernetesCluster) Pointers() []interface{}
- func (s *KubernetesCluster) SetPK(pk interface{})
- func (s KubernetesCluster) String() string
- func (s *KubernetesCluster) Table() reform.Table
- func (s *KubernetesCluster) Values() []interface{}
- func (s *KubernetesCluster) View() reform.View
- type MetricsResolutions
- type Node
- func CheckUniqueNodeInstanceRegion(q *reform.Querier, instance string, region *string) (*Node, error)
- func CreateNode(q *reform.Querier, nodeType NodeType, params *CreateNodeParams) (*Node, error)
- func FindNodeByID(q *reform.Querier, id string) (*Node, error)
- func FindNodeByName(q *reform.Querier, name string) (*Node, error)
- func FindNodes(q *reform.Querier, filters NodeFilters) ([]*Node, error)
- func FindNodesByIDs(q *reform.Querier, ids []string) ([]*Node, error)
- func (s *Node) AfterFind() error
- func (s *Node) BeforeInsert() error
- func (s *Node) BeforeUpdate() error
- func (s *Node) GetCustomLabels() (map[string]string, error)
- func (s *Node) HasPK() bool
- func (s *Node) PKPointer() interface{}
- func (s *Node) PKValue() interface{}
- func (s *Node) Pointers() []interface{}
- func (s *Node) SetCustomLabels(m map[string]string) error
- func (s *Node) SetPK(pk interface{})
- func (s Node) String() string
- func (s *Node) Table() reform.Table
- func (s *Node) UnifiedLabels() (map[string]string, error)
- func (s *Node) Values() []interface{}
- func (s *Node) View() reform.View
- type NodeFilters
- type NodeType
- type PagerDutyConfig
- type RemoveMode
- type Service
- func AddNewService(q *reform.Querier, serviceType ServiceType, params *AddDBMSServiceParams) (*Service, error)
- func FindServiceByID(q *reform.Querier, id string) (*Service, error)
- func FindServiceByName(q *reform.Querier, name string) (*Service, error)
- func FindServices(q *reform.Querier, filters ServiceFilters) ([]*Service, error)
- func FindServicesByIDs(q *reform.Querier, ids []string) ([]*Service, error)
- func (s *Service) AfterFind() error
- func (s *Service) BeforeInsert() error
- func (s *Service) BeforeUpdate() error
- func (s *Service) GetCustomLabels() (map[string]string, error)
- func (s *Service) HasPK() bool
- func (s *Service) PKPointer() interface{}
- func (s *Service) PKValue() interface{}
- func (s *Service) Pointers() []interface{}
- func (s *Service) SetCustomLabels(m map[string]string) error
- func (s *Service) SetPK(pk interface{})
- func (s Service) String() string
- func (s *Service) Table() reform.Table
- func (s *Service) UnifiedLabels() (map[string]string, error)
- func (s *Service) Values() []interface{}
- func (s *Service) View() reform.View
- type ServiceFilters
- type ServiceType
- type Settings
- type SetupDBParams
- type SetupFixturesMode
- type SlackConfig
- type TLSConfig
- type VictoriaMetricsParams
- type WebHookConfig
Constants ¶
const ( Email = ChannelType("email") PagerDuty = ChannelType("pagerduty") Slack = ChannelType("slack") WebHook = ChannelType("webhook") )
Available notification channel types.
const PMMServerAgentID string = "pmm-server" // no /agent_id/ prefix
PMMServerAgentID is a special Agent ID representing pmm-agent on PMM Server.
const PMMServerNodeID string = "pmm-server" // no /node_id/ prefix
PMMServerNodeID is a special Node ID representing PMM Server Node.
const PMMServerPostgreSQLServiceName = "pmm-server-postgresql"
PMMServerPostgreSQLServiceName is a special Service Name representing PMM Server's PostgreSQL Service.
Variables ¶
var ActionResultTable = &actionResultTableType{ s: parse.StructInfo{Type: "ActionResult", SQLSchema: "", SQLName: "action_results", Fields: []parse.FieldInfo{{Name: "ID", Type: "string", Column: "id"}, {Name: "PMMAgentID", Type: "string", Column: "pmm_agent_id"}, {Name: "Done", Type: "bool", Column: "done"}, {Name: "Error", Type: "string", Column: "error"}, {Name: "Output", Type: "string", Column: "output"}, {Name: "CreatedAt", Type: "time.Time", Column: "created_at"}, {Name: "UpdatedAt", Type: "time.Time", Column: "updated_at"}}, PKFieldIndex: 0}, z: new(ActionResult).Values(), }
ActionResultTable represents action_results view or table in SQL database.
var AgentTable = &agentTableType{ s: parse.StructInfo{Type: "Agent", SQLSchema: "", SQLName: "agents", Fields: []parse.FieldInfo{{Name: "AgentID", Type: "string", Column: "agent_id"}, {Name: "AgentType", Type: "AgentType", Column: "agent_type"}, {Name: "RunsOnNodeID", Type: "*string", Column: "runs_on_node_id"}, {Name: "ServiceID", Type: "*string", Column: "service_id"}, {Name: "NodeID", Type: "*string", Column: "node_id"}, {Name: "PMMAgentID", Type: "*string", Column: "pmm_agent_id"}, {Name: "CustomLabels", Type: "[]uint8", Column: "custom_labels"}, {Name: "CreatedAt", Type: "time.Time", Column: "created_at"}, {Name: "UpdatedAt", Type: "time.Time", Column: "updated_at"}, {Name: "Disabled", Type: "bool", Column: "disabled"}, {Name: "Status", Type: "string", Column: "status"}, {Name: "ListenPort", Type: "*uint16", Column: "listen_port"}, {Name: "Version", Type: "*string", Column: "version"}, {Name: "Username", Type: "*string", Column: "username"}, {Name: "Password", Type: "*string", Column: "password"}, {Name: "TLS", Type: "bool", Column: "tls"}, {Name: "TLSSkipVerify", Type: "bool", Column: "tls_skip_verify"}, {Name: "AWSAccessKey", Type: "*string", Column: "aws_access_key"}, {Name: "AWSSecretKey", Type: "*string", Column: "aws_secret_key"}, {Name: "TableCount", Type: "*int32", Column: "table_count"}, {Name: "TableCountTablestatsGroupLimit", Type: "int32", Column: "table_count_tablestats_group_limit"}, {Name: "QueryExamplesDisabled", Type: "bool", Column: "query_examples_disabled"}, {Name: "MaxQueryLogSize", Type: "int64", Column: "max_query_log_size"}, {Name: "MetricsPath", Type: "*string", Column: "metrics_path"}, {Name: "MetricsScheme", Type: "*string", Column: "metrics_scheme"}, {Name: "RDSBasicMetricsDisabled", Type: "bool", Column: "rds_basic_metrics_disabled"}, {Name: "RDSEnhancedMetricsDisabled", Type: "bool", Column: "rds_enhanced_metrics_disabled"}, {Name: "PushMetrics", Type: "bool", Column: "push_metrics"}}, PKFieldIndex: 0}, z: new(Agent).Values(), }
AgentTable represents agents view or table in SQL database.
var ChannelTable = &channelTableType{ s: parse.StructInfo{Type: "Channel", SQLSchema: "", SQLName: "ia_channels", Fields: []parse.FieldInfo{{Name: "ID", Type: "string", Column: "id"}, {Name: "Summary", Type: "string", Column: "summary"}, {Name: "Type", Type: "ChannelType", Column: "type"}, {Name: "EmailConfig", Type: "*EmailConfig", Column: "email_config"}, {Name: "PagerDutyConfig", Type: "*PagerDutyConfig", Column: "pagerduty_config"}, {Name: "SlackConfig", Type: "*SlackConfig", Column: "slack_config"}, {Name: "WebHookConfig", Type: "*WebHookConfig", Column: "webhook_config"}, {Name: "Disabled", Type: "bool", Column: "disabled"}, {Name: "CreatedAt", Type: "time.Time", Column: "created_at"}, {Name: "UpdatedAt", Type: "time.Time", Column: "updated_at"}}, PKFieldIndex: 0}, z: new(Channel).Values(), }
ChannelTable represents ia_channels view or table in SQL database.
var KubernetesClusterTable = &kubernetesClusterTableType{ s: parse.StructInfo{Type: "KubernetesCluster", SQLSchema: "", SQLName: "kubernetes_clusters", Fields: []parse.FieldInfo{{Name: "ID", Type: "string", Column: "id"}, {Name: "KubernetesClusterName", Type: "string", Column: "kubernetes_cluster_name"}, {Name: "KubeConfig", Type: "string", Column: "kube_config"}, {Name: "CreatedAt", Type: "time.Time", Column: "created_at"}, {Name: "UpdatedAt", Type: "time.Time", Column: "updated_at"}}, PKFieldIndex: 0}, z: new(KubernetesCluster).Values(), }
KubernetesClusterTable represents kubernetes_clusters view or table in SQL database.
var NodeTable = &nodeTableType{ s: parse.StructInfo{Type: "Node", SQLSchema: "", SQLName: "nodes", Fields: []parse.FieldInfo{{Name: "NodeID", Type: "string", Column: "node_id"}, {Name: "NodeType", Type: "NodeType", Column: "node_type"}, {Name: "NodeName", Type: "string", Column: "node_name"}, {Name: "MachineID", Type: "*string", Column: "machine_id"}, {Name: "Distro", Type: "string", Column: "distro"}, {Name: "NodeModel", Type: "string", Column: "node_model"}, {Name: "AZ", Type: "string", Column: "az"}, {Name: "CustomLabels", Type: "[]uint8", Column: "custom_labels"}, {Name: "Address", Type: "string", Column: "address"}, {Name: "CreatedAt", Type: "time.Time", Column: "created_at"}, {Name: "UpdatedAt", Type: "time.Time", Column: "updated_at"}, {Name: "ContainerID", Type: "*string", Column: "container_id"}, {Name: "ContainerName", Type: "*string", Column: "container_name"}, {Name: "Region", Type: "*string", Column: "region"}}, PKFieldIndex: 0}, z: new(Node).Values(), }
NodeTable represents nodes view or table in SQL database.
var Now = func() time.Time { return time.Now().Truncate(time.Microsecond).UTC() }
Now returns current time with database precision.
var PMMAgentWithPushMetricsSupport = version.MustParse("2.11.1")
PMMAgentWithPushMetricsSupport - version of pmmAgent, that support vmagent and push metrics mode will be released with PMM Agent v2.12. TODO fix it to 2.11.99 before release
var ServiceTable = &serviceTableType{ s: parse.StructInfo{Type: "Service", SQLSchema: "", SQLName: "services", Fields: []parse.FieldInfo{{Name: "ServiceID", Type: "string", Column: "service_id"}, {Name: "ServiceType", Type: "ServiceType", Column: "service_type"}, {Name: "ServiceName", Type: "string", Column: "service_name"}, {Name: "NodeID", Type: "string", Column: "node_id"}, {Name: "Environment", Type: "string", Column: "environment"}, {Name: "Cluster", Type: "string", Column: "cluster"}, {Name: "ReplicationSet", Type: "string", Column: "replication_set"}, {Name: "CustomLabels", Type: "[]uint8", Column: "custom_labels"}, {Name: "ExternalGroup", Type: "string", Column: "external_group"}, {Name: "CreatedAt", Type: "time.Time", Column: "created_at"}, {Name: "UpdatedAt", Type: "time.Time", Column: "updated_at"}, {Name: "Address", Type: "*string", Column: "address"}, {Name: "Port", Type: "*uint16", Column: "port"}, {Name: "Socket", Type: "*string", Column: "socket"}}, PKFieldIndex: 0}, z: new(Service).Values(), }
ServiceTable represents services view or table in SQL database.
Functions ¶
func ChangeActionResult ¶
func ChangeActionResult(q *reform.Querier, actionID, pmmAgentID, aError, output string, done bool) error
ChangeActionResult updates an action result in action results storage.
func CleanupOldResults ¶
CleanupOldResults deletes action results older than a specified date.
func FindDSNByServiceIDandPMMAgentID ¶
func FindDSNByServiceIDandPMMAgentID(q *reform.Querier, serviceID, pmmAgentID, db string) (string, error)
FindDSNByServiceIDandPMMAgentID resolves DSN by service id.
func FindPMMAgentsIDsWithPushMetrics ¶
FindPMMAgentsIDsWithPushMetrics returns pmm-agents-ids with agent, that use push_metrics mode.
func FindPmmAgentIDToRunAction ¶
FindPmmAgentIDToRunAction finds pmm-agent-id to run action.
func MergeLabels ¶
MergeLabels merges unified labels of Node, Service, and Agent (each can be nil).
func RemoveChannel ¶
RemoveChannel removes notification channel with specified id.
func RemoveKubernetesCluster ¶
RemoveKubernetesCluster removes Kubernetes cluster with provided name.
func RemoveNode ¶
func RemoveNode(q *reform.Querier, id string, mode RemoveMode) error
RemoveNode removes single Node.
func RemoveService ¶
func RemoveService(q *reform.Querier, id string, mode RemoveMode) error
RemoveService removes single Service.
func SaveSettings ¶
SaveSettings saves PMM Server settings. It may modify passed settings to fill defaults.
func ValidateSettings ¶
func ValidateSettings(params *ChangeSettingsParams) error
ValidateSettings validates settings changes.
Types ¶
type ActionResult ¶
type ActionResult struct {
ID string `reform:"id,pk"`
PMMAgentID string `reform:"pmm_agent_id"`
Done bool `reform:"done"`
Error string `reform:"error"`
Output string `reform:"output"`
CreatedAt time.Time `reform:"created_at"`
UpdatedAt time.Time `reform:"updated_at"`
}
ActionResult describes an action result which is storing in persistent storage.
func CreateActionResult ¶
func CreateActionResult(q *reform.Querier, pmmAgentID string) (*ActionResult, error)
CreateActionResult stores an action result in action results storage.
func FindActionResultByID ¶
func FindActionResultByID(q *reform.Querier, id string) (*ActionResult, error)
FindActionResultByID finds ActionResult by ID.
func (*ActionResult) AfterFind ¶
func (s *ActionResult) AfterFind() error
AfterFind implements reform.AfterFinder interface.
func (*ActionResult) BeforeInsert ¶
func (s *ActionResult) BeforeInsert() error
BeforeInsert implements reform.BeforeInserter interface.
func (*ActionResult) BeforeUpdate ¶
func (s *ActionResult) BeforeUpdate() error
BeforeUpdate implements reform.BeforeUpdater interface.
func (*ActionResult) HasPK ¶
func (s *ActionResult) HasPK() bool
HasPK returns true if record has non-zero primary key set, false otherwise.
func (*ActionResult) PKPointer ¶
func (s *ActionResult) PKPointer() interface{}
PKPointer returns a pointer to primary key field for that record. Returned interface{} value is never untyped nil.
func (*ActionResult) PKValue ¶
func (s *ActionResult) PKValue() interface{}
PKValue returns a value of primary key for that record. Returned interface{} value is never untyped nil.
func (*ActionResult) Pointers ¶
func (s *ActionResult) Pointers() []interface{}
Pointers returns a slice of pointers to struct or record fields. Returned interface{} values are never untyped nils.
func (*ActionResult) SetPK ¶
func (s *ActionResult) SetPK(pk interface{})
SetPK sets record primary key.
func (ActionResult) String ¶
func (s ActionResult) String() string
String returns a string representation of this struct or record.
func (*ActionResult) Table ¶
func (s *ActionResult) Table() reform.Table
Table returns Table object for that record.
func (*ActionResult) Values ¶
func (s *ActionResult) Values() []interface{}
Values returns a slice of struct or record field values. Returned interface{} values are never untyped nils.
func (*ActionResult) View ¶
func (s *ActionResult) View() reform.View
View returns View object for that struct.
type AddDBMSServiceParams ¶
type AddDBMSServiceParams struct {
ServiceName string
NodeID string
Environment string
Cluster string
ReplicationSet string
CustomLabels map[string]string
ExternalGroup string
Address *string
Port *uint16
Socket *string
}
AddDBMSServiceParams contains parameters for adding DBMS (MySQL, PostgreSQL, MongoDB, External) Services.
type Agent ¶
type Agent struct {
AgentID string `reform:"agent_id,pk"`
AgentType AgentType `reform:"agent_type"`
RunsOnNodeID *string `reform:"runs_on_node_id"`
ServiceID *string `reform:"service_id"`
NodeID *string `reform:"node_id"`
PMMAgentID *string `reform:"pmm_agent_id"`
CustomLabels []byte `reform:"custom_labels"`
CreatedAt time.Time `reform:"created_at"`
UpdatedAt time.Time `reform:"updated_at"`
Disabled bool `reform:"disabled"`
Status string `reform:"status"`
ListenPort *uint16 `reform:"listen_port"`
Version *string `reform:"version"`
Username *string `reform:"username"`
Password *string `reform:"password"`
TLS bool `reform:"tls"`
TLSSkipVerify bool `reform:"tls_skip_verify"`
AWSAccessKey *string `reform:"aws_access_key"`
AWSSecretKey *string `reform:"aws_secret_key"`
// TableCount stores last known table count. NULL if unknown.
TableCount *int32 `reform:"table_count"`
// Tablestats group collectors are disabled if there are more than that number of tables.
// 0 means tablestats group collectors are always enabled (no limit).
// Negative value means tablestats group collectors are always disabled.
// See IsMySQLTablestatsGroupEnabled method.
TableCountTablestatsGroupLimit int32 `reform:"table_count_tablestats_group_limit"`
QueryExamplesDisabled bool `reform:"query_examples_disabled"`
MaxQueryLogSize int64 `reform:"max_query_log_size"`
MetricsPath *string `reform:"metrics_path"`
MetricsScheme *string `reform:"metrics_scheme"`
RDSBasicMetricsDisabled bool `reform:"rds_basic_metrics_disabled"`
RDSEnhancedMetricsDisabled bool `reform:"rds_enhanced_metrics_disabled"`
PushMetrics bool `reform:"push_metrics"`
}
Agent represents Agent as stored in database.
func ChangeAgent ¶
func ChangeAgent(q *reform.Querier, agentID string, params *ChangeCommonAgentParams) (*Agent, error)
ChangeAgent changes common parameters for given Agent.
func CreateAgent ¶
CreateAgent creates Agent with given type.
func CreateExternalExporter ¶
func CreateExternalExporter(q *reform.Querier, params *CreateExternalExporterParams) (*Agent, error)
CreateExternalExporter creates ExternalExporter.
func CreateNodeExporter ¶
func CreateNodeExporter(q *reform.Querier, pmmAgentID string, customLabels map[string]string, pushMetrics bool) (*Agent, error)
CreateNodeExporter creates NodeExporter.
func CreatePMMAgent ¶
func CreatePMMAgent(q *reform.Querier, runsOnNodeID string, customLabels map[string]string) (*Agent, error)
CreatePMMAgent creates PMMAgent.
func FindAgentByID ¶
FindAgentByID finds Agent by ID.
func FindAgents ¶
func FindAgents(q *reform.Querier, filters AgentFilters) ([]*Agent, error)
FindAgents returns Agents by filters.
func FindAgentsByIDs ¶
FindAgentsByIDs finds Agents by IDs.
func FindAgentsForScrapeConfig ¶
func FindAgentsForScrapeConfig(q *reform.Querier, pmmAgentID *string, pushMetrics bool) ([]*Agent, error)
FindAgentsForScrapeConfig returns Agents for scrape config generation by pmm_agent_id and push_metrics value.
func FindPMMAgentsForService ¶
FindPMMAgentsForService gets pmm-agents for service.
func FindPMMAgentsForVersion ¶
func FindPMMAgentsForVersion(logger *logrus.Entry, agents []*Agent, minPMMAgentVersion *version.Parsed) []*Agent
FindPMMAgentsForVersion selects pmm-agents with version >= minPMMAgentVersion.
func FindPMMAgentsRunningOnNode ¶
FindPMMAgentsRunningOnNode gets pmm-agents for node where it runs.
func RemoveAgent ¶
RemoveAgent removes Agent by ID.
func (*Agent) BeforeInsert ¶
BeforeInsert implements reform.BeforeInserter interface.
func (*Agent) BeforeUpdate ¶
BeforeUpdate implements reform.BeforeUpdater interface.
func (*Agent) DSN ¶
DSN returns DSN string for accessing given Service with this Agent (and implicit driver).
func (*Agent) GetCustomLabels ¶
GetCustomLabels decodes custom labels.
func (*Agent) IsMySQLTablestatsGroupEnabled ¶
IsMySQLTablestatsGroupEnabled returns true if mysqld_exporter tablestats group collectors should be enabled.
func (*Agent) PKPointer ¶
func (s *Agent) PKPointer() interface{}
PKPointer returns a pointer to primary key field for that record. Returned interface{} value is never untyped nil.
func (*Agent) PKValue ¶
func (s *Agent) PKValue() interface{}
PKValue returns a value of primary key for that record. Returned interface{} value is never untyped nil.
func (*Agent) Pointers ¶
func (s *Agent) Pointers() []interface{}
Pointers returns a slice of pointers to struct or record fields. Returned interface{} values are never untyped nils.
func (*Agent) SetCustomLabels ¶
SetCustomLabels encodes custom labels.
func (*Agent) UnifiedLabels ¶
UnifiedLabels returns combined standard and custom labels with empty labels removed.
type AgentFilters ¶
type AgentFilters struct {
// Return only Agents started by this pmm-agent.
PMMAgentID string
// Return only Agents that provide insights for that Node.
NodeID string
// Return only Agents that provide insights for that Service.
ServiceID string
// Return Agents with provided type.
AgentType *AgentType
}
AgentFilters represents filters for agents list.
type AgentType ¶
type AgentType string
AgentType represents Agent type as stored in databases: pmm-managed's PostgreSQL, qan-api's ClickHouse, and VictoriaMetrics.
const ( PMMAgentType AgentType = "pmm-agent" NodeExporterType AgentType = "node_exporter" MySQLdExporterType AgentType = "mysqld_exporter" MongoDBExporterType AgentType = "mongodb_exporter" PostgresExporterType AgentType = "postgres_exporter" ProxySQLExporterType AgentType = "proxysql_exporter" RDSExporterType AgentType = "rds_exporter" QANMySQLPerfSchemaAgentType AgentType = "qan-mysql-perfschema-agent" QANMySQLSlowlogAgentType AgentType = "qan-mysql-slowlog-agent" QANMongoDBProfilerAgentType AgentType = "qan-mongodb-profiler-agent" QANPostgreSQLPgStatementsAgentType AgentType = "qan-postgresql-pgstatements-agent" QANPostgreSQLPgStatMonitorAgentType AgentType = "qan-postgresql-pgstatmonitor-agent" ExternalExporterType AgentType = "external-exporter" VMAgentType AgentType = "vmagent" )
Agent types (in the same order as in agents.proto).
type ChangeChannelParams ¶
type ChangeChannelParams struct {
EmailConfig *EmailConfig
PagerDutyConfig *PagerDutyConfig
SlackConfig *SlackConfig
WebHookConfig *WebHookConfig
Disabled bool
}
ChangeChannelParams is params for changing existing channel.
type ChangeCommonAgentParams ¶
type ChangeCommonAgentParams struct {
Disabled *bool // true - disable, false - enable, nil - do not change
CustomLabels map[string]string
RemoveCustomLabels bool
DisablePushMetrics *bool
}
ChangeCommonAgentParams contains parameters that can be changed for all Agents.
type ChangeSettingsParams ¶
type ChangeSettingsParams struct {
// We don't save it to db
DisableUpdates bool
DisableTelemetry bool
EnableTelemetry bool
MetricsResolutions MetricsResolutions
DataRetention time.Duration
AWSPartitions []string
SSHKey string
// not url.URL to keep username and password
AlertManagerURL string
RemoveAlertManagerURL bool
// Enable Security Threat Tool
EnableSTT bool
// Disable Security Threat Tool
DisableSTT bool
// List of STT checks to disable
DisableSTTChecks []string
// List of STT checks to enable
EnableSTTChecks []string
// Enable DBaaS features.
EnableDBaaS bool
// Disable DBaaS features.
DisableDBaaS bool
// Percona Platform user email
Email string
// Percona Platform session Id
SessionID string
// LogOut user from Percona Platform, i.e. remove user email and session id
LogOut bool
// EnableVMCache enables caching for vmdb search queries
EnableVMCache bool
// DisableVMCache disables caching for vmdb search queries
DisableVMCache bool
}
ChangeSettingsParams contains values to change data in settings table.
type Channel ¶
type Channel struct {
ID string `reform:"id,pk"`
Summary string `reform:"summary"`
Type ChannelType `reform:"type"`
EmailConfig *EmailConfig `reform:"email_config"`
PagerDutyConfig *PagerDutyConfig `reform:"pagerduty_config"`
SlackConfig *SlackConfig `reform:"slack_config"`
WebHookConfig *WebHookConfig `reform:"webhook_config"`
Disabled bool `reform:"disabled"`
CreatedAt time.Time `reform:"created_at"`
UpdatedAt time.Time `reform:"updated_at"`
}
Channel represents Integrated Alerting Notification Channel configuration.
func ChangeChannel ¶
func ChangeChannel(q *reform.Querier, channelID string, params *ChangeChannelParams) (*Channel, error)
ChangeChannel updates existing notifications channel.
func CreateChannel ¶
func CreateChannel(q *reform.Querier, params *CreateChannelParams) (*Channel, error)
CreateChannel persists notification channel.
func FindChannelByID ¶
FindChannelByID finds Channel by ID.
func FindChannels ¶
FindChannels returns saved notification channels configuration.
func (*Channel) BeforeInsert ¶
BeforeInsert implements reform.BeforeInserter interface.
func (*Channel) BeforeUpdate ¶
BeforeUpdate implements reform.BeforeUpdater interface.
func (*Channel) PKPointer ¶
func (s *Channel) PKPointer() interface{}
PKPointer returns a pointer to primary key field for that record. Returned interface{} value is never untyped nil.
func (*Channel) PKValue ¶
func (s *Channel) PKValue() interface{}
PKValue returns a value of primary key for that record. Returned interface{} value is never untyped nil.
func (*Channel) Pointers ¶
func (s *Channel) Pointers() []interface{}
Pointers returns a slice of pointers to struct or record fields. Returned interface{} values are never untyped nils.
type CreateAgentParams ¶
type CreateAgentParams struct {
PMMAgentID string
NodeID string
ServiceID string
Username string
Password string
CustomLabels map[string]string
TLS bool
TLSSkipVerify bool
TableCountTablestatsGroupLimit int32
QueryExamplesDisabled bool
MaxQueryLogSize int64
AWSAccessKey string
AWSSecretKey string
RDSBasicMetricsDisabled bool
RDSEnhancedMetricsDisabled bool
PushMetrics bool
}
CreateAgentParams params for add common exporter.
type CreateChannelParams ¶
type CreateChannelParams struct {
Summary string
EmailConfig *EmailConfig
PagerDutyConfig *PagerDutyConfig
SlackConfig *SlackConfig
WebHookConfig *WebHookConfig
Disabled bool
}
CreateChannelParams are params for creating new channel.
type CreateExternalExporterParams ¶
type CreateExternalExporterParams struct {
RunsOnNodeID string
ServiceID string
Username string
Password string
Scheme string
MetricsPath string
ListenPort uint32
CustomLabels map[string]string
PushMetrics bool
}
CreateExternalExporterParams params for add external exporter.
type CreateKubernetesClusterParams ¶
CreateKubernetesClusterParams contains all params required to create Kubernetes cluster.
type CreateNodeParams ¶
type CreateNodeParams struct {
NodeName string
MachineID *string
Distro string
NodeModel string
AZ string
ContainerID *string
ContainerName *string
CustomLabels map[string]string
Address string
Region *string
}
CreateNodeParams contains parameters for creating Nodes.
type EmailConfig ¶
EmailConfig is email notification channel configuration.
func (*EmailConfig) Scan ¶
func (c *EmailConfig) Scan(src interface{}) error
Scan implements database/sql.Scanner interface. Should be defined on the pointer.
type HTTPBasicAuth ¶
type HTTPBasicAuth struct {
Username string `json:"username,omitempty"`
Password string `json:"password,omitempty"`
PasswordFile string `json:"password_file,omitempty"`
}
HTTPBasicAuth is HTTP basic authentication configuration.
type HTTPConfig ¶
type HTTPConfig struct {
BasicAuth *HTTPBasicAuth `json:"basic_auth,omitempty"`
BearerToken string `json:"bearer_token,omitempty"`
BearerTokenFile string `json:"bearer_token_file,omitempty"`
TLSConfig *TLSConfig `json:"tls_config,omitempty"`
ProxyURL string `json:"proxy_url,omitempty"`
}
HTTPConfig is HTTP connection configuration.
type KubernetesCluster ¶
type KubernetesCluster struct {
ID string `reform:"id,pk"`
KubernetesClusterName string `reform:"kubernetes_cluster_name"`
KubeConfig string `reform:"kube_config"`
CreatedAt time.Time `reform:"created_at"`
UpdatedAt time.Time `reform:"updated_at"`
}
KubernetesCluster represents a Kubernetes cluster as stored in database.
func CreateKubernetesCluster ¶
func CreateKubernetesCluster(q *reform.Querier, params *CreateKubernetesClusterParams) (*KubernetesCluster, error)
CreateKubernetesCluster creates Kubernetes cluster with provided params.
func FindAllKubernetesClusters ¶
func FindAllKubernetesClusters(q *reform.Querier) ([]*KubernetesCluster, error)
FindAllKubernetesClusters returns all Kubernetes clusters.
func FindKubernetesClusterByName ¶
func FindKubernetesClusterByName(q *reform.Querier, name string) (*KubernetesCluster, error)
FindKubernetesClusterByName finds a Kubernetes cluster with provided name.
func (*KubernetesCluster) AfterFind ¶
func (s *KubernetesCluster) AfterFind() error
AfterFind implements reform.AfterFinder interface.
func (*KubernetesCluster) BeforeInsert ¶
func (s *KubernetesCluster) BeforeInsert() error
BeforeInsert implements reform.BeforeInserter interface.
func (*KubernetesCluster) BeforeUpdate ¶
func (s *KubernetesCluster) BeforeUpdate() error
BeforeUpdate implements reform.BeforeUpdater interface.
func (*KubernetesCluster) HasPK ¶
func (s *KubernetesCluster) HasPK() bool
HasPK returns true if record has non-zero primary key set, false otherwise.
func (*KubernetesCluster) PKPointer ¶
func (s *KubernetesCluster) PKPointer() interface{}
PKPointer returns a pointer to primary key field for that record. Returned interface{} value is never untyped nil.
func (*KubernetesCluster) PKValue ¶
func (s *KubernetesCluster) PKValue() interface{}
PKValue returns a value of primary key for that record. Returned interface{} value is never untyped nil.
func (*KubernetesCluster) Pointers ¶
func (s *KubernetesCluster) Pointers() []interface{}
Pointers returns a slice of pointers to struct or record fields. Returned interface{} values are never untyped nils.
func (*KubernetesCluster) SetPK ¶
func (s *KubernetesCluster) SetPK(pk interface{})
SetPK sets record primary key.
func (KubernetesCluster) String ¶
func (s KubernetesCluster) String() string
String returns a string representation of this struct or record.
func (*KubernetesCluster) Table ¶
func (s *KubernetesCluster) Table() reform.Table
Table returns Table object for that record.
func (*KubernetesCluster) Values ¶
func (s *KubernetesCluster) Values() []interface{}
Values returns a slice of struct or record field values. Returned interface{} values are never untyped nils.
func (*KubernetesCluster) View ¶
func (s *KubernetesCluster) View() reform.View
View returns View object for that struct.
type MetricsResolutions ¶
type MetricsResolutions struct {
HR time.Duration `json:"hr"`
MR time.Duration `json:"mr"`
LR time.Duration `json:"lr"`
}
MetricsResolutions contains standard VictoriaMetrics metrics resolutions.
type Node ¶
type Node struct {
NodeID string `reform:"node_id,pk"`
NodeType NodeType `reform:"node_type"`
NodeName string `reform:"node_name"`
MachineID *string `reform:"machine_id"`
Distro string `reform:"distro"`
NodeModel string `reform:"node_model"`
AZ string `reform:"az"`
CustomLabels []byte `reform:"custom_labels"`
// Node address. Used to construct endpoint for node_exporter.
// For RemoteRDS Nodes contains DBInstanceIdentifier (not DbiResourceId; not endpoint - that's Service address).
Address string `reform:"address"`
CreatedAt time.Time `reform:"created_at"`
UpdatedAt time.Time `reform:"updated_at"`
ContainerID *string `reform:"container_id"` // nil means "unknown"; non-nil value must be unique
ContainerName *string `reform:"container_name"`
Region *string `reform:"region"` // non-nil value must be unique in combination with instance/address
}
Node represents Node as stored in database.
func CheckUniqueNodeInstanceRegion ¶
func CheckUniqueNodeInstanceRegion(q *reform.Querier, instance string, region *string) (*Node, error)
CheckUniqueNodeInstanceRegion checks for uniqueness of instance address and region. This function not only return an error in case of finding an existing node with those paramenters but also returns the Node itself if there is any, because if we are recreating the instance (--force in pmm-admin) we need to know the Node.ID to remove it and its dependencies. This check only applies is region is not empty.
func CreateNode ¶
CreateNode creates a Node.
func FindNodeByID ¶
FindNodeByID finds a Node by ID.
func FindNodeByName ¶
FindNodeByName finds a Node by name.
func FindNodes ¶
func FindNodes(q *reform.Querier, filters NodeFilters) ([]*Node, error)
FindNodes returns Nodes by filters.
func FindNodesByIDs ¶
FindNodesByIDs finds Nodes by IDs.
func (*Node) BeforeInsert ¶
BeforeInsert implements reform.BeforeInserter interface.
func (*Node) BeforeUpdate ¶
BeforeUpdate implements reform.BeforeUpdater interface.
func (*Node) GetCustomLabels ¶
GetCustomLabels decodes custom labels.
func (*Node) PKPointer ¶
func (s *Node) PKPointer() interface{}
PKPointer returns a pointer to primary key field for that record. Returned interface{} value is never untyped nil.
func (*Node) PKValue ¶
func (s *Node) PKValue() interface{}
PKValue returns a value of primary key for that record. Returned interface{} value is never untyped nil.
func (*Node) Pointers ¶
func (s *Node) Pointers() []interface{}
Pointers returns a slice of pointers to struct or record fields. Returned interface{} values are never untyped nils.
func (*Node) SetCustomLabels ¶
SetCustomLabels encodes custom labels.
func (*Node) UnifiedLabels ¶
UnifiedLabels returns combined standard and custom labels with empty labels removed.
type NodeFilters ¶
type NodeFilters struct {
// Return Nodes with provided type.
NodeType *NodeType
}
NodeFilters represents filters for nodes list.
type NodeType ¶
type NodeType string
NodeType represents Node type as stored in databases: pmm-managed's PostgreSQL, qan-api's ClickHouse, and VictoriaMetrics.
type PagerDutyConfig ¶
type PagerDutyConfig struct {
SendResolved bool `json:"send_resolved"`
RoutingKey string `json:"routing_key,omitempty"`
ServiceKey string `json:"service_key,omitempty"`
}
PagerDutyConfig represents PagerDuty channel configuration.
func (*PagerDutyConfig) Scan ¶
func (c *PagerDutyConfig) Scan(src interface{}) error
Scan implements database/sql.Scanner interface. Should be defined on the pointer.
type RemoveMode ¶
type RemoveMode int
RemoveMode defines how Remove functions deal with dependend objects.
const ( // RemoveRestrict returns error if there dependend objects. RemoveRestrict RemoveMode = iota // RemoveCascade removes dependend objects recursively. RemoveCascade )
type Service ¶
type Service struct {
ServiceID string `reform:"service_id,pk"`
ServiceType ServiceType `reform:"service_type"`
ServiceName string `reform:"service_name"`
NodeID string `reform:"node_id"`
Environment string `reform:"environment"`
Cluster string `reform:"cluster"`
ReplicationSet string `reform:"replication_set"`
CustomLabels []byte `reform:"custom_labels"`
ExternalGroup string `reform:"external_group"`
CreatedAt time.Time `reform:"created_at"`
UpdatedAt time.Time `reform:"updated_at"`
Address *string `reform:"address"`
Port *uint16 `reform:"port"`
Socket *string `reform:"socket"`
}
Service represents Service as stored in database.
func AddNewService ¶
func AddNewService(q *reform.Querier, serviceType ServiceType, params *AddDBMSServiceParams) (*Service, error)
AddNewService adds new service to storage.
func FindServiceByID ¶
FindServiceByID finds Service by ID.
func FindServiceByName ¶
FindServiceByName finds Service by Name.
func FindServices ¶
func FindServices(q *reform.Querier, filters ServiceFilters) ([]*Service, error)
FindServices returns Services by filters.
func FindServicesByIDs ¶
FindServicesByIDs finds Services by IDs.
func (*Service) BeforeInsert ¶
BeforeInsert implements reform.BeforeInserter interface.
func (*Service) BeforeUpdate ¶
BeforeUpdate implements reform.BeforeUpdater interface.
func (*Service) GetCustomLabels ¶
GetCustomLabels decodes custom labels.
func (*Service) PKPointer ¶
func (s *Service) PKPointer() interface{}
PKPointer returns a pointer to primary key field for that record. Returned interface{} value is never untyped nil.
func (*Service) PKValue ¶
func (s *Service) PKValue() interface{}
PKValue returns a value of primary key for that record. Returned interface{} value is never untyped nil.
func (*Service) Pointers ¶
func (s *Service) Pointers() []interface{}
Pointers returns a slice of pointers to struct or record fields. Returned interface{} values are never untyped nils.
func (*Service) SetCustomLabels ¶
SetCustomLabels encodes custom labels.
func (*Service) UnifiedLabels ¶
UnifiedLabels returns combined standard and custom labels with empty labels removed.
type ServiceFilters ¶
type ServiceFilters struct {
// Return only Services runs on that Node.
NodeID string
// Return only Services with provided type.
ServiceType *ServiceType
}
ServiceFilters represents filters for services list.
type ServiceType ¶
type ServiceType string
ServiceType represents Service type as stored in databases: pmm-managed's PostgreSQL, qan-api's ClickHouse, and VictoriaMetrics.
const ( MySQLServiceType ServiceType = "mysql" MongoDBServiceType ServiceType = "mongodb" PostgreSQLServiceType ServiceType = "postgresql" ProxySQLServiceType ServiceType = "proxysql" ExternalServiceType ServiceType = "external" )
Service types (in the same order as in services.proto).
type Settings ¶
type Settings struct {
Telemetry struct {
Disabled bool `json:"disabled"`
UUID string `json:"uuid"`
} `json:"telemetry"`
MetricsResolutions MetricsResolutions `json:"metrics_resolutions"`
DataRetention time.Duration `json:"data_retention"`
AWSPartitions []string `json:"aws_partitions"`
AWSInstanceChecked bool `json:"aws_instance_checked"`
SSHKey string `json:"ssh_key"`
// not url.URL to keep username and password
AlertManagerURL string `json:"alert_manager_url"`
VictoriaMetrics struct {
CacheEnabled bool `json:"cache_enabled"`
} `json:"victoria_metrics"`
// Saas config options
SaaS struct {
// Percona Platform user email
Email string `json:"email"`
// Percona Platform session Id
SessionID string `json:"session_id"`
// Security Threat Tool enabled
STTEnabled bool `json:"stt_enabled"`
// List of disabled STT checks
DisabledSTTChecks []string `json:"disabled_stt_checks"`
} `json:"sass"`
// DBaaS config options
DBaaS struct {
Enabled bool `json:"enabled"`
} `json:"dbaas"`
}
Settings contains PMM Server settings.
func GetSettings ¶
GetSettings returns current PMM Server settings.
func UpdateSettings ¶
func UpdateSettings(q reform.DBTX, params *ChangeSettingsParams) (*Settings, error)
UpdateSettings updates only non-zero, non-empty values.
type SetupDBParams ¶
type SetupDBParams struct {
Logf reform.Printf
Username string
Password string
SetupFixtures SetupFixturesMode
MigrationVersion *int
}
SetupDBParams represents SetupDB parameters.
type SetupFixturesMode ¶
type SetupFixturesMode int
SetupFixturesMode defines if SetupDB adds initial data to the database or not.
const ( // SetupFixtures adds initial data to the database. SetupFixtures SetupFixturesMode = iota // SkipFixtures skips adding initial data to the database. Useful for tests. SkipFixtures )
type SlackConfig ¶
type SlackConfig struct {
SendResolved bool `json:"send_resolved"`
Channel string `json:"channel"`
}
SlackConfig is slack notification channel configuration.
func (*SlackConfig) Scan ¶
func (c *SlackConfig) Scan(src interface{}) error
Scan implements database/sql.Scanner interface. Should be defined on the pointer.
type TLSConfig ¶
type TLSConfig struct {
CaFile string `json:"ca_file,omitempty"`
CertFile string `json:"cert_file,omitempty"`
KeyFile string `json:"key_file,omitempty"`
ServerName string `json:"server_name,omitempty"`
InsecureSkipVerify bool `json:"insecure_skip_verify,omitempty"`
}
TLSConfig is TLS configuration.
type VictoriaMetricsParams ¶
type VictoriaMetricsParams struct {
// VMAlertFlags additional flags for VMAlert.
VMAlertFlags []string
// BaseConfigPath defines path for basic prometheus config.
BaseConfigPath string
}
VictoriaMetricsParams - defines flags and settings for victoriametrics.
func NewVictoriaMetricsParams ¶
func NewVictoriaMetricsParams(basePath string) (*VictoriaMetricsParams, error)
NewVictoriaMetricsParams - returns configuration params for VictoriaMetrics.
func (*VictoriaMetricsParams) UpdateParams ¶
func (vmp *VictoriaMetricsParams) UpdateParams() error
UpdateParams - reads configuration file and updates corresponding flags.
type WebHookConfig ¶
type WebHookConfig struct {
SendResolved bool ` json:"send_resolved"`
URL string ` json:"url"`
HTTPConfig *HTTPConfig ` json:"http_config,omitempty"`
MaxAlerts int32 ` json:"max_alerts"`
}
WebHookConfig is webhook notification channel configuration.
func (*WebHookConfig) Scan ¶
func (c *WebHookConfig) Scan(src interface{}) error
Scan implements database/sql.Scanner interface. Should be defined on the pointer.
Source Files
¶
- action_helpers.go
- action_models.go
- action_models_reform.go
- agent_helpers.go
- agent_model.go
- agent_model_reform.go
- channel.go
- channel_helpers.go
- channel_reform.go
- database.go
- dsn_helpers.go
- kubernetes_helpers.go
- kubernetes_models.go
- kubernetes_models_reform.go
- models.go
- node_helpers.go
- node_model.go
- node_model_reform.go
- service_helpers.go
- service_model.go
- service_model_reform.go
- settings.go
- settings_helpers.go
- victoriametrics.go