Beispiel #1
0
func (global *GlobalConfig) ToString(indent int) string {
	str := indentStr(indent, "global {\n")
	str += indentStr(indent+1, "scrape_interval = \"%s\"\n", utility.DurationToString(global.ScrapeInterval))
	str += indentStr(indent+1, "evaluation_interval = \"%s\"\n", utility.DurationToString(global.EvaluationInterval))
	if len(global.Labels) > 0 {
		str += labelsToString(indent+1, global.Labels)
	}
	str += indentStr(indent+1, "rule_files = [\n")
	str += stringListToString(indent+2, global.RuleFiles)
	str += indentStr(indent+1, "]\n")
	str += indentStr(indent, "}\n")
	return str
}
Beispiel #2
0
func (rule *AlertingRule) ToDotGraph() string {
	graph := fmt.Sprintf(`digraph "Rules" {
	  %#p[shape="box",label="ALERT %s IF FOR %s"];
		%#p -> %#p;
		%s
	}`, &rule, rule.name, utility.DurationToString(rule.holdDuration), &rule, rule.vector, rule.vector.NodeTreeToDotGraph())
	return graph
}
Beispiel #3
0
func (rule *AlertingRule) HTMLSnippet() template.HTML {
	alertMetric := clientmodel.Metric{
		clientmodel.MetricNameLabel: AlertMetricName,
		AlertNameLabel:              clientmodel.LabelValue(rule.name),
	}
	return template.HTML(fmt.Sprintf(
		`ALERT <a href="%s">%s</a> IF <a href="%s">%s</a> FOR %s WITH %s`,
		ConsoleLinkForExpression(alertMetric.String()),
		rule.name,
		ConsoleLinkForExpression(rule.vector.String()),
		rule.vector,
		utility.DurationToString(rule.holdDuration),
		rule.Labels))
}
Beispiel #4
0
func (job *JobConfig) ToString(indent int) string {
	str := indentStr(indent, "job {\n")
	str += indentStr(indent+1, "name = \"%v\"\n", job.Name)
	str += indentStr(indent+1, "scrape_interval = \"%s\"\n", utility.DurationToString(job.ScrapeInterval))
	for _, targets := range job.Targets {
		str += indentStr(indent+1, "targets {\n")
		str += indentStr(indent+2, "endpoints = [\n")
		str += stringListToString(indent+3, targets.Endpoints)
		str += indentStr(indent+2, "]\n")
		if len(targets.Labels) > 0 {
			str += labelsToString(indent+2, targets.Labels)
		}
		str += indentStr(indent+1, "}\n")
	}
	str += indentStr(indent, "}\n")
	return str
}
Beispiel #5
0
func (rule *AlertingRule) String() string {
	return fmt.Sprintf("ALERT %s IF %s FOR %s WITH %s", rule.name, rule.vector, utility.DurationToString(rule.holdDuration), rule.Labels)
}
Beispiel #6
0
func (node *MatrixSelector) String() string {
	vectorString := (&VectorSelector{labelMatchers: node.labelMatchers}).String()
	intervalString := fmt.Sprintf("[%s]", utility.DurationToString(node.interval))
	return vectorString + intervalString
}
Beispiel #7
0
func (node *MatrixLiteral) String() string {
	vectorString := (&VectorLiteral{labels: node.labels}).String()
	intervalString := fmt.Sprintf("['%v']", utility.DurationToString(node.interval))
	return vectorString + intervalString
}