session_id for metrics
This commit is contained in:
parent
1c8c3a573a
commit
807c53b133
1 changed files with 11 additions and 1 deletions
12
dnsstat.go
12
dnsstat.go
|
@ -3,6 +3,8 @@ package dnsstat
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
|
||||||
"github.com/coredns/caddy"
|
"github.com/coredns/caddy"
|
||||||
"github.com/coredns/coredns/core/dnsserver"
|
"github.com/coredns/coredns/core/dnsserver"
|
||||||
"github.com/coredns/coredns/plugin"
|
"github.com/coredns/coredns/plugin"
|
||||||
|
@ -19,7 +21,13 @@ type DNSStat struct {
|
||||||
Next plugin.Handler
|
Next plugin.Handler
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { plugin.Register("dnsstat", setup) }
|
// Session ID for current run for future better log partitioning in prometheus
|
||||||
|
var sessionID string
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
sessionID = uuid.New().String()
|
||||||
|
plugin.Register("dnsstat", setup)
|
||||||
|
}
|
||||||
|
|
||||||
// Register
|
// Register
|
||||||
func setup(c *caddy.Controller) error {
|
func setup(c *caddy.Controller) error {
|
||||||
|
@ -49,6 +57,7 @@ var requestCount = promauto.NewCounterVec(prometheus.CounterOpts{
|
||||||
"type",
|
"type",
|
||||||
"name",
|
"name",
|
||||||
"client_ip",
|
"client_ip",
|
||||||
|
"session_id",
|
||||||
})
|
})
|
||||||
|
|
||||||
// ServeDNS implements the plugin.Handler interface.
|
// ServeDNS implements the plugin.Handler interface.
|
||||||
|
@ -61,6 +70,7 @@ func (d DNSStat) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg)
|
||||||
state.Type(),
|
state.Type(),
|
||||||
state.Name(),
|
state.Name(),
|
||||||
state.IP(),
|
state.IP(),
|
||||||
|
sessionID,
|
||||||
).Inc()
|
).Inc()
|
||||||
return plugin.NextOrFailure(d.Name(), d.Next, ctx, w, r)
|
return plugin.NextOrFailure(d.Name(), d.Next, ctx, w, r)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue