Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
C
Coredns
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Railgun
Coredns
Commits
b371eb67
Commit
b371eb67
authored
Jan 18, 2020
by
Miek Gieben
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add metrics
Signed-off-by:
Miek Gieben
<
miek@miek.nl
>
parent
27282393
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
1 deletion
+27
-1
plugin/traffic/README.md
plugin/traffic/README.md
+7
-1
plugin/traffic/setup.go
plugin/traffic/setup.go
+2
-0
plugin/traffic/xds/client.go
plugin/traffic/xds/client.go
+1
-0
plugin/traffic/xds/metrics.go
plugin/traffic/xds/metrics.go
+17
-0
No files found.
plugin/traffic/README.md
View file @
b371eb67
...
@@ -91,6 +91,13 @@ What metrics should we do? If any? Number of clusters? Number of endpoints and h
...
@@ -91,6 +91,13 @@ What metrics should we do? If any? Number of clusters? Number of endpoints and h
This plugin report readiness to the ready plugin. This will happen after a gRPC stream has been
This plugin report readiness to the ready plugin. This will happen after a gRPC stream has been
established to the control plane.
established to the control plane.
## Metrics
If monitoring is enabled (via the
*prometheus*
plugin) then the following metric are exported:
*
`coredns_traffic_clusters_tracked{}`
the number of tracked clusters.
## Examples
## Examples
~~~
~~~
...
@@ -123,7 +130,6 @@ is not implemented.
...
@@ -123,7 +130,6 @@ is not implemented.
## TODO
## TODO
*
metrics?
*
credentials (other than TLS) - how/what?
*
credentials (other than TLS) - how/what?
*
is the protocol correctly implemented? Should we not have a 10s tick, but wait for responses from
*
is the protocol correctly implemented? Should we not have a 10s tick, but wait for responses from
the control plane?
the control plane?
plugin/traffic/setup.go
View file @
b371eb67
...
@@ -9,6 +9,7 @@ import (
...
@@ -9,6 +9,7 @@ import (
"github.com/coredns/coredns/core/dnsserver"
"github.com/coredns/coredns/core/dnsserver"
"github.com/coredns/coredns/plugin"
"github.com/coredns/coredns/plugin"
"github.com/coredns/coredns/plugin/metrics"
clog
"github.com/coredns/coredns/plugin/pkg/log"
clog
"github.com/coredns/coredns/plugin/pkg/log"
"github.com/coredns/coredns/plugin/pkg/parse"
"github.com/coredns/coredns/plugin/pkg/parse"
pkgtls
"github.com/coredns/coredns/plugin/pkg/tls"
pkgtls
"github.com/coredns/coredns/plugin/pkg/tls"
...
@@ -38,6 +39,7 @@ func setup(c *caddy.Controller) error {
...
@@ -38,6 +39,7 @@ func setup(c *caddy.Controller) error {
c
.
OnStartup
(
func
()
error
{
c
.
OnStartup
(
func
()
error
{
go
t
.
c
.
Run
()
go
t
.
c
.
Run
()
metrics
.
MustRegister
(
c
,
xds
.
ClusterGauge
)
return
nil
return
nil
})
})
c
.
OnShutdown
(
func
()
error
{
return
t
.
c
.
Stop
()
})
c
.
OnShutdown
(
func
()
error
{
return
t
.
c
.
Stop
()
})
...
...
plugin/traffic/xds/client.go
View file @
b371eb67
...
@@ -191,6 +191,7 @@ func (c *Client) receive(stream adsStream) error {
...
@@ -191,6 +191,7 @@ func (c *Client) receive(stream adsStream) error {
a
.
SetClusterLoadAssignment
(
cluster
.
GetName
(),
nil
)
a
.
SetClusterLoadAssignment
(
cluster
.
GetName
(),
nil
)
}
}
log
.
Debugf
(
"Cluster discovery processed with %d resources, version %q and nonce %q"
,
len
(
resp
.
GetResources
()),
c
.
Version
(
cdsURL
),
c
.
Nonce
(
cdsURL
))
log
.
Debugf
(
"Cluster discovery processed with %d resources, version %q and nonce %q"
,
len
(
resp
.
GetResources
()),
c
.
Version
(
cdsURL
),
c
.
Nonce
(
cdsURL
))
ClusterGauge
.
WithLabelValues
()
.
Set
(
float64
(
len
(
resp
.
GetResources
())))
// set our local administration and ack the reply. Empty version would signal NACK.
// set our local administration and ack the reply. Empty version would signal NACK.
c
.
SetNonce
(
cdsURL
,
resp
.
GetNonce
())
c
.
SetNonce
(
cdsURL
,
resp
.
GetNonce
())
c
.
SetVersion
(
cdsURL
,
resp
.
GetVersionInfo
())
c
.
SetVersion
(
cdsURL
,
resp
.
GetVersionInfo
())
...
...
plugin/traffic/xds/metrics.go
0 → 100644
View file @
b371eb67
package
xds
import
(
"github.com/coredns/coredns/plugin"
"github.com/prometheus/client_golang/prometheus"
)
var
(
// ClusterGauge is the number of clusters we are currently tracking.
ClusterGauge
=
prometheus
.
NewGaugeVec
(
prometheus
.
GaugeOpts
{
Namespace
:
plugin
.
Namespace
,
Subsystem
:
"traffic"
,
Name
:
"clusters_tracked"
,
Help
:
"Gauge of tracked clusters."
,
},
[]
string
{
""
})
)
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