mirror of
https://github.com/coredns/coredns.git
synced 2025-10-28 08:44:17 -04:00
@@ -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.
|
|||||||
|
|
||||||
## 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?
|
||||||
|
|||||||
@@ -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 {
|
|||||||
|
|
||||||
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() })
|
||||||
|
|||||||
@@ -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())
|
||||||
|
|||||||
17
plugin/traffic/xds/metrics.go
Normal file
17
plugin/traffic/xds/metrics.go
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
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{""})
|
||||||
|
)
|
||||||
Reference in New Issue
Block a user