| 
									
										
										
										
											2018-01-08 11:52:25 +01:00
										 |  |  | package template
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import (
 | 
					
						
							|  |  |  | 	"github.com/coredns/coredns/plugin"
 | 
					
						
							| 
									
										
										
										
											2018-01-09 22:30:58 +01:00
										 |  |  | 	"github.com/coredns/coredns/plugin/metrics"
 | 
					
						
							| 
									
										
										
										
											2018-01-08 11:52:25 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-03 09:04:47 +08:00
										 |  |  | 	"github.com/caddyserver/caddy"
 | 
					
						
							| 
									
										
										
										
											2018-01-08 11:52:25 +01:00
										 |  |  | 	"github.com/prometheus/client_golang/prometheus"
 | 
					
						
							|  |  |  | )
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | var (
 | 
					
						
							| 
									
										
										
										
											2018-04-27 19:37:12 +01:00
										 |  |  | 	templateMatchesCount = prometheus.NewCounterVec(prometheus.CounterOpts{
 | 
					
						
							| 
									
										
										
										
											2018-01-08 11:52:25 +01:00
										 |  |  | 		Namespace: plugin.Namespace,
 | 
					
						
							|  |  |  | 		Subsystem: "template",
 | 
					
						
							|  |  |  | 		Name:      "matches_total",
 | 
					
						
							|  |  |  | 		Help:      "Counter of template regex matches.",
 | 
					
						
							| 
									
										
										
										
											2018-04-27 19:37:12 +01:00
										 |  |  | 	}, []string{"server", "zone", "class", "type"})
 | 
					
						
							|  |  |  | 	templateFailureCount = prometheus.NewCounterVec(prometheus.CounterOpts{
 | 
					
						
							| 
									
										
										
										
											2018-01-08 11:52:25 +01:00
										 |  |  | 		Namespace: plugin.Namespace,
 | 
					
						
							|  |  |  | 		Subsystem: "template",
 | 
					
						
							|  |  |  | 		Name:      "template_failures_total",
 | 
					
						
							|  |  |  | 		Help:      "Counter of go template failures.",
 | 
					
						
							| 
									
										
										
										
											2018-04-27 19:37:12 +01:00
										 |  |  | 	}, []string{"server", "zone", "class", "type", "section", "template"})
 | 
					
						
							|  |  |  | 	templateRRFailureCount = prometheus.NewCounterVec(prometheus.CounterOpts{
 | 
					
						
							| 
									
										
										
										
											2018-01-08 11:52:25 +01:00
										 |  |  | 		Namespace: plugin.Namespace,
 | 
					
						
							|  |  |  | 		Subsystem: "template",
 | 
					
						
							|  |  |  | 		Name:      "rr_failures_total",
 | 
					
						
							|  |  |  | 		Help:      "Counter of mis-templated RRs.",
 | 
					
						
							| 
									
										
										
										
											2018-04-27 19:37:12 +01:00
										 |  |  | 	}, []string{"server", "zone", "class", "type", "section", "template"})
 | 
					
						
							| 
									
										
										
										
											2018-01-08 11:52:25 +01:00
										 |  |  | )
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // OnStartupMetrics sets up the metrics on startup.
 | 
					
						
							| 
									
										
										
										
											2018-01-09 22:30:58 +01:00
										 |  |  | func setupMetrics(c *caddy.Controller) error {
 | 
					
						
							|  |  |  | 	c.OnStartup(func() error {
 | 
					
						
							| 
									
										
										
										
											2018-09-19 05:11:24 -04:00
										 |  |  | 		metrics.MustRegister(c, templateMatchesCount, templateFailureCount, templateRRFailureCount)
 | 
					
						
							| 
									
										
										
										
											2018-01-09 22:30:58 +01:00
										 |  |  | 		return nil
 | 
					
						
							| 
									
										
										
										
											2018-01-08 11:52:25 +01:00
										 |  |  | 	})
 | 
					
						
							| 
									
										
										
										
											2018-01-09 22:30:58 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-08 11:52:25 +01:00
										 |  |  | 	return nil
 | 
					
						
							|  |  |  | }
 |