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
91541275
Commit
91541275
authored
Sep 18, 2017
by
bergquist
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'v4.5.x'
parents
6d901fe1
0a8a6fd8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
1 deletions
+47
-1
pkg/metrics/graphitebridge/graphite.go
+6
-1
pkg/metrics/graphitebridge/graphite_test.go
+41
-0
No files found.
pkg/metrics/graphitebridge/graphite.go
View file @
91541275
...
...
@@ -20,6 +20,7 @@ import (
"errors"
"fmt"
"io"
"math"
"net"
"sort"
"strings"
...
...
@@ -208,6 +209,10 @@ func (b *Bridge) writeMetrics(w io.Writer, mfs []*dto.MetricFamily, prefix strin
buf
:=
bufio
.
NewWriter
(
w
)
for
_
,
s
:=
range
vec
{
if
math
.
IsNaN
(
float64
(
s
.
Value
))
{
continue
}
if
err
:=
writePrefix
(
buf
,
prefix
);
err
!=
nil
{
return
err
}
...
...
@@ -357,7 +362,7 @@ func replaceInvalidRune(c rune) rune {
if
c
==
' '
{
return
'.'
}
if
!
((
c
>=
'a'
&&
c
<=
'z'
)
||
(
c
>=
'A'
&&
c
<=
'Z'
)
||
c
==
'_'
||
c
==
':'
||
(
c
>=
'0'
&&
c
<=
'9'
))
{
if
!
((
c
>=
'a'
&&
c
<=
'z'
)
||
(
c
>=
'A'
&&
c
<=
'Z'
)
||
c
==
'
-'
||
c
==
'
_'
||
c
==
':'
||
(
c
>=
'0'
&&
c
<=
'9'
))
{
return
'_'
}
return
c
...
...
pkg/metrics/graphitebridge/graphite_test.go
View file @
91541275
...
...
@@ -410,6 +410,47 @@ func TestTrimGrafanaNamespace(t *testing.T) {
}
}
func
TestSkipNanValues
(
t
*
testing
.
T
)
{
cntVec
:=
prometheus
.
NewSummary
(
prometheus
.
SummaryOpts
{
Name
:
"grafana_http_request_total"
,
Help
:
"docstring"
,
ConstLabels
:
prometheus
.
Labels
{
"constname"
:
"constvalue"
},
})
reg
:=
prometheus
.
NewRegistry
()
reg
.
MustRegister
(
cntVec
)
b
,
err
:=
NewBridge
(
&
Config
{
URL
:
"localhost:8080"
,
Gatherer
:
reg
,
CountersAsDelta
:
true
,
})
if
err
!=
nil
{
t
.
Fatalf
(
"error creating bridge: %v"
,
err
)
}
// first collect
mfs
,
err
:=
reg
.
Gather
()
if
err
!=
nil
{
t
.
Fatalf
(
"error: %v"
,
err
)
}
var
buf
bytes
.
Buffer
err
=
b
.
writeMetrics
(
&
buf
,
mfs
,
"prefix."
,
model
.
Time
(
1477043083
))
if
err
!=
nil
{
t
.
Fatalf
(
"error: %v"
,
err
)
}
want
:=
`prefix.http_request_total_sum.constname.constvalue 0 1477043
prefix.http_request_total_count.constname.constvalue.count 0 1477043
`
if
got
:=
buf
.
String
();
want
!=
got
{
t
.
Fatalf
(
"wanted
\n
%s
\n
, got
\n
%s
\n
"
,
want
,
got
)
}
}
func
TestPush
(
t
*
testing
.
T
)
{
reg
:=
prometheus
.
NewRegistry
()
cntVec
:=
prometheus
.
NewCounterVec
(
...
...
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