Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
sloth
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GitHub Mirror
slok
sloth
Commits
645eef4a
Unverified
Commit
645eef4a
authored
2 months ago
by
Xabier Larrakoetxea
Browse files
Options
Downloads
Patches
Plain Diff
Add the original SLO group source information to the plugin request
Signed-off-by:
Xabier Larrakoetxea
<
me@slok.dev
>
parent
a9bd6024
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
internal/app/generate/generate.go
+3
-2
3 additions, 2 deletions
internal/app/generate/generate.go
internal/app/generate/process.go
+2
-0
2 additions, 0 deletions
internal/app/generate/process.go
pkg/prometheus/plugin/slo/v1/v1.go
+4
-0
4 additions, 0 deletions
pkg/prometheus/plugin/slo/v1/v1.go
with
9 additions
and
2 deletions
internal/app/generate/generate.go
+
3
−
2
View file @
645eef4a
...
...
@@ -175,7 +175,7 @@ func (s Service) Generate(ctx context.Context, r Request) (*Response, error) {
slo
.
Labels
=
utilsdata
.
MergeLabels
(
slo
.
Labels
,
r
.
ExtraLabels
)
// Generate SLO result.
result
,
err
:=
s
.
generateSLO
(
ctx
,
r
.
Info
,
slo
)
result
,
err
:=
s
.
generateSLO
(
ctx
,
r
.
Info
,
r
.
SLOGroup
,
slo
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"could not generate %q slo: %w"
,
slo
.
ID
,
err
)
}
...
...
@@ -188,7 +188,7 @@ func (s Service) Generate(ctx context.Context, r Request) (*Response, error) {
},
nil
}
func
(
s
Service
)
generateSLO
(
ctx
context
.
Context
,
info
model
.
Info
,
slo
model
.
PromSLO
)
(
*
model
.
PromSLORules
,
error
)
{
func
(
s
Service
)
generateSLO
(
ctx
context
.
Context
,
info
model
.
Info
,
sloGroup
model
.
PromSLOGroup
,
slo
model
.
PromSLO
)
(
*
model
.
PromSLORules
,
error
)
{
logger
:=
s
.
logger
.
WithCtxValues
(
ctx
)
.
WithValues
(
log
.
Kv
{
"slo"
:
slo
.
ID
})
// Generate the MWMB alerts.
...
...
@@ -242,6 +242,7 @@ func (s Service) generateSLO(ctx context.Context, info model.Info, slo model.Pro
Info
:
info
,
MWMBAlertGroup
:
*
as
,
SLO
:
slo
,
SLOGroup
:
sloGroup
,
}
res
:=
&
SLOProcessorResult
{}
for
_
,
p
:=
range
sloProcessors
{
...
...
This diff is collapsed.
Click to expand it.
internal/app/generate/process.go
+
2
−
0
View file @
645eef4a
...
...
@@ -13,6 +13,7 @@ import (
type
SLOProcessorRequest
struct
{
Info
model
.
Info
SLO
model
.
PromSLO
SLOGroup
model
.
PromSLOGroup
MWMBAlertGroup
model
.
MWMBAlertGroup
}
type
SLOProcessorResult
struct
{
...
...
@@ -51,6 +52,7 @@ func NewSLOProcessorFromSLOPluginV1(pluginFactory pluginslov1.PluginFactory, log
Info
:
req
.
Info
,
SLO
:
req
.
SLO
,
MWMBAlertGroup
:
req
.
MWMBAlertGroup
,
OriginalSource
:
req
.
SLOGroup
.
OriginalSource
,
}
rs
:=
&
pluginslov1
.
Result
{
SLORules
:
res
.
SLORules
,
...
...
This diff is collapsed.
Click to expand it.
pkg/prometheus/plugin/slo/v1/v1.go
+
4
−
0
View file @
645eef4a
...
...
@@ -29,6 +29,10 @@ type AppUtils struct {
type
Request
struct
{
// Info about the application and execution, normally used as metadata.
Info
model
.
Info
// OriginalSource is the original specification of the SLO came from, this is informative data that
// can be used to make decision on plugins, it should be used only as RO.
// The information used on the generation is the SLO model itself not this one.
OriginalSource
model
.
PromSLOGroupSource
// The SLO to process and generate the final Prom rules.
SLO
model
.
PromSLO
// The SLO MWMBAlertGroup selected.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment