Skip to content

[pull] main from prometheus:main #59

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rules/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@
externalLabels,
externalURL,
!shouldRestore,
m.logger.With("alert", r.Alert),
m.logger.With("alert", r.Alert.Value),

Check failure on line 345 in rules/manager.go

View workflow job for this annotation

GitHub Actions / golangci-lint

r.Alert.Value undefined (type string has no field or method Value)) (typecheck)

Check failure on line 345 in rules/manager.go

View workflow job for this annotation

GitHub Actions / golangci-lint

r.Alert.Value undefined (type string has no field or method Value)) (typecheck)

Check failure on line 345 in rules/manager.go

View workflow job for this annotation

GitHub Actions / golangci-lint

r.Alert.Value undefined (type string has no field or method Value) (typecheck)

Check failure on line 345 in rules/manager.go

View workflow job for this annotation

GitHub Actions / golangci-lint

r.Alert.Value undefined (type string has no field or method Value)) (typecheck)

Check failure on line 345 in rules/manager.go

View workflow job for this annotation

GitHub Actions / golangci-lint

r.Alert.Value undefined (type string has no field or method Value)) (typecheck)

Check failure on line 345 in rules/manager.go

View workflow job for this annotation

GitHub Actions / golangci-lint

r.Alert.Value undefined (type string has no field or method Value)) (typecheck)

Check failure on line 345 in rules/manager.go

View workflow job for this annotation

GitHub Actions / golangci-lint

r.Alert.Value undefined (type string has no field or method Value)) (typecheck)

Check failure on line 345 in rules/manager.go

View workflow job for this annotation

GitHub Actions / golangci-lint

r.Alert.Value undefined (type string has no field or method Value) (typecheck)

Check failure on line 345 in rules/manager.go

View workflow job for this annotation

GitHub Actions / golangci-lint

r.Alert.Value undefined (type string has no field or method Value)) (typecheck)

Check failure on line 345 in rules/manager.go

View workflow job for this annotation

GitHub Actions / golangci-lint

r.Alert.Value undefined (type string has no field or method Value)) (typecheck)

Check failure on line 345 in rules/manager.go

View workflow job for this annotation

GitHub Actions / Go tests on Windows

r.Alert.Value undefined (type string has no field or method Value)

Check failure on line 345 in rules/manager.go

View workflow job for this annotation

GitHub Actions / Go tests on Windows

r.Alert.Value undefined (type string has no field or method Value)
))
continue
}
Expand Down
28 changes: 22 additions & 6 deletions template/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,14 +281,30 @@ func NewTemplateExpander(
}
}

type templateData struct {
Labels map[string]string
ExternalLabels map[string]string
ExternalURL string
Value interface{}
}

// String implements fmt.Stringer interface.
func (t templateData) String() string {
labelsString := func(labels map[string]string) string {
// model.LabelSet has a ready String() method, that we can use.
labelSet := make(model.LabelSet, len(t.Labels))
for k, v := range t.Labels {
labelSet[model.LabelName(k)] = model.LabelValue(v)
}
return labelSet.String()
}

return fmt.Sprintf("<Labels: %s, ExternalLabels: %s, ExternalURL: %s, Value: %v>", labelsString(t.Labels), labelsString(t.ExternalLabels), t.ExternalURL, t.Value)
}

// AlertTemplateData returns the interface to be used in expanding the template.
func AlertTemplateData(labels, externalLabels map[string]string, externalURL string, smpl promql.Sample) interface{} {
res := struct {
Labels map[string]string
ExternalLabels map[string]string
ExternalURL string
Value interface{}
}{
res := templateData{
Labels: labels,
ExternalLabels: externalLabels,
ExternalURL: externalURL,
Expand Down
Loading