@@ -31,10 +31,11 @@ type MetricsResolver struct {
3131 NextResolver
3232 typed
3333
34- totalQueries * prometheus.CounterVec
35- totalResponse * prometheus.CounterVec
36- totalErrors prometheus.Counter
37- durationHistogram * prometheus.HistogramVec
34+ totalQueries * prometheus.CounterVec
35+ totalResponse * prometheus.CounterVec
36+ totalClientResponse * prometheus.CounterVec
37+ totalErrors prometheus.Counter
38+ durationHistogram * prometheus.HistogramVec
3839}
3940
4041// Resolve resolves the passed request
@@ -45,8 +46,10 @@ func (r *MetricsResolver) Resolve(ctx context.Context, request *model.Request) (
4546 return response , err
4647 }
4748
49+ clientLabel := strings .Join (request .ClientNames , "," )
50+
4851 r .totalQueries .With (prometheus.Labels {
49- labelClient : strings . Join ( request . ClientNames , "," ) ,
52+ labelClient : clientLabel ,
5053 labelType : dns .TypeToString [request .Req .Question [0 ].Qtype ],
5154 }).Inc ()
5255
@@ -59,6 +62,11 @@ func (r *MetricsResolver) Resolve(ctx context.Context, request *model.Request) (
5962
6063 r .durationHistogram .WithLabelValues (responseType ).Observe (reqDuration .Seconds ())
6164
65+ r .totalClientResponse .With (prometheus.Labels {
66+ labelClient : clientLabel ,
67+ labelResponseType : responseType ,
68+ }).Inc ()
69+
6270 if err != nil {
6371 r .totalErrors .Inc ()
6472 } else {
@@ -87,10 +95,11 @@ func NewMetricsResolver(cfg config.Metrics) *MetricsResolver {
8795 configurable : withConfig (& cfg ),
8896 typed : withType ("metrics" ),
8997
90- durationHistogram : durationHistogram (),
91- totalQueries : totalQueriesMetric (),
92- totalResponse : totalResponseMetric (),
93- totalErrors : totalErrorMetric (),
98+ durationHistogram : durationHistogram (),
99+ totalQueries : totalQueriesMetric (),
100+ totalResponse : totalResponseMetric (),
101+ totalClientResponse : totalClientResponseMetric (),
102+ totalErrors : totalErrorMetric (),
94103 }
95104
96105 m .registerMetrics ()
@@ -102,6 +111,7 @@ func (r *MetricsResolver) registerMetrics() {
102111 metrics .RegisterMetric (r .durationHistogram )
103112 metrics .RegisterMetric (r .totalQueries )
104113 metrics .RegisterMetric (r .totalResponse )
114+ metrics .RegisterMetric (r .totalClientResponse )
105115 metrics .RegisterMetric (r .totalErrors )
106116}
107117
@@ -143,3 +153,12 @@ func totalResponseMetric() *prometheus.CounterVec {
143153 }, []string {labelReason , labelResponseCode , labelResponseType },
144154 )
145155}
156+
157+ func totalClientResponseMetric () * prometheus.CounterVec {
158+ return prometheus .NewCounterVec (
159+ prometheus.CounterOpts {
160+ Name : "blocky_client_response_total" ,
161+ Help : "Number of total responses per client and response type" ,
162+ }, []string {labelClient , labelResponseType },
163+ )
164+ }
0 commit comments