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
7d6c8aa6
Commit
7d6c8aa6
authored
Apr 09, 2018
by
ryan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add mssql and mysql
parent
113bfb3d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
12 deletions
+12
-12
pkg/tsdb/mssql/macros.go
+6
-6
pkg/tsdb/mysql/macros.go
+6
-6
No files found.
pkg/tsdb/mssql/macros.go
View file @
7d6c8aa6
...
...
@@ -82,11 +82,11 @@ func (m *MsSqlMacroEngine) evaluateMacro(name string, args []string) (string, er
if
len
(
args
)
==
0
{
return
""
,
fmt
.
Errorf
(
"missing time column argument for macro %v"
,
name
)
}
return
fmt
.
Sprintf
(
"%s >= DATEADD(s, %d, '1970-01-01') AND %s <= DATEADD(s, %d, '1970-01-01')"
,
args
[
0
],
uint64
(
m
.
TimeRange
.
GetFromAsMsEpoch
()
/
1000
),
args
[
0
],
u
int64
(
m
.
TimeRange
.
GetToAsMsEpoch
()
/
1000
)),
nil
return
fmt
.
Sprintf
(
"%s >= DATEADD(s, %d, '1970-01-01') AND %s <= DATEADD(s, %d, '1970-01-01')"
,
args
[
0
],
int64
(
m
.
TimeRange
.
GetFromAsMsEpoch
()
/
1000
),
args
[
0
],
int64
(
m
.
TimeRange
.
GetToAsMsEpoch
()
/
1000
)),
nil
case
"__timeFrom"
:
return
fmt
.
Sprintf
(
"DATEADD(second, %d, '1970-01-01')"
,
u
int64
(
m
.
TimeRange
.
GetFromAsMsEpoch
()
/
1000
)),
nil
return
fmt
.
Sprintf
(
"DATEADD(second, %d, '1970-01-01')"
,
int64
(
m
.
TimeRange
.
GetFromAsMsEpoch
()
/
1000
)),
nil
case
"__timeTo"
:
return
fmt
.
Sprintf
(
"DATEADD(second, %d, '1970-01-01')"
,
u
int64
(
m
.
TimeRange
.
GetToAsMsEpoch
()
/
1000
)),
nil
return
fmt
.
Sprintf
(
"DATEADD(second, %d, '1970-01-01')"
,
int64
(
m
.
TimeRange
.
GetToAsMsEpoch
()
/
1000
)),
nil
case
"__timeGroup"
:
if
len
(
args
)
<
2
{
return
""
,
fmt
.
Errorf
(
"macro %v needs time column and interval"
,
name
)
...
...
@@ -113,11 +113,11 @@ func (m *MsSqlMacroEngine) evaluateMacro(name string, args []string) (string, er
if
len
(
args
)
==
0
{
return
""
,
fmt
.
Errorf
(
"missing time column argument for macro %v"
,
name
)
}
return
fmt
.
Sprintf
(
"%s >= %d AND %s <= %d"
,
args
[
0
],
uint64
(
m
.
TimeRange
.
GetFromAsMsEpoch
()
/
1000
),
args
[
0
],
u
int64
(
m
.
TimeRange
.
GetToAsMsEpoch
()
/
1000
)),
nil
return
fmt
.
Sprintf
(
"%s >= %d AND %s <= %d"
,
args
[
0
],
int64
(
m
.
TimeRange
.
GetFromAsMsEpoch
()
/
1000
),
args
[
0
],
int64
(
m
.
TimeRange
.
GetToAsMsEpoch
()
/
1000
)),
nil
case
"__unixEpochFrom"
:
return
fmt
.
Sprintf
(
"%d"
,
u
int64
(
m
.
TimeRange
.
GetFromAsMsEpoch
()
/
1000
)),
nil
return
fmt
.
Sprintf
(
"%d"
,
int64
(
m
.
TimeRange
.
GetFromAsMsEpoch
()
/
1000
)),
nil
case
"__unixEpochTo"
:
return
fmt
.
Sprintf
(
"%d"
,
u
int64
(
m
.
TimeRange
.
GetToAsMsEpoch
()
/
1000
)),
nil
return
fmt
.
Sprintf
(
"%d"
,
int64
(
m
.
TimeRange
.
GetToAsMsEpoch
()
/
1000
)),
nil
default
:
return
""
,
fmt
.
Errorf
(
"Unknown macro %v"
,
name
)
}
...
...
pkg/tsdb/mysql/macros.go
View file @
7d6c8aa6
...
...
@@ -77,11 +77,11 @@ func (m *MySqlMacroEngine) evaluateMacro(name string, args []string) (string, er
if
len
(
args
)
==
0
{
return
""
,
fmt
.
Errorf
(
"missing time column argument for macro %v"
,
name
)
}
return
fmt
.
Sprintf
(
"%s >= FROM_UNIXTIME(%d) AND %s <= FROM_UNIXTIME(%d)"
,
args
[
0
],
uint64
(
m
.
TimeRange
.
GetFromAsMsEpoch
()
/
1000
),
args
[
0
],
u
int64
(
m
.
TimeRange
.
GetToAsMsEpoch
()
/
1000
)),
nil
return
fmt
.
Sprintf
(
"%s >= FROM_UNIXTIME(%d) AND %s <= FROM_UNIXTIME(%d)"
,
args
[
0
],
int64
(
m
.
TimeRange
.
GetFromAsMsEpoch
()
/
1000
),
args
[
0
],
int64
(
m
.
TimeRange
.
GetToAsMsEpoch
()
/
1000
)),
nil
case
"__timeFrom"
:
return
fmt
.
Sprintf
(
"FROM_UNIXTIME(%d)"
,
u
int64
(
m
.
TimeRange
.
GetFromAsMsEpoch
()
/
1000
)),
nil
return
fmt
.
Sprintf
(
"FROM_UNIXTIME(%d)"
,
int64
(
m
.
TimeRange
.
GetFromAsMsEpoch
()
/
1000
)),
nil
case
"__timeTo"
:
return
fmt
.
Sprintf
(
"FROM_UNIXTIME(%d)"
,
u
int64
(
m
.
TimeRange
.
GetToAsMsEpoch
()
/
1000
)),
nil
return
fmt
.
Sprintf
(
"FROM_UNIXTIME(%d)"
,
int64
(
m
.
TimeRange
.
GetToAsMsEpoch
()
/
1000
)),
nil
case
"__timeGroup"
:
if
len
(
args
)
<
2
{
return
""
,
fmt
.
Errorf
(
"macro %v needs time column and interval"
,
name
)
...
...
@@ -108,11 +108,11 @@ func (m *MySqlMacroEngine) evaluateMacro(name string, args []string) (string, er
if
len
(
args
)
==
0
{
return
""
,
fmt
.
Errorf
(
"missing time column argument for macro %v"
,
name
)
}
return
fmt
.
Sprintf
(
"%s >= %d AND %s <= %d"
,
args
[
0
],
uint64
(
m
.
TimeRange
.
GetFromAsMsEpoch
()
/
1000
),
args
[
0
],
u
int64
(
m
.
TimeRange
.
GetToAsMsEpoch
()
/
1000
)),
nil
return
fmt
.
Sprintf
(
"%s >= %d AND %s <= %d"
,
args
[
0
],
int64
(
m
.
TimeRange
.
GetFromAsMsEpoch
()
/
1000
),
args
[
0
],
int64
(
m
.
TimeRange
.
GetToAsMsEpoch
()
/
1000
)),
nil
case
"__unixEpochFrom"
:
return
fmt
.
Sprintf
(
"%d"
,
u
int64
(
m
.
TimeRange
.
GetFromAsMsEpoch
()
/
1000
)),
nil
return
fmt
.
Sprintf
(
"%d"
,
int64
(
m
.
TimeRange
.
GetFromAsMsEpoch
()
/
1000
)),
nil
case
"__unixEpochTo"
:
return
fmt
.
Sprintf
(
"%d"
,
u
int64
(
m
.
TimeRange
.
GetToAsMsEpoch
()
/
1000
)),
nil
return
fmt
.
Sprintf
(
"%d"
,
int64
(
m
.
TimeRange
.
GetToAsMsEpoch
()
/
1000
)),
nil
default
:
return
""
,
fmt
.
Errorf
(
"Unknown macro %v"
,
name
)
}
...
...
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