Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
71c1c0ab
Commit
71c1c0ab
authored
Jun 11, 2016
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(alerting): trying to get things to work with new model
parent
0ef68011
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
21 additions
and
5 deletions
+21
-5
pkg/log/log.go
+7
-0
pkg/services/alerting/commands.go
+5
-1
pkg/services/alerting/engine.go
+6
-0
pkg/services/alerting/reader.go
+0
-0
pkg/services/alerting/scheduler.go
+3
-4
No files found.
pkg/log/log.go
View file @
71c1c0ab
...
@@ -12,6 +12,7 @@ import (
...
@@ -12,6 +12,7 @@ import (
"gopkg.in/ini.v1"
"gopkg.in/ini.v1"
"github.com/go-stack/stack"
"github.com/inconshreveable/log15"
"github.com/inconshreveable/log15"
"github.com/inconshreveable/log15/term"
"github.com/inconshreveable/log15/term"
)
)
...
@@ -228,3 +229,9 @@ func LogFilterHandler(maxLevel log15.Lvl, filters map[string]log15.Lvl, h log15.
...
@@ -228,3 +229,9 @@ func LogFilterHandler(maxLevel log15.Lvl, filters map[string]log15.Lvl, h log15.
return
r
.
Lvl
<=
maxLevel
return
r
.
Lvl
<=
maxLevel
},
h
)
},
h
)
}
}
func
Stack
(
skip
int
)
string
{
call
:=
stack
.
Caller
(
skip
)
s
:=
stack
.
Trace
()
.
TrimBelow
(
call
)
.
TrimRuntime
()
return
s
.
String
()
}
pkg/services/alerting/commands.go
View file @
71c1c0ab
...
@@ -38,6 +38,10 @@ func updateDashboardAlerts(cmd *UpdateDashboardAlertsCommand) error {
...
@@ -38,6 +38,10 @@ func updateDashboardAlerts(cmd *UpdateDashboardAlertsCommand) error {
return
nil
return
nil
}
}
func
getTimeDurationStringToSeconds
(
str
string
)
int64
{
return
60
}
func
ConvetAlertModelToAlertRule
(
ruleDef
*
m
.
Alert
)
(
*
AlertRule
,
error
)
{
func
ConvetAlertModelToAlertRule
(
ruleDef
*
m
.
Alert
)
(
*
AlertRule
,
error
)
{
model
:=
&
AlertRule
{}
model
:=
&
AlertRule
{}
model
.
Id
=
ruleDef
.
Id
model
.
Id
=
ruleDef
.
Id
...
@@ -58,7 +62,7 @@ func ConvetAlertModelToAlertRule(ruleDef *m.Alert) (*AlertRule, error) {
...
@@ -58,7 +62,7 @@ func ConvetAlertModelToAlertRule(ruleDef *m.Alert) (*AlertRule, error) {
Level
:
warning
.
Get
(
"level"
)
.
MustFloat64
(),
Level
:
warning
.
Get
(
"level"
)
.
MustFloat64
(),
}
}
model
.
Frequency
=
ruleDef
.
Expression
.
Get
(
"frequency"
)
.
MustInt64
(
)
model
.
Frequency
=
getTimeDurationStringToSeconds
(
ruleDef
.
Expression
.
Get
(
"frequency"
)
.
MustString
()
)
model
.
Transform
=
ruleDef
.
Expression
.
Get
(
"transform"
)
.
Get
(
"type"
)
.
MustString
()
model
.
Transform
=
ruleDef
.
Expression
.
Get
(
"transform"
)
.
Get
(
"type"
)
.
MustString
()
model
.
TransformParams
=
*
ruleDef
.
Expression
.
Get
(
"transform"
)
model
.
TransformParams
=
*
ruleDef
.
Expression
.
Get
(
"transform"
)
...
...
pkg/services/alerting/engine.go
View file @
71c1c0ab
...
@@ -50,6 +50,12 @@ func (e *Engine) Stop() {
...
@@ -50,6 +50,12 @@ func (e *Engine) Stop() {
}
}
func
(
e
*
Engine
)
alertingTicker
()
{
func
(
e
*
Engine
)
alertingTicker
()
{
defer
func
()
{
if
err
:=
recover
();
err
!=
nil
{
e
.
log
.
Error
(
"Scheduler Panic, stopping..."
,
"error"
,
err
,
"stack"
,
log
.
Stack
(
1
))
}
}()
tickIndex
:=
0
tickIndex
:=
0
for
{
for
{
...
...
pkg/services/alerting/r
ule_r
eader.go
→
pkg/services/alerting/reader.go
View file @
71c1c0ab
File moved
pkg/services/alerting/scheduler.go
View file @
71c1c0ab
...
@@ -18,12 +18,12 @@ func NewScheduler() Scheduler {
...
@@ -18,12 +18,12 @@ func NewScheduler() Scheduler {
}
}
}
}
func
(
s
*
SchedulerImpl
)
Update
(
rule
s
[]
*
AlertRule
)
{
func
(
s
*
SchedulerImpl
)
Update
(
alert
s
[]
*
AlertRule
)
{
s
.
log
.
Debug
(
"Schedul
er: Update"
)
s
.
log
.
Debug
(
"Schedul
ing update"
,
"alerts.count"
,
len
(
alerts
)
)
jobs
:=
make
(
map
[
int64
]
*
AlertJob
,
0
)
jobs
:=
make
(
map
[
int64
]
*
AlertJob
,
0
)
for
i
,
rule
:=
range
rule
s
{
for
i
,
rule
:=
range
alert
s
{
var
job
*
AlertJob
var
job
*
AlertJob
if
s
.
jobs
[
rule
.
Id
]
!=
nil
{
if
s
.
jobs
[
rule
.
Id
]
!=
nil
{
job
=
s
.
jobs
[
rule
.
Id
]
job
=
s
.
jobs
[
rule
.
Id
]
...
@@ -40,7 +40,6 @@ func (s *SchedulerImpl) Update(rules []*AlertRule) {
...
@@ -40,7 +40,6 @@ func (s *SchedulerImpl) Update(rules []*AlertRule) {
jobs
[
rule
.
Id
]
=
job
jobs
[
rule
.
Id
]
=
job
}
}
s
.
log
.
Debug
(
"Scheduler: Selected new jobs"
,
"job count"
,
len
(
jobs
))
s
.
jobs
=
jobs
s
.
jobs
=
jobs
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment