diff --git a/widgets/nextdns-detailed/ReadMe.md b/widgets/nextdns-detailed/ReadMe.md new file mode 100644 index 00000000..561dacce --- /dev/null +++ b/widgets/nextdns-detailed/ReadMe.md @@ -0,0 +1,144 @@ +![](preview.png) + + +```yaml +- type: custom-api + title: NextDNS + title-url: https://my.nextdns.io/${NEXTDNS_PROFILE_ID}/analytics + cache: 1m + options: + profile: ${NEXTDNS_PROFILE_ID} + api-key: ${NEXTDNS_API_KEY} + template: | + + + {{ $profile := .Options.StringOr "profile" "" }} + {{ $apiKey := .Options.StringOr "api-key" "" }} + {{ $baseURL := print "https://api.nextdns.io/profiles/" $profile }} + + {{ $statusResp := newRequest (print $baseURL "/analytics/status?from=-30d") | withHeader "X-Api-Key" $apiKey | getResponse }} + {{ $reasonsResp := newRequest (print $baseURL "/analytics/reasons?from=-30d&limit=5&lang=en") | withHeader "X-Api-Key" $apiKey | getResponse }} + {{ $devicesResp := newRequest (print $baseURL "/analytics/devices?from=-30d&limit=5") | withHeader "X-Api-Key" $apiKey | getResponse }} + {{ $destResp := newRequest (print $baseURL "/analytics/destinations?type=countries&from=-30d&limit=5&lang=en") | withHeader "X-Api-Key" $apiKey | getResponse }} + {{ $logsResp := newRequest (print $baseURL "/logs?lang=en&limit=10") | withHeader "X-Api-Key" $apiKey | getResponse }} + +
+ {{ if $statusResp.JSON }} + {{ $total := 0 }}{{ $blocked := 0 }} + {{ range $statusResp.JSON.Array "data" }} + {{ $total = add $total (.Int "queries") }} + {{ if eq (.String "status") "blocked" }} + {{ $blocked = add $blocked (.Int "queries") }} + {{ end }} + {{ end }} +
+
+
{{ $total | formatNumber }}
+
QUERIES
+
+
+
{{ $blocked | formatNumber }}
+
BLOCKED
+
+
+
+ {{ if gt $total 0 }} + {{ div (mul $blocked 100.0) $total | printf "%.1f" }}% + {{ else }} + 0.0% + {{ end }} +
+
RATE
+
+
+ {{ end }} + + {{ if $reasonsResp.JSON }} +
+ Block Reasons + +
+ {{ end }} + + {{ if $devicesResp.JSON }} +
+ Active Devices + +
+ {{ end }} + + {{ if $destResp.JSON }} +
+ Destinations + +
+ {{ end }} + + {{ if $logsResp.JSON }} +
+ Live Traffic + +
+ {{ end }} +
+``` + +## Environment variables + +- `NEXTDNS_PROFILE_ID` - Your unique profile ID found in NextDNS control panel +- `NEXTDNS_API_KEY` - Configure and unique api key in your user profile diff --git a/widgets/nextdns-detailed/meta.yml b/widgets/nextdns-detailed/meta.yml new file mode 100644 index 00000000..8674fa0e --- /dev/null +++ b/widgets/nextdns-detailed/meta.yml @@ -0,0 +1,3 @@ +title: NextDNS Detailed +description: A comprehensive dashboard widget for monitoring NextDNS statistics, including overall queries, block rates, block reasons, active devices, top destinations, and live traffic logs. +author: keyiflerolsun diff --git a/widgets/nextdns-detailed/preview.png b/widgets/nextdns-detailed/preview.png new file mode 100644 index 00000000..aeff1c2e Binary files /dev/null and b/widgets/nextdns-detailed/preview.png differ