From 318b6deb8e4f89beb4084808a6e2eac5daeb95d2 Mon Sep 17 00:00:00 2001 From: Lukas Eklund Date: Thu, 18 Apr 2024 15:07:32 -0500 Subject: [PATCH] add VCL on Compute metrics --- pkg/realtime/metrics.go | 14 ++++++++ pkg/realtime/process.go | 7 ++++ pkg/realtime/response.go | 7 ++++ pkg/rt/common_test.go | 70 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 98 insertions(+) diff --git a/pkg/realtime/metrics.go b/pkg/realtime/metrics.go index efed499..7bff49f 100644 --- a/pkg/realtime/metrics.go +++ b/pkg/realtime/metrics.go @@ -197,6 +197,13 @@ type Metrics struct { SynthsTotal *prometheus.CounterVec TLSTotal *prometheus.CounterVec UncacheableTotal *prometheus.CounterVec + VclOnComputeEdgeHitRequestsTotal *prometheus.CounterVec + VclOnComputeEdgeMissRequestsTotal *prometheus.CounterVec + VclOnComputeErrorRequestsTotal *prometheus.CounterVec + VclOnComputeHitRequestsTotal *prometheus.CounterVec + VclOnComputeMissRequestsTotal *prometheus.CounterVec + VclOnComputePassRequestsTotal *prometheus.CounterVec + VclOnComputeSynthRequestsTotal *prometheus.CounterVec VideoTotal *prometheus.CounterVec WAFBlockedTotal *prometheus.CounterVec WAFLoggedTotal *prometheus.CounterVec @@ -402,6 +409,13 @@ func NewMetrics(namespace, subsystem string, nameFilter filter.Filter, r prometh SynthsTotal: prometheus.NewCounterVec(prometheus.CounterOpts{Namespace: namespace, Subsystem: subsystem, Name: "synth_total", Help: "TODO"}, []string{"service_id", "service_name", "datacenter"}), TLSTotal: prometheus.NewCounterVec(prometheus.CounterOpts{Namespace: namespace, Subsystem: subsystem, Name: "tls_total", Help: "Number of requests that were received over TLS."}, []string{"service_id", "service_name", "datacenter", "tls_version"}), UncacheableTotal: prometheus.NewCounterVec(prometheus.CounterOpts{Namespace: namespace, Subsystem: subsystem, Name: "uncacheable_total", Help: "Number of requests that were designated uncachable."}, []string{"service_id", "service_name", "datacenter"}), + VclOnComputeHitRequestsTotal: prometheus.NewCounterVec(prometheus.CounterOpts{Namespace: namespace, Subsystem: subsystem, Name: "vcl_on_compute_hit_requests_total", Help: "Number of cache hits for a VCL service running on Compute."}, []string{"service_id", "service_name", "datacenter"}), + VclOnComputeMissRequestsTotal: prometheus.NewCounterVec(prometheus.CounterOpts{Namespace: namespace, Subsystem: subsystem, Name: "vcl_on_compute_miss_requests_total", Help: "Number of cache misses for a VCL service running on Compute."}, []string{"service_id", "service_name", "datacenter"}), + VclOnComputePassRequestsTotal: prometheus.NewCounterVec(prometheus.CounterOpts{Namespace: namespace, Subsystem: subsystem, Name: "vcl_on_compute_pass_requests_total", Help: "Number of requests that passed through the CDN without being cached for a VCL service running on Compute."}, []string{"service_id", "service_name", "datacenter"}), + VclOnComputeErrorRequestsTotal: prometheus.NewCounterVec(prometheus.CounterOpts{Namespace: namespace, Subsystem: subsystem, Name: "vcl_on_compute_error_requests_total", Help: "Number of cache errors for a VCL service running on Compute."}, []string{"service_id", "service_name", "datacenter"}), + VclOnComputeSynthRequestsTotal: prometheus.NewCounterVec(prometheus.CounterOpts{Namespace: namespace, Subsystem: subsystem, Name: "vcl_on_compute_synth_requests_total", Help: "Number of requests that returned a synthetic response (i.e., response objects created with the synthetic VCL statement) for a VCL service running on Compute."}, []string{"service_id", "service_name", "datacenter"}), + VclOnComputeEdgeHitRequestsTotal: prometheus.NewCounterVec(prometheus.CounterOpts{Namespace: namespace, Subsystem: subsystem, Name: "vcl_on_compute_edge_hit_requests_total", Help: "Number of requests sent by end users to Fastly that resulted in a hit at the edge for a VCL service running on Compute."}, []string{"service_id", "service_name", "datacenter"}), + VclOnComputeEdgeMissRequestsTotal: prometheus.NewCounterVec(prometheus.CounterOpts{Namespace: namespace, Subsystem: subsystem, Name: "vcl_on_compute_edge_miss_requests_total", Help: "Number of requests sent by end users to Fastly that resulted in a miss at the edge for a VCL service running on Compute."}, []string{"service_id", "service_name", "datacenter"}), VideoTotal: prometheus.NewCounterVec(prometheus.CounterOpts{Namespace: namespace, Subsystem: subsystem, Name: "video_total", Help: "Number of responses with the video segment or video manifest MIME type (i.e., application/x-mpegurl, application/vnd.apple.mpegurl, application/f4m, application/dash+xml, application/vnd.ms-sstr+xml, ideo/mp2t, audio/aac, video/f4f, video/x-flv, video/mp4, audio/mp4)."}, []string{"service_id", "service_name", "datacenter"}), WAFBlockedTotal: prometheus.NewCounterVec(prometheus.CounterOpts{Namespace: namespace, Subsystem: subsystem, Name: "waf_blocked_total", Help: "Number of requests that triggered a WAF rule and were blocked."}, []string{"service_id", "service_name", "datacenter"}), WAFLoggedTotal: prometheus.NewCounterVec(prometheus.CounterOpts{Namespace: namespace, Subsystem: subsystem, Name: "waf_logged_total", Help: "Number of requests that triggered a WAF rule and were logged."}, []string{"service_id", "service_name", "datacenter"}), diff --git a/pkg/realtime/process.go b/pkg/realtime/process.go index ddc3269..394576d 100644 --- a/pkg/realtime/process.go +++ b/pkg/realtime/process.go @@ -224,6 +224,13 @@ func Process(response *Response, serviceID, serviceName, serviceVersion string, m.TLSTotal.WithLabelValues(serviceID, serviceName, datacenter, "1.2").Add(float64(stats.TLSv12)) m.TLSTotal.WithLabelValues(serviceID, serviceName, datacenter, "1.3").Add(float64(stats.TLSv13)) m.UncacheableTotal.WithLabelValues(serviceID, serviceName, datacenter).Add(float64(stats.Uncacheable)) + m.VclOnComputeHitRequestsTotal.WithLabelValues(serviceID, serviceName, datacenter).Add(float64(stats.VclOnComputeHitRequests)) + m.VclOnComputeMissRequestsTotal.WithLabelValues(serviceID, serviceName, datacenter).Add(float64(stats.VclOnComputeMissRequests)) + m.VclOnComputePassRequestsTotal.WithLabelValues(serviceID, serviceName, datacenter).Add(float64(stats.VclOnComputePassRequests)) + m.VclOnComputeErrorRequestsTotal.WithLabelValues(serviceID, serviceName, datacenter).Add(float64(stats.VclOnComputeErrorRequests)) + m.VclOnComputeSynthRequestsTotal.WithLabelValues(serviceID, serviceName, datacenter).Add(float64(stats.VclOnComputeSynthRequests)) + m.VclOnComputeEdgeHitRequestsTotal.WithLabelValues(serviceID, serviceName, datacenter).Add(float64(stats.VclOnComputeEdgeHitRequests)) + m.VclOnComputeEdgeMissRequestsTotal.WithLabelValues(serviceID, serviceName, datacenter).Add(float64(stats.VclOnComputeEdgeMissRequests)) m.VideoTotal.WithLabelValues(serviceID, serviceName, datacenter).Add(float64(stats.Video)) m.WAFBlockedTotal.WithLabelValues(serviceID, serviceName, datacenter).Add(float64(stats.WAFBlocked)) m.WAFLoggedTotal.WithLabelValues(serviceID, serviceName, datacenter).Add(float64(stats.WAFLogged)) diff --git a/pkg/realtime/response.go b/pkg/realtime/response.go index 2714f05..15b9257 100644 --- a/pkg/realtime/response.go +++ b/pkg/realtime/response.go @@ -238,6 +238,13 @@ type Datacenter struct { TLSv12 uint64 `json:"tls_v12"` TLSv13 uint64 `json:"tls_v13"` Uncacheable uint64 `json:"uncacheable"` + VclOnComputeEdgeHitRequests uint64 `json:"vcl_on_compute_edge_hit_requests"` + VclOnComputeEdgeMissRequests uint64 `json:"vcl_on_compute_edge_miss_requests"` + VclOnComputeErrorRequests uint64 `json:"vcl_on_compute_error_requests"` + VclOnComputeHitRequests uint64 `json:"vcl_on_compute_hit_requests"` + VclOnComputeMissRequests uint64 `json:"vcl_on_compute_miss_requests"` + VclOnComputePassRequests uint64 `json:"vcl_on_compute_pass_requests"` + VclOnComputeSynthRequests uint64 `json:"vcl_on_compute_synth_requests"` Video uint64 `json:"video"` WAFBlocked uint64 `json:"waf_blocked"` WAFLogged uint64 `json:"waf_logged"` diff --git a/pkg/rt/common_test.go b/pkg/rt/common_test.go index 52f9cbf..1f271b0 100644 --- a/pkg/rt/common_test.go +++ b/pkg/rt/common_test.go @@ -4333,6 +4333,76 @@ var expectedRTMetricsOutputMap = map[string]float64{ `testspace_testsystem_uncacheable_total{datacenter="TYO",service_id="my-service-id",service_name="my-service-name"}`: 0, `testspace_testsystem_uncacheable_total{datacenter="YUL",service_id="my-service-id",service_name="my-service-name"}`: 0, `testspace_testsystem_uncacheable_total{datacenter="YYZ",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_hit_requests_total{datacenter="BUR",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_hit_requests_total{datacenter="BWI",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_hit_requests_total{datacenter="FRA",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_hit_requests_total{datacenter="HHN",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_hit_requests_total{datacenter="LGA",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_hit_requests_total{datacenter="SEA",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_hit_requests_total{datacenter="SYD",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_hit_requests_total{datacenter="TYO",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_hit_requests_total{datacenter="YUL",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_hit_requests_total{datacenter="YYZ",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_miss_requests_total{datacenter="BUR",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_miss_requests_total{datacenter="BWI",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_miss_requests_total{datacenter="FRA",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_miss_requests_total{datacenter="HHN",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_miss_requests_total{datacenter="LGA",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_miss_requests_total{datacenter="SEA",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_miss_requests_total{datacenter="SYD",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_miss_requests_total{datacenter="TYO",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_miss_requests_total{datacenter="YUL",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_miss_requests_total{datacenter="YYZ",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_pass_requests_total{datacenter="BUR",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_pass_requests_total{datacenter="BWI",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_pass_requests_total{datacenter="FRA",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_pass_requests_total{datacenter="HHN",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_pass_requests_total{datacenter="LGA",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_pass_requests_total{datacenter="SEA",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_pass_requests_total{datacenter="SYD",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_pass_requests_total{datacenter="TYO",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_pass_requests_total{datacenter="YUL",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_pass_requests_total{datacenter="YYZ",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_error_requests_total{datacenter="BUR",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_error_requests_total{datacenter="BWI",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_error_requests_total{datacenter="FRA",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_error_requests_total{datacenter="HHN",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_error_requests_total{datacenter="LGA",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_error_requests_total{datacenter="SEA",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_error_requests_total{datacenter="SYD",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_error_requests_total{datacenter="TYO",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_error_requests_total{datacenter="YUL",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_error_requests_total{datacenter="YYZ",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_synth_requests_total{datacenter="BUR",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_synth_requests_total{datacenter="BWI",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_synth_requests_total{datacenter="FRA",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_synth_requests_total{datacenter="HHN",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_synth_requests_total{datacenter="LGA",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_synth_requests_total{datacenter="SEA",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_synth_requests_total{datacenter="SYD",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_synth_requests_total{datacenter="TYO",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_synth_requests_total{datacenter="YUL",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_synth_requests_total{datacenter="YYZ",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_edge_hit_requests_total{datacenter="BUR",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_edge_hit_requests_total{datacenter="BWI",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_edge_hit_requests_total{datacenter="FRA",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_edge_hit_requests_total{datacenter="HHN",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_edge_hit_requests_total{datacenter="LGA",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_edge_hit_requests_total{datacenter="SEA",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_edge_hit_requests_total{datacenter="SYD",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_edge_hit_requests_total{datacenter="TYO",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_edge_hit_requests_total{datacenter="YUL",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_edge_hit_requests_total{datacenter="YYZ",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_edge_miss_requests_total{datacenter="BUR",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_edge_miss_requests_total{datacenter="BWI",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_edge_miss_requests_total{datacenter="FRA",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_edge_miss_requests_total{datacenter="HHN",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_edge_miss_requests_total{datacenter="LGA",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_edge_miss_requests_total{datacenter="SEA",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_edge_miss_requests_total{datacenter="SYD",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_edge_miss_requests_total{datacenter="TYO",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_edge_miss_requests_total{datacenter="YUL",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_edge_miss_requests_total{datacenter="YYZ",service_id="my-service-id",service_name="my-service-name"}`: 0, `testspace_testsystem_video_total{datacenter="BUR",service_id="my-service-id",service_name="my-service-name"}`: 0, `testspace_testsystem_video_total{datacenter="BWI",service_id="my-service-id",service_name="my-service-name"}`: 0, `testspace_testsystem_video_total{datacenter="FRA",service_id="my-service-id",service_name="my-service-name"}`: 0,