rules/alerting.go
func NewAlertingRule(
	name string, vec promql.Expr, hold time.Duration,
	labels, annotations, externalLabels labels.Labels,
	restored bool, logger log.Logger,
) *AlertingRule {
	el := make(map[string]string, len(externalLabels))
	for _, lbl := range externalLabels {
		el[lbl.Name] = lbl.Value
	}

	return &AlertingRule{
		name:           name,
		vector:         vec,
		holdDuration:   hold,
		labels:         labels,
		annotations:    annotations,
		externalLabels: el,
		health:         HealthUnknown,
		active:         map[uint64]*Alert{},
		logger:         logger,
		restored:       restored,
	}
}
func NewAlertingRule(
	name string, vec promql.Expr, hold time.Duration,
	labels, annotations, externalLabels labels.Labels,
	restored bool, logger log.Logger,
) *AlertingRule {
	el := make(map[string]string, len(externalLabels))
	for _, lbl := range externalLabels {
		el[lbl.Name] = lbl.Value
	}

	return &AlertingRule{
		name:           name,
		vector:         vec,
		holdDuration:   hold,
		labels:         labels,
		annotations:    annotations,
		externalLabels: el,
		health:         HealthUnknown,
		active:         map[uint64]*Alert{},
		logger:         logger,
		restored:       restored,
	}
}
// NewAlertingRule constructs a new AlertingRule.