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
f609623a
Commit
f609623a
authored
Oct 10, 2016
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
style(influxdb): tidy up code
parent
95b9f472
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
39 deletions
+39
-39
pkg/services/alerting/conditions/evaluator.go
+1
-1
pkg/tsdb/influxdb/influxdb.go
+38
-38
No files found.
pkg/services/alerting/conditions/evaluator.go
View file @
f609623a
...
@@ -122,7 +122,7 @@ func NewAlertEvaluator(model *simplejson.Json) (AlertEvaluator, error) {
...
@@ -122,7 +122,7 @@ func NewAlertEvaluator(model *simplejson.Json) (AlertEvaluator, error) {
return
&
NoDataEvaluator
{},
nil
return
&
NoDataEvaluator
{},
nil
}
}
return
nil
,
alerting
.
ValidationError
{
Reason
:
"Evaludator invalid evaluator type
"
}
return
nil
,
alerting
.
ValidationError
{
Reason
:
"Evaludator invalid evaluator type
: "
+
typ
}
}
}
func
inSlice
(
a
string
,
list
[]
string
)
bool
{
func
inSlice
(
a
string
,
list
[]
string
)
bool
{
...
...
pkg/tsdb/influxdb/influxdb.go
View file @
f609623a
...
@@ -51,6 +51,44 @@ func init() {
...
@@ -51,6 +51,44 @@ func init() {
}
}
}
}
func
(
e
*
InfluxDBExecutor
)
Execute
(
ctx
context
.
Context
,
queries
tsdb
.
QuerySlice
,
context
*
tsdb
.
QueryContext
)
*
tsdb
.
BatchResult
{
result
:=
&
tsdb
.
BatchResult
{}
query
,
err
:=
e
.
getQuery
(
queries
,
context
)
if
err
!=
nil
{
return
result
.
WithError
(
err
)
}
glog
.
Debug
(
"Influxdb query"
,
"raw query"
,
query
)
req
,
err
:=
e
.
createRequest
(
query
)
if
err
!=
nil
{
return
result
.
WithError
(
err
)
}
resp
,
err
:=
ctxhttp
.
Do
(
ctx
,
HttpClient
,
req
)
if
err
!=
nil
{
return
result
.
WithError
(
err
)
}
if
resp
.
StatusCode
/
100
!=
2
{
return
result
.
WithError
(
fmt
.
Errorf
(
"Influxdb returned statuscode invalid status code: %v"
,
resp
.
Status
))
}
var
response
Response
dec
:=
json
.
NewDecoder
(
resp
.
Body
)
dec
.
UseNumber
()
err
=
dec
.
Decode
(
&
response
)
if
err
!=
nil
{
return
result
.
WithError
(
err
)
}
result
.
QueryResults
=
make
(
map
[
string
]
*
tsdb
.
QueryResult
)
result
.
QueryResults
[
"A"
]
=
e
.
ResponseParser
.
Parse
(
&
response
)
return
result
}
func
(
e
*
InfluxDBExecutor
)
getQuery
(
queries
tsdb
.
QuerySlice
,
context
*
tsdb
.
QueryContext
)
(
string
,
error
)
{
func
(
e
*
InfluxDBExecutor
)
getQuery
(
queries
tsdb
.
QuerySlice
,
context
*
tsdb
.
QueryContext
)
(
string
,
error
)
{
for
_
,
v
:=
range
queries
{
for
_
,
v
:=
range
queries
{
query
,
err
:=
e
.
QueryParser
.
Parse
(
v
.
Model
)
query
,
err
:=
e
.
QueryParser
.
Parse
(
v
.
Model
)
...
@@ -92,41 +130,3 @@ func (e *InfluxDBExecutor) createRequest(query string) (*http.Request, error) {
...
@@ -92,41 +130,3 @@ func (e *InfluxDBExecutor) createRequest(query string) (*http.Request, error) {
glog
.
Debug
(
"influxdb request"
,
"url"
,
req
.
URL
.
String
())
glog
.
Debug
(
"influxdb request"
,
"url"
,
req
.
URL
.
String
())
return
req
,
nil
return
req
,
nil
}
}
func
(
e
*
InfluxDBExecutor
)
Execute
(
ctx
context
.
Context
,
queries
tsdb
.
QuerySlice
,
context
*
tsdb
.
QueryContext
)
*
tsdb
.
BatchResult
{
result
:=
&
tsdb
.
BatchResult
{}
query
,
err
:=
e
.
getQuery
(
queries
,
context
)
if
err
!=
nil
{
return
result
.
WithError
(
err
)
}
glog
.
Debug
(
"Influxdb query"
,
"raw query"
,
query
)
req
,
err
:=
e
.
createRequest
(
query
)
if
err
!=
nil
{
return
result
.
WithError
(
err
)
}
resp
,
err
:=
ctxhttp
.
Do
(
ctx
,
HttpClient
,
req
)
if
err
!=
nil
{
return
result
.
WithError
(
err
)
}
if
resp
.
StatusCode
/
100
!=
2
{
return
result
.
WithError
(
fmt
.
Errorf
(
"Influxdb returned statuscode invalid status code: %v"
,
resp
.
Status
))
}
var
response
Response
dec
:=
json
.
NewDecoder
(
resp
.
Body
)
dec
.
UseNumber
()
err
=
dec
.
Decode
(
&
response
)
if
err
!=
nil
{
return
result
.
WithError
(
err
)
}
result
.
QueryResults
=
make
(
map
[
string
]
*
tsdb
.
QueryResult
)
result
.
QueryResults
[
"A"
]
=
e
.
ResponseParser
.
Parse
(
&
response
)
return
result
}
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