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
cc0a39f8
Commit
cc0a39f8
authored
Oct 16, 2016
by
utkarshcmu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added downsampling params to alerting
parent
5e0fa0f0
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
15 deletions
+25
-15
pkg/tsdb/opentsdb/opentsdb.go
+24
-9
pkg/tsdb/opentsdb/types.go
+1
-6
No files found.
pkg/tsdb/opentsdb/opentsdb.go
View file @
cc0a39f8
...
...
@@ -14,7 +14,7 @@ import (
"io/ioutil"
"net/http"
"net/url"
//
"net/http/httputil"
"net/http/httputil"
"encoding/json"
"gopkg.in/guregu/null.v3"
...
...
@@ -58,16 +58,31 @@ func (e *OpenTsdbExecutor) Execute(ctx context.Context, queries tsdb.QuerySlice,
tsdbQuery
.
Start
=
queryContext
.
TimeRange
.
GetFromAsMsEpoch
()
tsdbQuery
.
End
=
queryContext
.
TimeRange
.
GetToAsMsEpoch
()
tsdbQuery
.
Queries
=
make
([]
map
[
string
]
interface
{},
len
(
queries
))
for
_
,
query
:=
range
queries
{
tsdbQuery
.
Queries
=
[]
OpenTsdbMetric
{
OpenTsdbMetric
{
Metric
:
query
.
Model
.
Get
(
"metric"
)
.
MustString
(),
Aggregator
:
query
.
Model
.
Get
(
"aggregator"
)
.
MustString
(),
},
for
i
:=
0
;
i
<
len
(
queries
);
i
++
{
metric
:=
make
(
map
[
string
]
interface
{})
metric
[
"metric"
]
=
queries
[
i
]
.
Model
.
Get
(
"metric"
)
.
MustString
()
metric
[
"aggregator"
]
=
queries
[
i
]
.
Model
.
Get
(
"aggregator"
)
.
MustString
()
disableDownsampling
:=
queries
[
i
]
.
Model
.
Get
(
"disableDownsampling"
)
.
MustBool
()
if
!
disableDownsampling
{
downsampleInterval
:=
queries
[
i
]
.
Model
.
Get
(
"downsampleInterval"
)
.
MustString
()
if
downsampleInterval
==
""
{
downsampleInterval
=
"1m"
//default value for blank
}
downsample
:=
downsampleInterval
+
"-"
+
queries
[
i
]
.
Model
.
Get
(
"downsampleAggregator"
)
.
MustString
()
if
queries
[
i
]
.
Model
.
Get
(
"downsampleFillPolicy"
)
.
MustString
()
!=
"none"
{
metric
[
"downsample"
]
=
downsample
+
"-"
+
queries
[
i
]
.
Model
.
Get
(
"downsampleFillPolicy"
)
.
MustString
()
}
}
tsdbQuery
.
Queries
[
i
]
=
metric
}
if
setting
.
Env
==
setting
.
DEV
{
plog
.
Debug
(
"OpenTsdb request"
,
"params"
,
tsdbQuery
)
}
...
...
@@ -110,13 +125,13 @@ func (e *OpenTsdbExecutor) createRequest(data OpenTsdbQuery) (*http.Request, err
req
.
SetBasicAuth
(
e
.
BasicAuthUser
,
e
.
BasicAuthPassword
)
}
/*
requestDump
,
err
:=
httputil
.
DumpRequest
(
req
,
true
)
if
err
!=
nil
{
fmt
.
Println
(
err
)
}
fmt
.
Println
(
string
(
requestDump
))
*/
return
req
,
err
}
...
...
pkg/tsdb/opentsdb/types.go
View file @
cc0a39f8
...
...
@@ -3,12 +3,7 @@ package opentsdb
type
OpenTsdbQuery
struct
{
Start
int64
`json:"start"`
End
int64
`json:"end"`
Queries
[]
OpenTsdbMetric
`json:"queries"`
}
type
OpenTsdbMetric
struct
{
Metric
string
`json:"metric"`
Aggregator
string
`json:"aggregator"`
Queries
[]
map
[
string
]
interface
{}
`json:"queries"`
}
type
OpenTsdbResponse
struct
{
...
...
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