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:
ErrorCode::TelemetryDisabledif Core runs without telemetry.ErrorCode::Validationfor a bad range (fromnot beforeto, over 92 days, over 2000 points) or a grouping the route does not take.Error::InvalidInputfor a time before 1970.
Implementations§
Source§impl<'a> Stats<'a>
impl<'a> Stats<'a>
Sourcepub async fn zone_queries(
&self,
zone: &str,
group_by: Option<StatsGroup>,
name: Option<&str>,
query: &StatsSeriesQuery,
) -> Result<StatsSeriesResult>
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);
}Sourcepub async fn zone_nx(
&self,
zone: &str,
query: &StatsSeriesQuery,
) -> Result<ZoneNxStats>
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.
Sourcepub async fn zone_names(
&self,
zone: &str,
query: &StatsTopQuery,
) -> Result<ZoneNamesStats>
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.
Sourcepub async fn zone_nx_names(
&self,
zone: &str,
query: &StatsTopQuery,
) -> Result<StatsTopList>
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.
Sourcepub async fn client_events(
&self,
scope: ClientScope,
group_by: Option<StatsGroup>,
query: &StatsSeriesQuery,
) -> Result<StatsSeriesResult>
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
ErrorCode::NotFoundif the identity does not exist.ErrorCode::Forbiddenfor another user’s identity or user, or with a zone key.
§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);Sourcepub async fn client_rcodes(
&self,
scope: ClientScope,
group_by: Option<StatsGroup>,
query: &StatsSeriesQuery,
) -> Result<StatsSeriesResult>
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.
Sourcepub async fn client_blocked(
&self,
scope: ClientScope,
query: &StatsTopQuery,
) -> Result<StatsTopList>
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.