plugin/acl : add view label into metrics (#5615)

Signed-off-by: Ondřej Benkovský <ondrej.benkovsky@jamf.com>

Signed-off-by: Ondřej Benkovský <ondrej.benkovsky@jamf.com>
This commit is contained in:
Ondřej Benkovský
2022-09-12 22:35:59 +02:00
committed by GitHub
parent 8655b7cbc3
commit dc84196690
3 changed files with 10 additions and 8 deletions

View File

@@ -89,8 +89,10 @@ example.org {
If monitoring is enabled (via the _prometheus_ plugin) then the following metrics are exported: If monitoring is enabled (via the _prometheus_ plugin) then the following metrics are exported:
- `coredns_acl_blocked_requests_total{server, zone}` - counter of DNS requests being blocked. - `coredns_acl_blocked_requests_total{server, zone, view}` - counter of DNS requests being blocked.
- `coredns_acl_allowed_requests_total{server}` - counter of DNS requests being allowed. - `coredns_acl_filtered_requests_total{server, zone, view}` - counter of DNS requests being filtered.
- `coredns_acl_allowed_requests_total{server, view}` - counter of DNS requests being allowed.
The `server` and `zone` labels are explained in the _metrics_ plugin documentation. The `server` and `zone` labels are explained in the _metrics_ plugin documentation.

View File

@@ -75,7 +75,7 @@ RulesCheckLoop:
ede := dns.EDNS0_EDE{InfoCode: dns.ExtendedErrorCodeBlocked} ede := dns.EDNS0_EDE{InfoCode: dns.ExtendedErrorCodeBlocked}
m.IsEdns0().Option = append(m.IsEdns0().Option, &ede) m.IsEdns0().Option = append(m.IsEdns0().Option, &ede)
w.WriteMsg(m) w.WriteMsg(m)
RequestBlockCount.WithLabelValues(metrics.WithServer(ctx), zone).Inc() RequestBlockCount.WithLabelValues(metrics.WithServer(ctx), zone, metrics.WithView(ctx)).Inc()
return dns.RcodeSuccess, nil return dns.RcodeSuccess, nil
} }
case actionAllow: case actionAllow:
@@ -90,13 +90,13 @@ RulesCheckLoop:
ede := dns.EDNS0_EDE{InfoCode: dns.ExtendedErrorCodeFiltered} ede := dns.EDNS0_EDE{InfoCode: dns.ExtendedErrorCodeFiltered}
m.IsEdns0().Option = append(m.IsEdns0().Option, &ede) m.IsEdns0().Option = append(m.IsEdns0().Option, &ede)
w.WriteMsg(m) w.WriteMsg(m)
RequestFilterCount.WithLabelValues(metrics.WithServer(ctx), zone).Inc() RequestFilterCount.WithLabelValues(metrics.WithServer(ctx), zone, metrics.WithView(ctx)).Inc()
return dns.RcodeSuccess, nil return dns.RcodeSuccess, nil
} }
} }
} }
RequestAllowCount.WithLabelValues(metrics.WithServer(ctx)).Inc() RequestAllowCount.WithLabelValues(metrics.WithServer(ctx), metrics.WithView(ctx)).Inc()
return plugin.NextOrFailure(state.Name(), a.Next, ctx, w, r) return plugin.NextOrFailure(state.Name(), a.Next, ctx, w, r)
} }

View File

@@ -14,19 +14,19 @@ var (
Subsystem: pluginName, Subsystem: pluginName,
Name: "blocked_requests_total", Name: "blocked_requests_total",
Help: "Counter of DNS requests being blocked.", Help: "Counter of DNS requests being blocked.",
}, []string{"server", "zone"}) }, []string{"server", "zone", "view"})
// RequestFilterCount is the number of DNS requests being filtered. // RequestFilterCount is the number of DNS requests being filtered.
RequestFilterCount = promauto.NewCounterVec(prometheus.CounterOpts{ RequestFilterCount = promauto.NewCounterVec(prometheus.CounterOpts{
Namespace: plugin.Namespace, Namespace: plugin.Namespace,
Subsystem: pluginName, Subsystem: pluginName,
Name: "filtered_requests_total", Name: "filtered_requests_total",
Help: "Counter of DNS requests being filtered.", Help: "Counter of DNS requests being filtered.",
}, []string{"server", "zone"}) }, []string{"server", "zone", "view"})
// RequestAllowCount is the number of DNS requests being Allowed. // RequestAllowCount is the number of DNS requests being Allowed.
RequestAllowCount = promauto.NewCounterVec(prometheus.CounterOpts{ RequestAllowCount = promauto.NewCounterVec(prometheus.CounterOpts{
Namespace: plugin.Namespace, Namespace: plugin.Namespace,
Subsystem: pluginName, Subsystem: pluginName,
Name: "allowed_requests_total", Name: "allowed_requests_total",
Help: "Counter of DNS requests being allowed.", Help: "Counter of DNS requests being allowed.",
}, []string{"server"}) }, []string{"server", "view"})
) )