-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
temp commit for compute metrics work
- Loading branch information
1 parent
3d8983f
commit 44cc2fa
Showing
18 changed files
with
178 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package metrics_test | ||
|
||
import ( | ||
"bytes" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
"github.com/rancher/opni/pkg/alerting/metrics" | ||
) | ||
|
||
var _ = Describe("compute alerting options pipeline & compute alerts construction", func() { | ||
When("users want to create cpu compute alerts", func() { | ||
Specify("alerting/metrics package should export cpu alerts", func() { | ||
_, templateOk := metrics.ComputeNameToTemplate["cpu"] | ||
_, optionsOk := metrics.ComputeNameToOpts["cpu"] | ||
Expect((templateOk && optionsOk)).To(BeTrue()) | ||
}) | ||
|
||
Specify("cpu alerts should have parsed an available template", func() { | ||
tmpl := metrics.ComputeNameToTemplate["cpu"] | ||
Expect(tmpl).NotTo(BeNil()) | ||
definedTmpls := tmpl.Templates() | ||
Expect(definedTmpls).NotTo(HaveLen(0)) | ||
}) | ||
|
||
Specify("The template should be executed from options", func() { | ||
tmpl := metrics.ComputeNameToTemplate["cpu"] | ||
opts := metrics.ComputeNameToOpts["cpu"] | ||
var b bytes.Buffer | ||
err := tmpl.Execute(&b, opts) | ||
Expect(err).NotTo(HaveOccurred()) | ||
}) | ||
|
||
Specify("valid inputs should construct valid promQL", func() { | ||
validInputs := []metrics.CpuRuleOptions{ | ||
{ | ||
Node: []string{""}, | ||
}, | ||
} | ||
|
||
for _, input := range validInputs { | ||
tmpl := metrics.ComputeNameToTemplate["cpu"] | ||
var b bytes.Buffer | ||
err := tmpl.Execute(&b, input) | ||
Expect(err).NotTo(HaveOccurred()) | ||
Expect(b.String()).NotTo(Equal("")) | ||
} | ||
}) | ||
|
||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
sum( | ||
rate( | ||
node_cpu_seconds_total{mode={{ .UsageMode }}}[{{ .Interval }}] | ||
) | ||
) | ||
BY (__tenant_id__) / ON(__tenant_id__) GROUP_LEFT() | ||
sum( | ||
rate( | ||
node_cpu_seconds_total[{{ .Interval }}] | ||
) | ||
) | ||
BY (__tenant_id__) | ||
|
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.