예제 #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
}
예제 #2
0
파일: alerting.go 프로젝트: pjjw/prometheus
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
}
예제 #3
0
파일: alerting.go 프로젝트: pjjw/prometheus
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))
}
예제 #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
}
예제 #5
0
파일: alerting.go 프로젝트: pjjw/prometheus
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)
}
예제 #6
0
func (node *MatrixSelector) String() string {
	vectorString := (&VectorSelector{labelMatchers: node.labelMatchers}).String()
	intervalString := fmt.Sprintf("[%s]", utility.DurationToString(node.interval))
	return vectorString + intervalString
}
예제 #7
0
func (node *MatrixLiteral) String() string {
	vectorString := (&VectorLiteral{labels: node.labels}).String()
	intervalString := fmt.Sprintf("['%v']", utility.DurationToString(node.interval))
	return vectorString + intervalString
}