mirror of
				https://github.com/coredns/coredns.git
				synced 2025-10-31 10:13:14 -04:00 
			
		
		
		
	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:
		| @@ -89,8 +89,10 @@ example.org { | ||||
|  | ||||
| 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. | ||||
|   | ||||
| @@ -75,7 +75,7 @@ RulesCheckLoop: | ||||
| 				ede := dns.EDNS0_EDE{InfoCode: dns.ExtendedErrorCodeBlocked} | ||||
| 				m.IsEdns0().Option = append(m.IsEdns0().Option, &ede) | ||||
| 				w.WriteMsg(m) | ||||
| 				RequestBlockCount.WithLabelValues(metrics.WithServer(ctx), zone).Inc() | ||||
| 				RequestBlockCount.WithLabelValues(metrics.WithServer(ctx), zone, metrics.WithView(ctx)).Inc() | ||||
| 				return dns.RcodeSuccess, nil | ||||
| 			} | ||||
| 		case actionAllow: | ||||
| @@ -90,13 +90,13 @@ RulesCheckLoop: | ||||
| 				ede := dns.EDNS0_EDE{InfoCode: dns.ExtendedErrorCodeFiltered} | ||||
| 				m.IsEdns0().Option = append(m.IsEdns0().Option, &ede) | ||||
| 				w.WriteMsg(m) | ||||
| 				RequestFilterCount.WithLabelValues(metrics.WithServer(ctx), zone).Inc() | ||||
| 				RequestFilterCount.WithLabelValues(metrics.WithServer(ctx), zone, metrics.WithView(ctx)).Inc() | ||||
| 				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) | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -14,19 +14,19 @@ var ( | ||||
| 		Subsystem: pluginName, | ||||
| 		Name:      "blocked_requests_total", | ||||
| 		Help:      "Counter of DNS requests being blocked.", | ||||
| 	}, []string{"server", "zone"}) | ||||
| 	}, []string{"server", "zone", "view"}) | ||||
| 	// RequestFilterCount is the number of DNS requests being filtered. | ||||
| 	RequestFilterCount = promauto.NewCounterVec(prometheus.CounterOpts{ | ||||
| 		Namespace: plugin.Namespace, | ||||
| 		Subsystem: pluginName, | ||||
| 		Name:      "filtered_requests_total", | ||||
| 		Help:      "Counter of DNS requests being filtered.", | ||||
| 	}, []string{"server", "zone"}) | ||||
| 	}, []string{"server", "zone", "view"}) | ||||
| 	// RequestAllowCount is the number of DNS requests being Allowed. | ||||
| 	RequestAllowCount = promauto.NewCounterVec(prometheus.CounterOpts{ | ||||
| 		Namespace: plugin.Namespace, | ||||
| 		Subsystem: pluginName, | ||||
| 		Name:      "allowed_requests_total", | ||||
| 		Help:      "Counter of DNS requests being allowed.", | ||||
| 	}, []string{"server"}) | ||||
| 	}, []string{"server", "view"}) | ||||
| ) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user