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
ca50e315
Commit
ca50e315
authored
Sep 28, 2018
by
Erik Sundell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stackdriver: make it possible to use point values of type string
parent
5bc6d857
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
4 deletions
+9
-4
pkg/tsdb/stackdriver/annotation_query.go
+8
-4
pkg/tsdb/stackdriver/types.go
+1
-0
No files found.
pkg/tsdb/stackdriver/annotation_query.go
View file @
ca50e315
...
@@ -3,6 +3,7 @@ package stackdriver
...
@@ -3,6 +3,7 @@ package stackdriver
import
(
import
(
"context"
"context"
"fmt"
"fmt"
"strconv"
"strings"
"strings"
"time"
"time"
...
@@ -41,12 +42,15 @@ func (e *StackdriverExecutor) parseToAnnotations(queryRes *tsdb.QueryResult, dat
...
@@ -41,12 +42,15 @@ func (e *StackdriverExecutor) parseToAnnotations(queryRes *tsdb.QueryResult, dat
// reverse the order to be ascending
// reverse the order to be ascending
for
i
:=
len
(
series
.
Points
)
-
1
;
i
>=
0
;
i
--
{
for
i
:=
len
(
series
.
Points
)
-
1
;
i
>=
0
;
i
--
{
point
:=
series
.
Points
[
i
]
point
:=
series
.
Points
[
i
]
value
:=
strconv
.
FormatFloat
(
point
.
Value
.
DoubleValue
,
'f'
,
6
,
64
)
if
series
.
ValueType
==
"STRING"
{
value
=
point
.
Value
.
StringValue
}
annotation
:=
make
(
map
[
string
]
string
)
annotation
:=
make
(
map
[
string
]
string
)
annotation
[
"time"
]
=
point
.
Interval
.
EndTime
.
UTC
()
.
Format
(
time
.
RFC3339
)
annotation
[
"time"
]
=
point
.
Interval
.
EndTime
.
UTC
()
.
Format
(
time
.
RFC3339
)
annotation
[
"title"
]
=
formatAnnotationText
(
title
,
point
.
Value
.
DoubleV
alue
,
series
.
Metric
.
Type
,
series
.
Metric
.
Labels
,
series
.
Resource
.
Labels
)
annotation
[
"title"
]
=
formatAnnotationText
(
title
,
v
alue
,
series
.
Metric
.
Type
,
series
.
Metric
.
Labels
,
series
.
Resource
.
Labels
)
annotation
[
"tags"
]
=
tags
annotation
[
"tags"
]
=
tags
annotation
[
"text"
]
=
formatAnnotationText
(
text
,
point
.
Value
.
DoubleV
alue
,
series
.
Metric
.
Type
,
series
.
Metric
.
Labels
,
series
.
Resource
.
Labels
)
annotation
[
"text"
]
=
formatAnnotationText
(
text
,
v
alue
,
series
.
Metric
.
Type
,
series
.
Metric
.
Labels
,
series
.
Resource
.
Labels
)
annotations
=
append
(
annotations
,
annotation
)
annotations
=
append
(
annotations
,
annotation
)
}
}
}
}
...
@@ -78,7 +82,7 @@ func transformAnnotationToTable(data []map[string]string, result *tsdb.QueryResu
...
@@ -78,7 +82,7 @@ func transformAnnotationToTable(data []map[string]string, result *tsdb.QueryResu
slog
.
Info
(
"anno"
,
"len"
,
len
(
data
))
slog
.
Info
(
"anno"
,
"len"
,
len
(
data
))
}
}
func
formatAnnotationText
(
annotationText
string
,
pointValue
float64
,
metricType
string
,
metricLabels
map
[
string
]
string
,
resourceLabels
map
[
string
]
string
)
string
{
func
formatAnnotationText
(
annotationText
string
,
pointValue
string
,
metricType
string
,
metricLabels
map
[
string
]
string
,
resourceLabels
map
[
string
]
string
)
string
{
result
:=
legendKeyFormat
.
ReplaceAllFunc
([]
byte
(
annotationText
),
func
(
in
[]
byte
)
[]
byte
{
result
:=
legendKeyFormat
.
ReplaceAllFunc
([]
byte
(
annotationText
),
func
(
in
[]
byte
)
[]
byte
{
metaPartName
:=
strings
.
Replace
(
string
(
in
),
"{{"
,
""
,
1
)
metaPartName
:=
strings
.
Replace
(
string
(
in
),
"{{"
,
""
,
1
)
metaPartName
=
strings
.
Replace
(
metaPartName
,
"}}"
,
""
,
1
)
metaPartName
=
strings
.
Replace
(
metaPartName
,
"}}"
,
""
,
1
)
...
...
pkg/tsdb/stackdriver/types.go
View file @
ca50e315
...
@@ -34,6 +34,7 @@ type StackdriverResponse struct {
...
@@ -34,6 +34,7 @@ type StackdriverResponse struct {
}
`json:"interval"`
}
`json:"interval"`
Value
struct
{
Value
struct
{
DoubleValue
float64
`json:"doubleValue"`
DoubleValue
float64
`json:"doubleValue"`
StringValue
string
`json:"stringValue"`
}
`json:"value"`
}
`json:"value"`
}
`json:"points"`
}
`json:"points"`
}
`json:"timeSeries"`
}
`json:"timeSeries"`
...
...
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