Skip to content

Commit

Permalink
add some TODOs
Browse files Browse the repository at this point in the history
  • Loading branch information
jacksontj committed Aug 16, 2023
1 parent 73e527c commit 105bcc5
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions cmd/promxy/tmp.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ func (q *AlertQuerier) Select(sortSeries bool, hints *storage.SelectHints, match

// Now we need to "backfill" the data (regenerate the series that it would have queried)

// TODO: have to loop over groups to get interval
var (
matchingGroupIdx int
matchingRuleIdx int
Expand All @@ -83,6 +82,7 @@ func (q *AlertQuerier) Select(sortSeries bool, hints *storage.SelectHints, match
FIND_RULE:
for i, group := range q.m.RuleGroups() {
for ii, rule := range group.AlertingRules() {
// TODO: what to do with overlapping names? Maybe check labels against matchers?
if rule.Name() == alertname {
matchingGroupIdx = i
matchingRuleIdx = ii
Expand All @@ -93,6 +93,7 @@ FIND_RULE:
}
}

// TODO: return empty set?
if matchingRule == nil {
panic("not found")
}
Expand All @@ -108,9 +109,6 @@ FIND_RULE:
return proxyquerier.NewSeriesSet(nil, nil, err)
}

// Can't use this; as it acquires a lock -- which this is trying to do. We could use it but it would have to be
// *prior* to rule manager start (which would probably break normal backfill)
// TODO: mess with https://pkg.go.dev/github.com/prometheus/prometheus@v0.46.0/rules#AlertingRule.Eval ?
result = query.Exec(context.TODO())
q.ruleValues[key] = result
}
Expand All @@ -119,7 +117,7 @@ FIND_RULE:
return proxyquerier.NewSeriesSet(nil, result.Warnings, result.Err)
}

// TODO: filter val to matchers!
// Now we need to filter+convert the result
var val model.Value
// convert promql.Value -> model.Value
switch v := result.Value.(type) {
Expand Down Expand Up @@ -153,7 +151,8 @@ FIND_RULE:
metric[model.MetricNameLabel] = model.LabelValue(matchers[0].Value)
metric[model.AlertNameLabel] = model.LabelValue(matchers[1].Value)

// TODO: check that this is sufficient?
// TODO: check that the rule manager doesn't add any more labels
// Add the labels which the alert would add
for _, label := range matchingRule.Labels() {
metric[model.LabelName(label.Name)] = model.LabelValue(label.Value)
}
Expand All @@ -162,7 +161,8 @@ FIND_RULE:
activeAt model.SampleValue
lastPoint time.Time
)
// TODO: the value isn't the actual value here -- its a number that emcapsulates when it cleared
// Now we have to convert the *actual* result into the series that is stored for the ALERTS
// TODO: move to another method (with its own tests)
samples := make([]model.SamplePair, len(item.Points))
for x, sample := range item.Points {
sampleTime := model.Time(sample.T).Time()
Expand Down

0 comments on commit 105bcc5

Please sign in to comment.