diff --git a/docs/dashboards/grafana_prometheus.json b/docs/dashboards/grafana_prometheus.json index 32b43a35..c8960316 100644 --- a/docs/dashboards/grafana_prometheus.json +++ b/docs/dashboards/grafana_prometheus.json @@ -22,7 +22,7 @@ "type": "grafana", "id": "grafana", "name": "Grafana", - "version": "9.5.6" + "version": "11.2.2" }, { "type": "panel", @@ -116,13 +116,13 @@ "y": 0 }, "id": 79, - "links": [], "maxDataPoints": 100, "options": { "colorMode": "none", "graphMode": "none", "justifyMode": "center", "orientation": "auto", + "percentChangeColorMode": "standard", "reduceOptions": { "calcs": [ "lastNotNull" @@ -130,12 +130,14 @@ "fields": "/^version$/", "values": false }, + "showPercentChange": false, "text": { "valueSize": 15 }, - "textMode": "value" + "textMode": "value", + "wideLayout": true }, - "pluginVersion": "9.5.6", + "pluginVersion": "11.2.2", "targets": [ { "datasource": { @@ -192,13 +194,13 @@ "y": 0 }, "id": 56, - "links": [], "maxDataPoints": 100, "options": { "colorMode": "background", "graphMode": "none", "justifyMode": "center", "orientation": "vertical", + "percentChangeColorMode": "standard", "reduceOptions": { "calcs": [ "lastNotNull" @@ -206,10 +208,12 @@ "fields": "", "values": false }, + "showPercentChange": false, "text": {}, - "textMode": "auto" + "textMode": "auto", + "wideLayout": true }, - "pluginVersion": "9.5.6", + "pluginVersion": "11.2.2", "targets": [ { "datasource": { @@ -265,13 +269,13 @@ "y": 0 }, "id": 40, - "links": [], "maxDataPoints": 100, "options": { "colorMode": "background", "graphMode": "area", "justifyMode": "auto", "orientation": "auto", + "percentChangeColorMode": "standard", "reduceOptions": { "calcs": [ "lastNotNull" @@ -279,10 +283,12 @@ "fields": "", "values": false }, + "showPercentChange": false, "text": {}, - "textMode": "value_and_name" + "textMode": "value_and_name", + "wideLayout": true }, - "pluginVersion": "9.5.6", + "pluginVersion": "11.2.2", "targets": [ { "datasource": { @@ -338,13 +344,13 @@ "y": 0 }, "id": 78, - "links": [], "maxDataPoints": 100, "options": { "colorMode": "background", "graphMode": "none", "justifyMode": "center", "orientation": "auto", + "percentChangeColorMode": "standard", "reduceOptions": { "calcs": [ "lastNotNull" @@ -352,10 +358,12 @@ "fields": "", "values": false }, + "showPercentChange": false, "text": {}, - "textMode": "auto" + "textMode": "auto", + "wideLayout": true }, - "pluginVersion": "9.5.6", + "pluginVersion": "11.2.2", "targets": [ { "datasource": { @@ -410,13 +418,13 @@ "y": 0 }, "id": 77, - "links": [], "maxDataPoints": 100, "options": { "colorMode": "background", "graphMode": "none", "justifyMode": "center", "orientation": "horizontal", + "percentChangeColorMode": "standard", "reduceOptions": { "calcs": [ "lastNotNull" @@ -424,10 +432,12 @@ "fields": "", "values": false }, + "showPercentChange": false, "text": {}, - "textMode": "auto" + "textMode": "auto", + "wideLayout": true }, - "pluginVersion": "9.5.6", + "pluginVersion": "11.2.2", "targets": [ { "datasource": { @@ -482,13 +492,13 @@ "y": 0 }, "id": 27, - "links": [], "maxDataPoints": 100, "options": { "colorMode": "background", "graphMode": "none", "justifyMode": "center", "orientation": "horizontal", + "percentChangeColorMode": "standard", "reduceOptions": { "calcs": [ "lastNotNull" @@ -496,10 +506,12 @@ "fields": "", "values": false }, + "showPercentChange": false, "text": {}, - "textMode": "auto" + "textMode": "auto", + "wideLayout": true }, - "pluginVersion": "9.5.6", + "pluginVersion": "11.2.2", "targets": [ { "datasource": { @@ -554,13 +566,13 @@ "y": 0 }, "id": 81, - "links": [], "maxDataPoints": 100, "options": { "colorMode": "background", "graphMode": "none", "justifyMode": "center", "orientation": "horizontal", + "percentChangeColorMode": "standard", "reduceOptions": { "calcs": [ "lastNotNull" @@ -568,10 +580,12 @@ "fields": "", "values": false }, + "showPercentChange": false, "text": {}, - "textMode": "auto" + "textMode": "auto", + "wideLayout": true }, - "pluginVersion": "9.5.6", + "pluginVersion": "11.2.2", "targets": [ { "datasource": { @@ -605,11 +619,13 @@ "mode": "palette-classic" }, "custom": { + "axisBorderShow": false, "axisCenteredZero": false, "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 10, "gradientMode": "none", @@ -618,6 +634,7 @@ "tooltip": false, "viz": false }, + "insertNulls": false, "lineInterpolation": "linear", "lineWidth": 1, "pointSize": 5, @@ -718,18 +735,92 @@ }, "gridPos": { "h": 8, - "w": 7, + "w": 4, "x": 0, "y": 3 }, + "id": 93, + "options": { + "displayLabels": [ + "percent" + ], + "legend": { + "displayMode": "list", + "placement": "bottom", + "showLegend": true, + "values": [ + "percent" + ] + }, + "pieType": "donut", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "9.2.5", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "editorMode": "code", + "exemplar": true, + "expr": "sum by (operation) (increase(${prom_prefix}_operations_total{job=~\"$job\", stream_id=~\"$stream_id\"}[$__range])) != 0", + "format": "time_series", + "instant": false, + "interval": "", + "legendFormat": "__auto", + "refId": "A" + } + ], + "title": "DNS messages per operations", + "type": "piechart" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + } + }, + "mappings": [], + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 4, + "x": 4, + "y": 3 + }, "id": 74, "options": { "displayLabels": [ "percent" ], "legend": { - "displayMode": "table", - "placement": "right", + "displayMode": "list", + "placement": "bottom", "showLegend": true, "values": [ "percent" @@ -766,7 +857,6 @@ } ], "title": "Replies per return code", - "transformations": [], "type": "piechart" }, { @@ -793,8 +883,8 @@ }, "gridPos": { "h": 8, - "w": 6, - "x": 7, + "w": 5, + "x": 8, "y": 3 }, "id": 70, @@ -841,7 +931,6 @@ } ], "title": "Queries per type", - "transformations": [], "type": "piechart" }, { @@ -913,7 +1002,6 @@ } ], "title": "Transports", - "transformations": [], "type": "piechart" }, { @@ -928,11 +1016,13 @@ "mode": "palette-classic" }, "custom": { + "axisBorderShow": false, "axisCenteredZero": false, "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 10, "gradientMode": "none", @@ -941,6 +1031,7 @@ "tooltip": false, "viz": false }, + "insertNulls": false, "lineInterpolation": "linear", "lineWidth": 1, "pointSize": 5, @@ -1096,7 +1187,6 @@ } ], "title": "IP Protocols", - "transformations": [], "type": "piechart" }, { @@ -1168,11 +1258,11 @@ ], "show": false }, - "frameIndex": 1, + "frameIndex": 0, "showHeader": false, "sortBy": [] }, - "pluginVersion": "9.5.6", + "pluginVersion": "11.2.2", "targets": [ { "datasource": { @@ -1388,11 +1478,13 @@ "mode": "palette-classic" }, "custom": { + "axisBorderShow": false, "axisCenteredZero": false, "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 11, "gradientMode": "none", @@ -1401,6 +1493,7 @@ "tooltip": false, "viz": false }, + "insertNulls": false, "lineInterpolation": "linear", "lineStyle": { "fill": "solid" @@ -1487,11 +1580,13 @@ "mode": "palette-classic" }, "custom": { + "axisBorderShow": false, "axisCenteredZero": false, "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 11, "gradientMode": "none", @@ -1500,6 +1595,7 @@ "tooltip": false, "viz": false }, + "insertNulls": false, "lineInterpolation": "linear", "lineStyle": { "fill": "solid" @@ -1576,8 +1672,7 @@ } ], "refresh": "5s", - "schemaVersion": 38, - "style": "dark", + "schemaVersion": 39, "tags": [], "templating": { "list": [ @@ -1656,6 +1751,6 @@ "timezone": "", "title": "DNScollector - Dashboard for Prometheus", "uid": "6uPErf6nz", - "version": 4, + "version": 2, "weekStart": "" } \ No newline at end of file diff --git a/workers/prometheus.go b/workers/prometheus.go index a0c94b12..0f1f2087 100644 --- a/workers/prometheus.go +++ b/workers/prometheus.go @@ -48,6 +48,7 @@ type EpsCounters struct { TotalRcodes, TotalQtypes map[string]float64 TotalIPVersion, TotalIPProtocol map[string]float64 + TotalOperations map[string]float64 TotalDNSMessages float64 TotalQueries, TotalReplies int TotalBytes, TotalBytesSent, TotalBytesReceived int @@ -166,6 +167,7 @@ type Prometheus struct { counterQtypes, counterRcodes *prometheus.Desc counterIPProtocol, counterIPVersion *prometheus.Desc counterDNSMessages, counterDNSQueries, counterDNSReplies *prometheus.Desc + counterOperations *prometheus.Desc counterFlagsTC, counterFlagsAA *prometheus.Desc counterFlagsRA, counterFlagsAD *prometheus.Desc @@ -196,6 +198,7 @@ func newPrometheusCounterSet(w *Prometheus, labels prometheus.Labels) *Prometheu epsCounters: EpsCounters{ TotalRcodes: make(map[string]float64), TotalQtypes: make(map[string]float64), TotalIPVersion: make(map[string]float64), TotalIPProtocol: make(map[string]float64), + TotalOperations: make(map[string]float64), }, topRequesters: topmap.NewTopMap(w.GetConfig().Loggers.Prometheus.TopN), @@ -248,6 +251,7 @@ func (w *PrometheusCountersSet) Describe(ch chan<- *prometheus.Desc) { ch <- w.prom.counterQtypes ch <- w.prom.counterRcodes + ch <- w.prom.counterOperations ch <- w.prom.counterIPProtocol ch <- w.prom.counterIPVersion ch <- w.prom.counterDNSMessages @@ -374,6 +378,12 @@ func (w *PrometheusCountersSet) Record(dm dnsutils.DNSMessage) { w.epsCounters.TotalRcodes[dm.DNS.Rcode]++ } + if _, exists := w.epsCounters.TotalOperations[dm.DNSTap.Operation]; !exists { + w.epsCounters.TotalOperations[dm.DNSTap.Operation] = 1 + } else { + w.epsCounters.TotalOperations[dm.DNSTap.Operation]++ + } + if dm.DNS.Type == dnsutils.DNSQuery { w.epsCounters.TotalBytesReceived += dm.DNS.Length w.epsCounters.TotalQueries++ @@ -518,6 +528,13 @@ func (w *PrometheusCountersSet) Collect(ch chan<- prometheus.Metric) { ) } + // Update DNSTap Operations counter + for k, v := range w.epsCounters.TotalOperations { + ch <- prometheus.MustNewConstMetric(w.prom.counterOperations, prometheus.CounterValue, + v, k, + ) + } + // Update IP protocol counter for k, v := range w.epsCounters.TotalIPProtocol { ch <- prometheus.MustNewConstMetric(w.prom.counterIPProtocol, prometheus.CounterValue, @@ -880,6 +897,12 @@ func (w *Prometheus) InitProm() { []string{"return_code"}, nil, ) + w.counterOperations = prometheus.NewDesc( + fmt.Sprintf("%s_operations_total", promPrefix), + "Counter of dns messages per operations", + []string{"operation"}, nil, + ) + w.counterIPProtocol = prometheus.NewDesc( fmt.Sprintf("%s_ipprotocol_total", promPrefix), "Counter of packets per IP protocol",