mirror of
https://github.com/coredns/coredns.git
synced 2025-10-27 16:24:19 -04:00
return failure with CH class hits file or etcd, monitoring portis 9135
This commit is contained in:
@@ -53,10 +53,10 @@ var directiveOrder = []directive{
|
|||||||
// Directives that inject handlers (middleware)
|
// Directives that inject handlers (middleware)
|
||||||
{"prometheus", setup.Prometheus},
|
{"prometheus", setup.Prometheus},
|
||||||
{"log", setup.Log},
|
{"log", setup.Log},
|
||||||
|
{"chaos", setup.Chaos},
|
||||||
{"rewrite", setup.Rewrite},
|
{"rewrite", setup.Rewrite},
|
||||||
{"loadbalance", setup.Loadbalance},
|
{"loadbalance", setup.Loadbalance},
|
||||||
{"file", setup.File},
|
{"file", setup.File},
|
||||||
{"chaos", setup.Chaos},
|
|
||||||
{"secondary", setup.Secondary},
|
{"secondary", setup.Secondary},
|
||||||
{"etcd", setup.Etcd},
|
{"etcd", setup.Etcd},
|
||||||
{"proxy", setup.Proxy},
|
{"proxy", setup.Proxy},
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
path = "/metrics"
|
path = "/metrics"
|
||||||
addr = "localhost:9153"
|
addr = "localhost:9135" // 9153 is occopied by bind_exporter
|
||||||
)
|
)
|
||||||
|
|
||||||
var once sync.Once
|
var once sync.Once
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package etcd
|
package etcd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/miekg/coredns/middleware"
|
"github.com/miekg/coredns/middleware"
|
||||||
@@ -12,7 +13,7 @@ import (
|
|||||||
func (e Etcd) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) {
|
func (e Etcd) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) {
|
||||||
state := middleware.State{W: w, Req: r}
|
state := middleware.State{W: w, Req: r}
|
||||||
if state.QClass() != dns.ClassINET {
|
if state.QClass() != dns.ClassINET {
|
||||||
return e.Next.ServeDNS(ctx, w, r)
|
return dns.RcodeServerFailure, fmt.Errorf("can only deal with ClassINET")
|
||||||
}
|
}
|
||||||
|
|
||||||
// We need to check stubzones first, because we may get a request for a zone we
|
// We need to check stubzones first, because we may get a request for a zone we
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package file
|
package file
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
@@ -25,7 +26,7 @@ type (
|
|||||||
func (f File) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) {
|
func (f File) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) {
|
||||||
state := middleware.State{W: w, Req: r}
|
state := middleware.State{W: w, Req: r}
|
||||||
if state.QClass() != dns.ClassINET {
|
if state.QClass() != dns.ClassINET {
|
||||||
return f.Next.ServeDNS(ctx, w, r)
|
return dns.RcodeServerFailure, fmt.Errorf("can only deal with ClassINET")
|
||||||
}
|
}
|
||||||
qname := state.Name()
|
qname := state.Name()
|
||||||
zone := middleware.Zones(f.Zones.Names).Matches(qname)
|
zone := middleware.Zones(f.Zones.Names).Matches(qname)
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ Transfer:
|
|||||||
|
|
||||||
z.Tree = z1.Tree
|
z.Tree = z1.Tree
|
||||||
*z.Expired = false
|
*z.Expired = false
|
||||||
log.Printf("[INFO] Transfered: %s", z.name)
|
log.Printf("[INFO] Transferred: %s", z.name)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,6 @@ prometheus
|
|||||||
For each zone that you want to see metrics for.
|
For each zone that you want to see metrics for.
|
||||||
|
|
||||||
It optionally takes an address where the metrics are exported, the default
|
It optionally takes an address where the metrics are exported, the default
|
||||||
is `localhost:9153`. The metrics path is fixed to `/metrics`.
|
is `localhost:9154`. The metrics path is fixed to `/metrics`.
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ func (m *Metrics) Start() error {
|
|||||||
|
|
||||||
http.Handle(path, prometheus.Handler())
|
http.Handle(path, prometheus.Handler())
|
||||||
go func() {
|
go func() {
|
||||||
|
// TODO(miek): Logging here?
|
||||||
fmt.Errorf("%s", http.ListenAndServe(m.Addr, nil))
|
fmt.Errorf("%s", http.ListenAndServe(m.Addr, nil))
|
||||||
}()
|
}()
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user