Documentation ¶
Overview ¶
Copyright © 2021 NAME HERE <EMAIL ADDRESS>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2021 NAME HERE <EMAIL ADDRESS>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2021 NAME HERE <EMAIL ADDRESS>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2021 NAME HERE <EMAIL ADDRESS>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Variables
- func GetAlertGroups(resourcesNames []string, outputFlag string, groupFile string, ...)
- func GetAlertRules(resourcesNames []string, outputFlag string, groupsNames string, ...)
- type AlertingRule
- type FilteredRulesList
- type Label
- type Labels
- type PromAlert
- type Rule
- type RuleGroup
- type RuleHealth
Constants ¶
This section is empty.
Variables ¶
var AlertCmd = &cobra.Command{ Use: "alert", Aliases: []string{"alerts"}, Run: func(cmd *cobra.Command, args []string) { cmd.Help() os.Exit(0) }, }
alertCmd represents the alert command
var GroupFilename, RuleState, GroupName string
var GroupSubCmd = &cobra.Command{ Use: "group", Aliases: []string{"groups"}, Run: func(cmd *cobra.Command, args []string) { resourcesNames := args monitoringExist, _ := helpers.Exists(vars.MustGatherRootPath + "/monitoring") if !monitoringExist { fmt.Println("Path '" + vars.MustGatherRootPath + "/monitoring' does not exist.") os.Exit(1) } alertsFilePath := vars.MustGatherRootPath + "/monitoring/alerts.json" alertsFilePathExist, _ := helpers.Exists(alertsFilePath) if !alertsFilePathExist { alertsFilePath = vars.MustGatherRootPath + "/monitoring/prometheus/rules.json" alertsFilePathExist, _ := helpers.Exists(alertsFilePath) if !alertsFilePathExist { fmt.Println("Prometheus rules not found in must-gather.") os.Exit(1) } } GetAlertGroups(resourcesNames, vars.OutputStringVar, GroupFilename, alertsFilePath) }, }
var RuleSubCmd = &cobra.Command{ Use: "rule", Aliases: []string{"rules"}, Run: func(cmd *cobra.Command, args []string) { resourcesNames := args monitoringExist, _ := helpers.Exists(vars.MustGatherRootPath + "/monitoring") if !monitoringExist { fmt.Println("Path '" + vars.MustGatherRootPath + "/monitoring' does not exist.") os.Exit(1) } alertsFilePath := vars.MustGatherRootPath + "/monitoring/alerts.json" alertsFilePathExist, _ := helpers.Exists(alertsFilePath) if !alertsFilePathExist { alertsFilePath = vars.MustGatherRootPath + "/monitoring/prometheus/rules.json" alertsFilePathExist, _ := helpers.Exists(alertsFilePath) if !alertsFilePathExist { fmt.Println("Prometheus rules not found in must-gather.") os.Exit(1) } } GetAlertRules(resourcesNames, vars.OutputStringVar, GroupName, RuleState, alertsFilePath) }, }
Functions ¶
func GetAlertGroups ¶
Types ¶
type AlertingRule ¶
type AlertingRule struct { // State can be "pending", "firing", "inactive". State string `json:"state"` Name string `json:"name"` Query string `json:"query"` Duration float64 `json:"duration"` Labels Labels `json:"labels"` Annotations Labels `json:"annotations"` Alerts []*PromAlert `json:"alerts"` Health RuleHealth `json:"health"` LastError string `json:"lastError,omitempty"` EvaluationTime float64 `json:"evaluationTime"` LastEvaluation time.Time `json:"lastEvaluation"` // Type of an alertingRule is always "alerting". Type string `json:"type"` }
type FilteredRulesList ¶
type FilteredRulesList struct {
Data []Rule `json:"data"`
}
type Labels ¶
type Labels []Label
Labels is a sorted set of labels. Order has to be guaranteed upon instantiation.
type RuleGroup ¶
type RuleGroup struct { Name string `json:"name"` File string `json:"file"` // In order to preserve rule ordering, while exposing type (alerting or recording) // specific properties, both alerting and recording rules are exposed in the // same array. Rules []Rule `json:"rules"` Interval float64 `json:"interval"` Limit int `json:"limit"` EvaluationTime float64 `json:"evaluationTime"` LastEvaluation time.Time `json:"lastEvaluation"` }
type RuleHealth ¶
type RuleHealth string
const ( HealthUnknown RuleHealth = "unknown" HealthGood RuleHealth = "ok" HealthBad RuleHealth = "err" )
The possible health states of a rule based on the last execution.