github.com/netdata/go.d.plugin@v0.58.1/modules/coredns/metrics.go (about)

     1  // SPDX-License-Identifier: GPL-3.0-or-later
     2  
     3  package coredns
     4  
     5  import (
     6  	mtx "github.com/netdata/go.d.plugin/pkg/metrics"
     7  )
     8  
     9  func newMetrics() *metrics {
    10  	mx := &metrics{}
    11  	mx.PerServer = make(map[string]*requestResponse)
    12  	mx.PerZone = make(map[string]*requestResponse)
    13  
    14  	return mx
    15  }
    16  
    17  type metrics struct {
    18  	Panic         mtx.Gauge                   `stm:"panic_total"`
    19  	NoZoneDropped mtx.Gauge                   `stm:"no_matching_zone_dropped_total"`
    20  	Summary       requestResponse             `stm:""`
    21  	PerServer     map[string]*requestResponse `stm:""`
    22  	PerZone       map[string]*requestResponse `stm:""`
    23  }
    24  
    25  type requestResponse struct {
    26  	Request  request  `stm:"request"`
    27  	Response response `stm:"response"`
    28  }
    29  
    30  type request struct {
    31  	Total     mtx.Gauge `stm:"total"`
    32  	PerStatus struct {
    33  		Processed mtx.Gauge `stm:"processed"`
    34  		Dropped   mtx.Gauge `stm:"dropped"`
    35  	} `stm:"per_status"`
    36  	PerProto struct {
    37  		UDP mtx.Gauge `stm:"udp"`
    38  		TCP mtx.Gauge `stm:"tcp"`
    39  	} `stm:"per_proto"`
    40  	PerIPFamily struct {
    41  		IPv4 mtx.Gauge `stm:"v4"`
    42  		IPv6 mtx.Gauge `stm:"v6"`
    43  	} `stm:"per_ip_family"`
    44  	// https://github.com/coredns/coredns/blob/master/plugin/metrics/vars/report.go
    45  	PerType struct {
    46  		A      mtx.Gauge `stm:"A"`
    47  		AAAA   mtx.Gauge `stm:"AAAA"`
    48  		MX     mtx.Gauge `stm:"MX"`
    49  		SOA    mtx.Gauge `stm:"SOA"`
    50  		CNAME  mtx.Gauge `stm:"CNAME"`
    51  		PTR    mtx.Gauge `stm:"PTR"`
    52  		TXT    mtx.Gauge `stm:"TXT"`
    53  		NS     mtx.Gauge `stm:"NS"`
    54  		SRV    mtx.Gauge `stm:"SRV"`
    55  		DS     mtx.Gauge `stm:"DS"`
    56  		DNSKEY mtx.Gauge `stm:"DNSKEY"`
    57  		RRSIG  mtx.Gauge `stm:"RRSIG"`
    58  		NSEC   mtx.Gauge `stm:"NSEC"`
    59  		NSEC3  mtx.Gauge `stm:"NSEC3"`
    60  		IXFR   mtx.Gauge `stm:"IXFR"`
    61  		ANY    mtx.Gauge `stm:"ANY"`
    62  		Other  mtx.Gauge `stm:"other"`
    63  	} `stm:"per_type"`
    64  	//Duration struct {
    65  	//	LE000025 mtx.Gauge `stm:"0.00025"`
    66  	//	LE00005  mtx.Gauge `stm:"0.0005"`
    67  	//	LE0001   mtx.Gauge `stm:"0.001"`
    68  	//	LE0002   mtx.Gauge `stm:"0.002"`
    69  	//	LE0004   mtx.Gauge `stm:"0.004"`
    70  	//	LE0008   mtx.Gauge `stm:"0.008"`
    71  	//	LE0016   mtx.Gauge `stm:"0.016"`
    72  	//	LE0032   mtx.Gauge `stm:"0.032"`
    73  	//	LE0064   mtx.Gauge `stm:"0.064"`
    74  	//	LE0128   mtx.Gauge `stm:"0.128"`
    75  	//	LE0256   mtx.Gauge `stm:"0.256"`
    76  	//	LE0512   mtx.Gauge `stm:"0.512"`
    77  	//	LE1024   mtx.Gauge `stm:"1.024"`
    78  	//	LE2048   mtx.Gauge `stm:"2.048"`
    79  	//	LE4096   mtx.Gauge `stm:"4.096"`
    80  	//	LE8192   mtx.Gauge `stm:"8.192"`
    81  	//	LEInf    mtx.Gauge `stm:"+Inf"`
    82  	//} `stm:"duration_seconds_bucket"`
    83  }
    84  
    85  // https://github.com/miekg/dns/blob/master/types.go
    86  // https://github.com/miekg/dns/blob/master/msg.go#L169
    87  type response struct {
    88  	Total    mtx.Gauge `stm:"total"`
    89  	PerRcode struct {
    90  		NOERROR   mtx.Gauge `stm:"NOERROR"`
    91  		FORMERR   mtx.Gauge `stm:"FORMERR"`
    92  		SERVFAIL  mtx.Gauge `stm:"SERVFAIL"`
    93  		NXDOMAIN  mtx.Gauge `stm:"NXDOMAIN"`
    94  		NOTIMP    mtx.Gauge `stm:"NOTIMP"`
    95  		REFUSED   mtx.Gauge `stm:"REFUSED"`
    96  		YXDOMAIN  mtx.Gauge `stm:"YXDOMAIN"`
    97  		YXRRSET   mtx.Gauge `stm:"YXRRSET"`
    98  		NXRRSET   mtx.Gauge `stm:"NXRRSET"`
    99  		NOTAUTH   mtx.Gauge `stm:"NOTAUTH"`
   100  		NOTZONE   mtx.Gauge `stm:"NOTZONE"`
   101  		BADSIG    mtx.Gauge `stm:"BADSIG"`
   102  		BADKEY    mtx.Gauge `stm:"BADKEY"`
   103  		BADTIME   mtx.Gauge `stm:"BADTIME"`
   104  		BADMODE   mtx.Gauge `stm:"BADMODE"`
   105  		BADNAME   mtx.Gauge `stm:"BADNAME"`
   106  		BADALG    mtx.Gauge `stm:"BADALG"`
   107  		BADTRUNC  mtx.Gauge `stm:"BADTRUNC"`
   108  		BADCOOKIE mtx.Gauge `stm:"BADCOOKIE"`
   109  		Other     mtx.Gauge `stm:"other"`
   110  	} `stm:"per_rcode"`
   111  }