Documentation ¶
Index ¶
- Constants
- Variables
- func ContainsIn(slices []string, expected string) bool
- func GetLabel(group string) (string, bool)
- func ValidateAMConfigReceiver(receiver amconfig.Receiver) error
- func ValidateAlertRule(rule request.AlertRule) error
- type AlertGroup
- type AlertRules
- type Metadata
- func (m *Metadata) AddAMConfigReceiver(configFile string, receiver amconfig.Receiver) error
- func (m *Metadata) AddAlertRule(configFile string, alertRule request.AlertRule) error
- func (m *Metadata) AlertManagerConfigMarshalToYaml(configFile string) ([]byte, error)
- func (m *Metadata) AlertRuleMarshalToYaml(configFile string) ([]byte, error)
- func (m *Metadata) CheckAlertRuleExists(configFile, group, alert string) (bool, error)
- func (m *Metadata) DeleteAMConfigReceiver(configFile string, name string) (bool, error)
- func (m *Metadata) DeleteAlertRule(configFile string, group, alert string) bool
- func (m *Metadata) GetAMConfigReceiver(configFile string, filter *request.AMConfigReceiverFilter, ...) ([]amconfig.Receiver, int)
- func (m *Metadata) GetAlertRules(configFile string, filter *request.AlertRuleFilter, ...) ([]*request.AlertRule, int)
- func (m *Metadata) SetAMConfig(configFile string, configs *amconfig.Config)
- func (m *Metadata) SetAlertRules(configFile string, rules *AlertRules)
- func (m *Metadata) UpdateAMConfigReceiver(configFile string, receiver amconfig.Receiver, oldName string) error
- func (m *Metadata) UpdateAlertRule(configFile string, alertRule request.AlertRule, oldGroup, oldAlert string) error
- type NoneAPI
- func (n *NoneAPI) AddAMConfigReceiver(configFile string, receiver amconfig.Receiver) error
- func (n *NoneAPI) AddAlertRule(configFile string, alertRule request.AlertRule) error
- func (n *NoneAPI) CheckAlertRule(configFile, group, alert string) (bool, error)
- func (n *NoneAPI) DeleteAMConfigReceiver(configFile string, name string) error
- func (n *NoneAPI) DeleteAlertRule(configFile string, group string, alert string) error
- func (n *NoneAPI) GetAMConfigReceiver(configFile string, filter *request.AMConfigReceiverFilter, ...) ([]amconfig.Receiver, int)
- func (n *NoneAPI) GetAlertRuleConfigFile(alertRuleFile string) (map[string]string, error)
- func (n *NoneAPI) GetAlertRules(configFile string, filter *request.AlertRuleFilter, ...) ([]*request.AlertRule, int)
- func (n *NoneAPI) GetNamespaceInfo(namespace string) (*v1.Namespace, error)
- func (n *NoneAPI) GetNamespaceList() (*v1.NamespaceList, error)
- func (n *NoneAPI) GetPodInfo(namespace string, pod string) (*v1.Pod, error)
- func (n *NoneAPI) GetPodList(namespace string) (*v1.PodList, error)
- func (n *NoneAPI) GetVectorConfigFile() (map[string]string, error)
- func (n *NoneAPI) SyncNow() error
- func (n *NoneAPI) UpdateAMConfigReceiver(configFile string, receiver amconfig.Receiver, oldName string) error
- func (n *NoneAPI) UpdateAlertRule(configFile string, alertRule request.AlertRule, oldGroup, oldAlert string) error
- func (n *NoneAPI) UpdateAlertRuleConfigFile(configFile string, content []byte) error
- func (n *NoneAPI) UpdateVectorConfigFile(content []byte) error
- type Repo
Constants ¶
View Source
const ( AuthTypeNone string = "none" AuthTypeServiceAccount string = "serviceAccount" AuthTypeKubeConfig string = "kubeConfig" // DefaultKubeConfigPath Default kubeconfig path DefaultKubeConfigPath string = "~/.kube/config" // DefaultMetaSetting DefaultAPONS string = "apo" DefaultCMNAME string = "apo-victoria-metrics-alert-server-alert-rules-config" DefaultAlertRuleFile string = "alert-rules.yaml" DefaultAMCMName string = "apo-alertmanager-config" DefaultAMConfigFile string = "alertmanager.yaml" DefaultVCNAME string = "apo-vector-config" DefaultVCConfigFile string = "aggregator.yaml" )
View Source
const ( AppLabelVal = "应用指标" InfraLabelVal = "主机相关" NetLabelVal = "网络相关" ContainerLabelVal = "容器相关" CustomLabelVal = "用户自定义组" AppLabelKey = "app" InfraLabelKey = "infra" NetLabelKey = "network" ContainerLabelKey = "container" CustomLabelKey = "custom" )
Variables ¶
View Source
var ErrKubernetesRepoNotReady = errors.New("kubernetes repo is not ready")
View Source
var GroupsLabel = map[string]string{ AppLabelKey: AppLabelVal, InfraLabelKey: InfraLabelVal, NetLabelKey: NetLabelVal, ContainerLabelKey: ContainerLabelVal, CustomLabelKey: CustomLabelVal, }
Functions ¶
func ContainsIn ¶
func ValidateAlertRule ¶
Types ¶
type AlertGroup ¶
type AlertRules ¶
type AlertRules struct { Rules []*request.AlertRule Groups []AlertGroup }
func ParseAlertRules ¶
func ParseAlertRules(strContent string) (*AlertRules, error)
type Metadata ¶
type Metadata struct { AlertRulesMap map[string]*AlertRules AMConfigMap map[string]*amconfig.Config // contains filtered or unexported fields }
func (*Metadata) AddAMConfigReceiver ¶
func (*Metadata) AddAlertRule ¶
func (*Metadata) AlertManagerConfigMarshalToYaml ¶
func (*Metadata) AlertRuleMarshalToYaml ¶
func (*Metadata) CheckAlertRuleExists ¶
func (*Metadata) DeleteAMConfigReceiver ¶
func (*Metadata) DeleteAlertRule ¶
func (*Metadata) GetAMConfigReceiver ¶
func (*Metadata) GetAlertRules ¶
func (*Metadata) SetAMConfig ¶
func (*Metadata) SetAlertRules ¶
func (m *Metadata) SetAlertRules(configFile string, rules *AlertRules)
func (*Metadata) UpdateAMConfigReceiver ¶
type NoneAPI ¶
type NoneAPI struct{}
func (*NoneAPI) AddAMConfigReceiver ¶
func (*NoneAPI) AddAlertRule ¶
func (*NoneAPI) CheckAlertRule ¶
func (*NoneAPI) DeleteAMConfigReceiver ¶
DeleteAMConfigReceiver implements Repo.
func (*NoneAPI) DeleteAlertRule ¶
func (*NoneAPI) GetAMConfigReceiver ¶
func (n *NoneAPI) GetAMConfigReceiver(configFile string, filter *request.AMConfigReceiverFilter, pageParam *request.PageParam, syncNow bool) ([]amconfig.Receiver, int)
GetAMConfigReceiver implements Repo.
func (*NoneAPI) GetAlertRuleConfigFile ¶
GetAlertRuleConfigFile implements Repo.
func (*NoneAPI) GetAlertRules ¶
func (*NoneAPI) GetNamespaceInfo ¶
func (*NoneAPI) GetNamespaceList ¶
func (n *NoneAPI) GetNamespaceList() (*v1.NamespaceList, error)
func (*NoneAPI) GetPodInfo ¶
func (*NoneAPI) GetVectorConfigFile ¶
GetVectorConfigFile implements Repo.
func (*NoneAPI) UpdateAMConfigReceiver ¶
func (n *NoneAPI) UpdateAMConfigReceiver(configFile string, receiver amconfig.Receiver, oldName string) error
UpdateAMConfigReceiver implements Repo.
func (*NoneAPI) UpdateAlertRule ¶
func (*NoneAPI) UpdateAlertRuleConfigFile ¶
UpdateAlertRuleConfigFile implements Repo.
func (*NoneAPI) UpdateVectorConfigFile ¶
UpdateVectorConfigFile implements Repo.
type Repo ¶
type Repo interface { // Sync with K8sAPIServer SyncNow() error GetAlertRuleConfigFile(alertRuleFile string) (map[string]string, error) UpdateAlertRuleConfigFile(configFile string, content []byte) error GetVectorConfigFile() (map[string]string, error) UpdateVectorConfigFile(content []byte) error GetAlertRules(configFile string, filter *request.AlertRuleFilter, pageParam *request.PageParam, syncNow bool) ([]*request.AlertRule, int) UpdateAlertRule(configFile string, alertRule request.AlertRule, oldGroup, oldAlert string) error AddAlertRule(configFile string, alertRule request.AlertRule) error DeleteAlertRule(configFile string, group, alert string) error CheckAlertRule(configFile, group, alert string) (bool, error) GetAMConfigReceiver(configFile string, filter *request.AMConfigReceiverFilter, pageParam *request.PageParam, syncNow bool) ([]amconfig.Receiver, int) AddAMConfigReceiver(configFile string, receiver amconfig.Receiver) error UpdateAMConfigReceiver(configFile string, receiver amconfig.Receiver, oldName string) error DeleteAMConfigReceiver(configFile string, name string) error GetNamespaceList() (*v1.NamespaceList, error) GetNamespaceInfo(namespace string) (*v1.Namespace, error) GetPodList(namespace string) (*v1.PodList, error) GetPodInfo(namespace string, pod string) (*v1.Pod, error) }
Click to show internal directories.
Click to hide internal directories.