Skip to main content

Stats

Struct Stats 

Source
pub struct Stats<'a> { /* private fields */ }
Expand description

Statistics routes, from Client::stats.

Zone views need access to the zone (a zone key sees its zone); client views need a personal key (a zone key gets ErrorCode::Forbidden). Every time in a response is in milliseconds.

§Errors

Every method can fail with:

Implementations§

Source§

impl<'a> Stats<'a>

Source

pub async fn zone_queries( &self, zone: &str, group_by: Option<StatsGroup>, name: Option<&str>, query: &StatsSeriesQuery, ) -> Result<StatsSeriesResult>

Queries to the zone over time. group_by: Rcode (Core’s default, NXDOMAIN included), Qtype, Geo (country), Name or None; with name, only that name (then without NXDOMAIN).

GET /api/v1/stats/zones/:ref/queries

§Errors

ErrorCode::NotFound if there is no such zone.

§Examples
use std::time::{Duration, SystemTime};
use dinio_sdk::api::{StatsGroup, StatsSeriesQuery, StatsStep};

let week = StatsSeriesQuery {
    from: Some((SystemTime::now() - Duration::from_secs(7 * 86_400)).into()),
    step: Some(StatsStep::Day),
    ..Default::default()
};
let result = client
    .stats()
    .zone_queries("example.com", Some(StatsGroup::Qtype), None, &week)
    .await?;
for series in &result.series {
    println!("{} {}", series.label, series.total);
}
Source

pub async fn zone_nx( &self, zone: &str, query: &StatsSeriesQuery, ) -> Result<ZoneNxStats>

NXDOMAIN answers under the zone over time, and an estimate of how many distinct non-existent names were asked.

GET /api/v1/stats/zones/:ref/nx

§Errors

ErrorCode::NotFound if there is no such zone.

Source

pub async fn zone_names( &self, zone: &str, query: &StatsTopQuery, ) -> Result<ZoneNamesStats>

The zone’s busiest names, with their rcode and qtype breakdown.

GET /api/v1/stats/zones/:ref/names

§Errors

ErrorCode::NotFound if there is no such zone.

Source

pub async fn zone_nx_names( &self, zone: &str, query: &StatsTopQuery, ) -> Result<StatsTopList>

The most asked non-existent names under the zone (typos, scanners, missing records).

GET /api/v1/stats/zones/:ref/nx-names

§Errors

ErrorCode::NotFound if there is no such zone.

Source

pub async fn client_events( &self, scope: ClientScope, group_by: Option<StatsGroup>, query: &StatsSeriesQuery, ) -> Result<StatsSeriesResult>

Client traffic by event type; the share of key sinkhole is the blocked share. group_by: EventType (Core’s default), Client (labelled with identify) or None.

GET /api/v1/stats/clients/events

§Errors
§Examples
use dinio_sdk::api::{ClientScope, StatsSeriesQuery};

let phone = dinio_sdk::ops::find_client_identity(client, "phone").await?;
let events = client
    .stats()
    .client_events(ClientScope::Client(phone.uuid), None, &StatsSeriesQuery::default())
    .await?;
let blocked = events.series.iter().find(|s| s.key == "sinkhole").map_or(0.0, |s| s.share);
Source

pub async fn client_rcodes( &self, scope: ClientScope, group_by: Option<StatsGroup>, query: &StatsSeriesQuery, ) -> Result<StatsSeriesResult>

Answers to clients by rcode. group_by: Rcode (Core’s default), Client or None.

GET /api/v1/stats/clients/rcodes

§Errors

As client_events.

Source

pub async fn client_blocked( &self, scope: ClientScope, query: &StatsTopQuery, ) -> Result<StatsTopList>

The names most often blocked for clients (sinkhole hits).

GET /api/v1/stats/clients/blocked

§Errors

As client_events.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for Stats<'a>

§

impl<'a> !UnwindSafe for Stats<'a>

§

impl<'a> Freeze for Stats<'a>

§

impl<'a> Send for Stats<'a>

§

impl<'a> Sync for Stats<'a>

§

impl<'a> Unpin for Stats<'a>

§

impl<'a> UnsafeUnpin for Stats<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more