diff --git a/README.md b/README.md index efe2d70..97cb143 100644 --- a/README.md +++ b/README.md @@ -119,6 +119,19 @@ Different flags (for the same filter target) combine with AND semantics. For example, `-metric-allowlist 'bytes_total$' -metric-blocklist imgopto` would only export metrics whose names ended in bytes_total, but didn't include imgopto. +### Metrics Grouping: by datacenter or aggregate + +The Fastly real-time stats API returns measurements grouped by datacenter as +well as aggregated measurements for all datacenters. By default, exported +metrics are grouped by datacenter. The response body size of the metrics +endpoint can potentially be very large. This will be exacerbated when using +the exporter with many services, many origins with Origin Inspector, and many +domains with Domain Inspector. One way to reduce the output size of the +metrics endpoint is by using the `-aggregate-only` flag. When this flag is +used only the `aggregated` metrics from the real-time stats API will be +exported. Metrics will still include the datacenter label but it will always +be set to "aggregate". + ### Service discovery Per-service metrics are available via `/metrics?target=`. Available diff --git a/cmd/fastly-exporter/main.go b/cmd/fastly-exporter/main.go index 33931fa..23f0ada 100644 --- a/cmd/fastly-exporter/main.go +++ b/cmd/fastly-exporter/main.go @@ -44,6 +44,7 @@ func main() { serviceRefresh time.Duration apiTimeout time.Duration rtTimeout time.Duration + aggregateOnly bool debug bool versionFlag bool configFileExample bool @@ -67,6 +68,7 @@ func main() { fs.DurationVar(&serviceRefresh, "api-refresh", 1*time.Minute, "DEPRECATED -- use service-refresh instead") fs.DurationVar(&apiTimeout, "api-timeout", 15*time.Second, "HTTP client timeout for api.fastly.com requests (5–60s)") fs.DurationVar(&rtTimeout, "rt-timeout", 45*time.Second, "HTTP client timeout for rt.fastly.com requests (45–120s)") + fs.BoolVar(&aggregateOnly, "aggregate-only", false, "Use aggregated data rather than per-datacenter") fs.BoolVar(&debug, "debug", false, "log debug information") fs.BoolVar(&versionFlag, "version", false, "print version information and exit") fs.String("config-file", "", "config file (optional)") @@ -341,6 +343,7 @@ func main() { subscriberOptions = []rt.SubscriberOption{ rt.WithLogger(rtLogger), rt.WithMetadataProvider(serviceCache), + rt.WithAggregateOnly(aggregateOnly), } ) manager = rt.NewManager(serviceCache, rtClient, token, registry, subscriberOptions, productCache, rtLogger) diff --git a/pkg/domain/process.go b/pkg/domain/process.go index 4b2eebc..b802b08 100644 --- a/pkg/domain/process.go +++ b/pkg/domain/process.go @@ -1,8 +1,18 @@ package domain // Process updates the metrics with data from the API response. -func Process(response *Response, serviceID, serviceName, serviceVersion string, m *Metrics) { +func Process(response *Response, serviceID, serviceName, _ string, m *Metrics, aggregateOnly bool) { + const aggregateDC = "aggregate" + for _, d := range response.Data { + if aggregateOnly { + for domain, stats := range d.Aggregated { + process(serviceID, serviceName, aggregateDC, domain, stats, m) + } + + continue + } + for datacenter, byDomain := range d.Datacenter { for domain, stats := range byDomain { process(serviceID, serviceName, datacenter, domain, stats, m) diff --git a/pkg/origin/process.go b/pkg/origin/process.go index 5396a09..749ceeb 100644 --- a/pkg/origin/process.go +++ b/pkg/origin/process.go @@ -7,8 +7,18 @@ const ( ) // Process updates the metrics with data from the API response. -func Process(response *Response, serviceID, serviceName, serviceVersion string, m *Metrics) { +func Process(response *Response, serviceID, serviceName, _ string, m *Metrics, aggregateOnly bool) { + const aggregateDC = "aggregate" + for _, d := range response.Data { + if aggregateOnly { + for origin, stats := range d.Aggregated { + process(serviceID, serviceName, aggregateDC, origin, stats, m) + } + + continue + } + for datacenter, byOrigin := range d.Datacenter { for origin, stats := range byOrigin { process(serviceID, serviceName, datacenter, origin, stats, m) diff --git a/pkg/realtime/process.go b/pkg/realtime/process.go index c84fa7c..ef3a902 100644 --- a/pkg/realtime/process.go +++ b/pkg/realtime/process.go @@ -7,8 +7,16 @@ import ( ) // Process updates the metrics with data from the API response. -func Process(response *Response, serviceID, serviceName, serviceVersion string, m *Metrics) { +func Process(response *Response, serviceID, serviceName, _ string, m *Metrics, aggregateOnly bool) { + const aggregateDC = "aggregate" + for _, d := range response.Data { + if aggregateOnly { + process(serviceID, serviceName, aggregateDC, d.Aggregated, m) + + continue + } + for datacenter, stats := range d.Datacenter { process(serviceID, serviceName, datacenter, stats, m) } diff --git a/pkg/rt/common_test.go b/pkg/rt/common_test.go index 9379026..9c6252b 100644 --- a/pkg/rt/common_test.go +++ b/pkg/rt/common_test.go @@ -4535,6 +4535,273 @@ var expectedRTMetricsOutputMap = map[string]float64{ `testspace_testsystem_websocket_resp_header_bytes_total{datacenter="YYZ",service_id="my-service-id",service_name="my-service-name"}`: 0, } +var expectedRTMetricsAggOutputMap = map[string]float64{ + `testspace_testsystem_attack_blocked_req_body_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_attack_blocked_req_header_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_attack_logged_req_body_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_attack_logged_req_header_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_attack_passed_req_body_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_attack_passed_req_header_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_attack_req_body_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_attack_req_header_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_attack_resp_synth_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_bereq_body_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_bereq_header_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 84871, + `testspace_testsystem_blacklist_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_body_size_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 1.237172e+07, + `testspace_testsystem_bot_challenge_complete_tokens_checked_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_bot_challenge_complete_tokens_disabled_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_bot_challenge_complete_tokens_failed_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_bot_challenge_complete_tokens_issued_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_bot_challenge_complete_tokens_passed_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_bot_challenge_starts_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_bot_challenges_failed_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_bot_challenges_issued_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_bot_challenges_succeeded_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_compute_bereq_body_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_compute_bereq_errors_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_compute_bereq_header_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_compute_bereq_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_compute_beresp_body_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_compute_beresp_header_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_compute_execution_time_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_compute_globals_limit_exceeded_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_compute_guest_errors_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_compute_heap_limit_exceeded_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_compute_ram_used_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_compute_req_body_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_compute_req_header_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_compute_request_time_billed_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_compute_request_time_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_compute_requests_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_compute_resource_limit_exceeded_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_compute_resp_body_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_compute_resp_header_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_compute_resp_status_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name",status_group="1xx"}`: 0, + `testspace_testsystem_compute_resp_status_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name",status_group="2xx"}`: 0, + `testspace_testsystem_compute_resp_status_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name",status_group="3xx"}`: 0, + `testspace_testsystem_compute_resp_status_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name",status_group="4xx"}`: 0, + `testspace_testsystem_compute_resp_status_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name",status_group="5xx"}`: 0, + `testspace_testsystem_compute_runtime_errors_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_compute_stack_limit_exceeded_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_ddos_action_blackhole_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_ddos_action_close_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_ddos_action_downgrade_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_ddos_action_downgraded_connections_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_ddos_action_limit_streams_connections_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_ddos_action_limit_streams_requests_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_ddos_action_tarpit_accept_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_ddos_action_tarpit_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_deliver_sub_count_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 90, + `testspace_testsystem_deliver_sub_time_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 2.095131e+06, + `testspace_testsystem_edge_hit_requests_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_edge_hit_resp_body_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_edge_hit_resp_header_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_edge_miss_requests_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_edge_miss_resp_body_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_edge_miss_resp_header_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_edge_resp_body_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 1.237172e+07, + `testspace_testsystem_edge_resp_header_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 36038, + `testspace_testsystem_edge_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 90, + `testspace_testsystem_error_sub_count_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_error_sub_time_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_errors_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_fanout_bereq_body_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_fanout_bereq_header_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_fanout_beresp_body_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_fanout_beresp_header_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_fanout_conn_time_ms_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_fanout_recv_publishes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_fanout_req_body_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_fanout_req_header_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_fanout_resp_body_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_fanout_resp_header_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_fanout_send_publishes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_fetch_sub_count_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_fetch_sub_time_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_hash_sub_count_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 90, + `testspace_testsystem_hash_sub_time_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 340481, + `testspace_testsystem_header_size_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 36038, + `testspace_testsystem_hit_resp_body_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 66578, + `testspace_testsystem_hit_sub_count_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 5, + `testspace_testsystem_hit_sub_time_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 21908, + `testspace_testsystem_hits_time_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0.000575, + `testspace_testsystem_hits_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 11, + `testspace_testsystem_http2_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 48, + `testspace_testsystem_http3_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 33, + `testspace_testsystem_http_total{datacenter="aggregate",http_version="1",service_id="my-service-id",service_name="my-service-name"}`: 10, + `testspace_testsystem_http_total{datacenter="aggregate",http_version="2",service_id="my-service-id",service_name="my-service-name"}`: 48, + `testspace_testsystem_http_total{datacenter="aggregate",http_version="3",service_id="my-service-id",service_name="my-service-name"}`: 33, + `testspace_testsystem_imgopto_resp_body_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_imgopto_resp_header_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_imgopto_shield_resp_body_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_imgopto_shield_resp_header_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_imgopto_shield_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_imgopto_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_imgopto_transform_resp_body_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_imgopto_transform_resp_header_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_imgopto_transforms_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_imgvideo_frames_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_imgvideo_resp_body_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_imgvideo_resp_header_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_imgvideo_shield_frames_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_imgvideo_shield_resp_body_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_imgvideo_shield_resp_header_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_imgvideo_shield_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_imgvideo_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_ipv6_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_kv_store_class_a_operations_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_kv_store_class_b_operations_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_last_successful_response{service_id="my-service-id",service_name="my-service-name"}`: 1.716236045e+09, + `testspace_testsystem_log_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_logging_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_miss_duration_seconds_bucket{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name",le="+Inf"}`: 79, + `testspace_testsystem_miss_duration_seconds_bucket{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name",le="0.005"}`: 3, + `testspace_testsystem_miss_duration_seconds_bucket{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name",le="0.01"}`: 6, + `testspace_testsystem_miss_duration_seconds_bucket{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name",le="0.025"}`: 12, + `testspace_testsystem_miss_duration_seconds_bucket{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name",le="0.05"}`: 41, + `testspace_testsystem_miss_duration_seconds_bucket{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name",le="0.1"}`: 68, + `testspace_testsystem_miss_duration_seconds_bucket{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name",le="0.25"}`: 72, + `testspace_testsystem_miss_duration_seconds_bucket{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name",le="0.5"}`: 78, + `testspace_testsystem_miss_duration_seconds_bucket{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name",le="1"}`: 79, + `testspace_testsystem_miss_duration_seconds_bucket{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name",le="16"}`: 79, + `testspace_testsystem_miss_duration_seconds_bucket{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name",le="2"}`: 79, + `testspace_testsystem_miss_duration_seconds_bucket{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name",le="32"}`: 79, + `testspace_testsystem_miss_duration_seconds_bucket{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name",le="4"}`: 79, + `testspace_testsystem_miss_duration_seconds_bucket{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name",le="60"}`: 79, + `testspace_testsystem_miss_duration_seconds_bucket{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name",le="8"}`: 79, + `testspace_testsystem_miss_duration_seconds_count{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 79, + `testspace_testsystem_miss_duration_seconds_sum{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 6.813999999999999, + `testspace_testsystem_miss_resp_body_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 1.2305142e+07, + `testspace_testsystem_miss_sub_count_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 85, + `testspace_testsystem_miss_sub_time_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 73946, + `testspace_testsystem_miss_time_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 6.22564403, + `testspace_testsystem_miss_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 79, + `testspace_testsystem_object_size_bytes_bucket{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name",le="+Inf"}`: 90, + `testspace_testsystem_object_size_bytes_bucket{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name",le="1.024e+06"}`: 89, + `testspace_testsystem_object_size_bytes_bucket{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name",le="1.024e+07"}`: 90, + `testspace_testsystem_object_size_bytes_bucket{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name",le="1.024e+08"}`: 90, + `testspace_testsystem_object_size_bytes_bucket{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name",le="1.024e+09"}`: 90, + `testspace_testsystem_object_size_bytes_bucket{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name",le="1024"}`: 7, + `testspace_testsystem_object_size_bytes_bucket{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name",le="10240"}`: 22, + `testspace_testsystem_object_size_bytes_bucket{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name",le="102400"}`: 41, + `testspace_testsystem_object_size_bytes_count{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 90, + `testspace_testsystem_object_size_bytes_sum{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 6.1498368e+07, + `testspace_testsystem_origin_cache_fetch_resp_body_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_origin_cache_fetch_resp_header_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_origin_cache_fetches_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_origin_fetch_body_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_origin_fetch_header_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 84871, + `testspace_testsystem_origin_fetch_resp_body_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 1.2326343e+07, + `testspace_testsystem_origin_fetch_resp_header_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 18600, + `testspace_testsystem_origin_fetches_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 82, + `testspace_testsystem_origin_revalidations_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 4, + `testspace_testsystem_otfp_deliver_time_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_otfp_manifests_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_otfp_resp_body_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_otfp_resp_header_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_otfp_shield_resp_body_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_otfp_shield_resp_header_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_otfp_shield_time_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_otfp_shield_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_otfp_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_otfp_transform_resp_body_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_otfp_transform_resp_header_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_otfp_transform_time_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_otfp_transforms_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_pass_resp_body_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_pass_sub_count_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_pass_sub_time_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_pass_time_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_pass_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_pci_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_pipe_sub_count_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_pipe_sub_time_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_pipe{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_predeliver_sub_count_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 90, + `testspace_testsystem_predeliver_sub_time_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 95970, + `testspace_testsystem_prehash_sub_count_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 90, + `testspace_testsystem_prehash_sub_time_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 62951, + `testspace_testsystem_realtime_api_requests_total{result="success",service_id="my-service-id",service_name="my-service-name"}`: 1, + `testspace_testsystem_recv_sub_count_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 180, + `testspace_testsystem_recv_sub_time_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 8.346979e+06, + `testspace_testsystem_req_body_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 192, + `testspace_testsystem_req_header_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 50603, + `testspace_testsystem_requests_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 91, + `testspace_testsystem_resp_body_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 1.237172e+07, + `testspace_testsystem_resp_header_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 36038, + `testspace_testsystem_restarts_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_segblock_origin_fetches_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_segblock_shield_fetches_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_service_info{service_id="my-service-id",service_name="my-service-name",service_version="123"}`: 1, + `testspace_testsystem_shield_cache_fetches_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_shield_fetch_body_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_shield_fetch_header_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_shield_fetch_resp_body_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_shield_fetch_resp_header_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_shield_fetches_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_shield_hit_requests_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_shield_hit_resp_body_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_shield_hit_resp_header_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_shield_miss_requests_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_shield_miss_resp_body_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_shield_miss_resp_header_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_shield_resp_body_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_shield_resp_header_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_shield_revalidations_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_shield_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_status_code_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name",status_code="200"}`: 85, + `testspace_testsystem_status_code_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name",status_code="204"}`: 0, + `testspace_testsystem_status_code_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name",status_code="206"}`: 0, + `testspace_testsystem_status_code_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name",status_code="301"}`: 0, + `testspace_testsystem_status_code_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name",status_code="302"}`: 0, + `testspace_testsystem_status_code_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name",status_code="304"}`: 1, + `testspace_testsystem_status_code_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name",status_code="400"}`: 0, + `testspace_testsystem_status_code_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name",status_code="401"}`: 0, + `testspace_testsystem_status_code_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name",status_code="403"}`: 0, + `testspace_testsystem_status_code_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name",status_code="404"}`: 4, + `testspace_testsystem_status_code_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name",status_code="406"}`: 0, + `testspace_testsystem_status_code_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name",status_code="416"}`: 0, + `testspace_testsystem_status_code_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name",status_code="429"}`: 0, + `testspace_testsystem_status_code_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name",status_code="500"}`: 0, + `testspace_testsystem_status_code_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name",status_code="501"}`: 0, + `testspace_testsystem_status_code_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name",status_code="502"}`: 0, + `testspace_testsystem_status_code_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name",status_code="503"}`: 0, + `testspace_testsystem_status_code_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name",status_code="504"}`: 0, + `testspace_testsystem_status_code_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name",status_code="505"}`: 0, + `testspace_testsystem_status_group_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name",status_group="1xx"}`: 0, + `testspace_testsystem_status_group_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name",status_group="2xx"}`: 85, + `testspace_testsystem_status_group_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name",status_group="3xx"}`: 1, + `testspace_testsystem_status_group_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name",status_group="4xx"}`: 4, + `testspace_testsystem_status_group_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name",status_group="5xx"}`: 0, + `testspace_testsystem_synth_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_tls_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name",tls_version="1.0"}`: 0, + `testspace_testsystem_tls_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name",tls_version="1.1"}`: 0, + `testspace_testsystem_tls_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name",tls_version="1.2"}`: 87, + `testspace_testsystem_tls_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name",tls_version="1.3"}`: 0, + `testspace_testsystem_uncacheable_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_edge_hit_requests_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_edge_miss_requests_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_error_requests_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_hit_requests_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_miss_requests_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_pass_requests_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_vcl_on_compute_synth_requests_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_video_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_waf_blocked_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_waf_logged_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_waf_passed_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_websocket_bereq_body_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_websocket_bereq_header_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_websocket_beresp_body_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_websocket_beresp_header_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_websocket_conn_time_ms_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_websocket_req_body_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_websocket_req_header_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_websocket_resp_body_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, + `testspace_testsystem_websocket_resp_header_bytes_total{datacenter="aggregate",service_id="my-service-id",service_name="my-service-name"}`: 0, +} + // // origin fixtures // @@ -4731,6 +4998,125 @@ var expectedOriginsMetricsOutputMap = map[string]float64{ `testspace_origin_status_group_total{datacenter="TYO",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="waf",status_group="5xx"}`: 0, } +var expectedOriginsMetricsAggOutputMap = map[string]float64{ + `testspace_origin_latency_seconds_bucket{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="compute",le="+Inf"}`: 10, + `testspace_origin_latency_seconds_bucket{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="compute",le="0.001"}`: 10, + `testspace_origin_latency_seconds_bucket{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="compute",le="0.005"}`: 10, + `testspace_origin_latency_seconds_bucket{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="compute",le="0.01"}`: 10, + `testspace_origin_latency_seconds_bucket{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="compute",le="0.05"}`: 10, + `testspace_origin_latency_seconds_bucket{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="compute",le="0.1"}`: 10, + `testspace_origin_latency_seconds_bucket{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="compute",le="0.25"}`: 10, + `testspace_origin_latency_seconds_bucket{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="compute",le="0.5"}`: 10, + `testspace_origin_latency_seconds_bucket{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="compute",le="1"}`: 10, + `testspace_origin_latency_seconds_bucket{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="compute",le="10"}`: 10, + `testspace_origin_latency_seconds_bucket{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="compute",le="5"}`: 10, + `testspace_origin_latency_seconds_bucket{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="compute",le="60"}`: 10, + `testspace_origin_latency_seconds_bucket{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="delivery",le="+Inf"}`: 10, + `testspace_origin_latency_seconds_bucket{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="delivery",le="0.001"}`: 2, + `testspace_origin_latency_seconds_bucket{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="delivery",le="0.005"}`: 3, + `testspace_origin_latency_seconds_bucket{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="delivery",le="0.01"}`: 4, + `testspace_origin_latency_seconds_bucket{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="delivery",le="0.05"}`: 10, + `testspace_origin_latency_seconds_bucket{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="delivery",le="0.1"}`: 10, + `testspace_origin_latency_seconds_bucket{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="delivery",le="0.25"}`: 10, + `testspace_origin_latency_seconds_bucket{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="delivery",le="0.5"}`: 10, + `testspace_origin_latency_seconds_bucket{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="delivery",le="1"}`: 10, + `testspace_origin_latency_seconds_bucket{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="delivery",le="10"}`: 10, + `testspace_origin_latency_seconds_bucket{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="delivery",le="5"}`: 10, + `testspace_origin_latency_seconds_bucket{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="delivery",le="60"}`: 10, + `testspace_origin_latency_seconds_bucket{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="waf",le="+Inf"}`: 10, + `testspace_origin_latency_seconds_bucket{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="waf",le="0.001"}`: 0, + `testspace_origin_latency_seconds_bucket{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="waf",le="0.005"}`: 5, + `testspace_origin_latency_seconds_bucket{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="waf",le="0.01"}`: 10, + `testspace_origin_latency_seconds_bucket{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="waf",le="0.05"}`: 10, + `testspace_origin_latency_seconds_bucket{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="waf",le="0.1"}`: 10, + `testspace_origin_latency_seconds_bucket{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="waf",le="0.25"}`: 10, + `testspace_origin_latency_seconds_bucket{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="waf",le="0.5"}`: 10, + `testspace_origin_latency_seconds_bucket{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="waf",le="1"}`: 10, + `testspace_origin_latency_seconds_bucket{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="waf",le="10"}`: 10, + `testspace_origin_latency_seconds_bucket{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="waf",le="5"}`: 10, + `testspace_origin_latency_seconds_bucket{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="waf",le="60"}`: 10, + `testspace_origin_latency_seconds_count{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="compute"}`: 10, + `testspace_origin_latency_seconds_count{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="delivery"}`: 10, + `testspace_origin_latency_seconds_count{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="waf"}`: 10, + `testspace_origin_latency_seconds_sum{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="compute"}`: 0.008, + `testspace_origin_latency_seconds_sum{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="delivery"}`: 0.317, + `testspace_origin_latency_seconds_sum{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="waf"}`: 0.075, + `testspace_origin_resp_body_bytes_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="compute"}`: 1152, + `testspace_origin_resp_body_bytes_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="delivery"}`: 1024, + `testspace_origin_resp_body_bytes_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="waf"}`: 1088, + `testspace_origin_resp_header_bytes_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="delivery"}`: 64, + `testspace_origin_responses_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="compute"}`: 10, + `testspace_origin_responses_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="delivery"}`: 10, + `testspace_origin_responses_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="waf"}`: 10, + `testspace_origin_status_code_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="compute",status_code="200"}`: 6, + `testspace_origin_status_code_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="compute",status_code="204"}`: 0, + `testspace_origin_status_code_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="compute",status_code="301"}`: 0, + `testspace_origin_status_code_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="compute",status_code="302"}`: 0, + `testspace_origin_status_code_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="compute",status_code="304"}`: 0, + `testspace_origin_status_code_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="compute",status_code="400"}`: 0, + `testspace_origin_status_code_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="compute",status_code="401"}`: 0, + `testspace_origin_status_code_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="compute",status_code="403"}`: 4, + `testspace_origin_status_code_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="compute",status_code="404"}`: 0, + `testspace_origin_status_code_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="compute",status_code="416"}`: 0, + `testspace_origin_status_code_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="compute",status_code="500"}`: 0, + `testspace_origin_status_code_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="compute",status_code="501"}`: 0, + `testspace_origin_status_code_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="compute",status_code="502"}`: 0, + `testspace_origin_status_code_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="compute",status_code="503"}`: 0, + `testspace_origin_status_code_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="compute",status_code="504"}`: 0, + `testspace_origin_status_code_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="compute",status_code="505"}`: 0, + `testspace_origin_status_code_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="delivery",status_code="200"}`: 9, + `testspace_origin_status_code_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="delivery",status_code="204"}`: 0, + `testspace_origin_status_code_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="delivery",status_code="206"}`: 0, + `testspace_origin_status_code_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="delivery",status_code="301"}`: 1, + `testspace_origin_status_code_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="delivery",status_code="302"}`: 0, + `testspace_origin_status_code_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="delivery",status_code="304"}`: 0, + `testspace_origin_status_code_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="delivery",status_code="400"}`: 0, + `testspace_origin_status_code_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="delivery",status_code="401"}`: 0, + `testspace_origin_status_code_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="delivery",status_code="403"}`: 0, + `testspace_origin_status_code_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="delivery",status_code="404"}`: 0, + `testspace_origin_status_code_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="delivery",status_code="416"}`: 0, + `testspace_origin_status_code_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="delivery",status_code="429"}`: 0, + `testspace_origin_status_code_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="delivery",status_code="500"}`: 0, + `testspace_origin_status_code_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="delivery",status_code="501"}`: 0, + `testspace_origin_status_code_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="delivery",status_code="502"}`: 0, + `testspace_origin_status_code_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="delivery",status_code="503"}`: 0, + `testspace_origin_status_code_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="delivery",status_code="504"}`: 0, + `testspace_origin_status_code_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="delivery",status_code="505"}`: 0, + `testspace_origin_status_code_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="waf",status_code="200"}`: 10, + `testspace_origin_status_code_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="waf",status_code="204"}`: 0, + `testspace_origin_status_code_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="waf",status_code="206"}`: 0, + `testspace_origin_status_code_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="waf",status_code="301"}`: 0, + `testspace_origin_status_code_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="waf",status_code="302"}`: 0, + `testspace_origin_status_code_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="waf",status_code="304"}`: 0, + `testspace_origin_status_code_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="waf",status_code="400"}`: 0, + `testspace_origin_status_code_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="waf",status_code="401"}`: 0, + `testspace_origin_status_code_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="waf",status_code="403"}`: 0, + `testspace_origin_status_code_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="waf",status_code="404"}`: 0, + `testspace_origin_status_code_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="waf",status_code="416"}`: 0, + `testspace_origin_status_code_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="waf",status_code="429"}`: 0, + `testspace_origin_status_code_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="waf",status_code="500"}`: 0, + `testspace_origin_status_code_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="waf",status_code="501"}`: 0, + `testspace_origin_status_code_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="waf",status_code="502"}`: 0, + `testspace_origin_status_code_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="waf",status_code="503"}`: 0, + `testspace_origin_status_code_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="waf",status_code="504"}`: 0, + `testspace_origin_status_code_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="waf",status_code="505"}`: 0, + `testspace_origin_status_group_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="compute",status_group="1xx"}`: 0, + `testspace_origin_status_group_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="compute",status_group="2xx"}`: 6, + `testspace_origin_status_group_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="compute",status_group="3xx"}`: 0, + `testspace_origin_status_group_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="compute",status_group="4xx"}`: 4, + `testspace_origin_status_group_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="compute",status_group="5xx"}`: 0, + `testspace_origin_status_group_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="delivery",status_group="1xx"}`: 0, + `testspace_origin_status_group_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="delivery",status_group="2xx"}`: 9, + `testspace_origin_status_group_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="delivery",status_group="3xx"}`: 1, + `testspace_origin_status_group_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="delivery",status_group="4xx"}`: 0, + `testspace_origin_status_group_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="delivery",status_group="5xx"}`: 0, + `testspace_origin_status_group_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="waf",status_group="1xx"}`: 0, + `testspace_origin_status_group_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="waf",status_group="2xx"}`: 10, + `testspace_origin_status_group_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="waf",status_group="3xx"}`: 0, + `testspace_origin_status_group_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="waf",status_group="4xx"}`: 0, + `testspace_origin_status_group_total{datacenter="aggregate",origin="testorigin",service_id="my-service-id",service_name="my-service-name",source="waf",status_group="5xx"}`: 0, +} + // // domain fixtures // @@ -4855,3 +5241,67 @@ var expectedDomainsMetricsOutputMap = map[string]float64{ `testspace_domain_status_group_total{datacenter="TYO",domain="testhost",service_id="my-service-id",service_name="my-service-name",status_group="4xx"}`: 0, `testspace_domain_status_group_total{datacenter="TYO",domain="testhost",service_id="my-service-id",service_name="my-service-name",status_group="5xx"}`: 0, } + +var expectedDomainsMetricsAggOutputMap = map[string]float64{ + `testspace_domain_bereq_body_bytes_total{datacenter="aggregate",domain="testhost",service_id="my-service-id",service_name="my-service-name"}`: 16, + `testspace_domain_bereq_header_bytes_total{datacenter="aggregate",domain="testhost",service_id="my-service-id",service_name="my-service-name"}`: 16, + `testspace_domain_edge_hit_ratio{datacenter="aggregate",domain="testhost",service_id="my-service-id",service_name="my-service-name"}`: 0.5, + `testspace_domain_edge_hit_requests_total{datacenter="aggregate",domain="testhost",service_id="my-service-id",service_name="my-service-name"}`: 5, + `testspace_domain_edge_miss_requests_total{datacenter="aggregate",domain="testhost",service_id="my-service-id",service_name="my-service-name"}`: 5, + `testspace_domain_edge_requests_total{datacenter="aggregate",domain="testhost",service_id="my-service-id",service_name="my-service-name"}`: 10, + `testspace_domain_edge_resp_body_bytes_total{datacenter="aggregate",domain="testhost",service_id="my-service-id",service_name="my-service-name"}`: 1024, + `testspace_domain_edge_resp_header_bytes_total{datacenter="aggregate",domain="testhost",service_id="my-service-id",service_name="my-service-name"}`: 48, + `testspace_domain_origin_fetch_resp_body_bytes{datacenter="aggregate",domain="testhost",service_id="my-service-id",service_name="my-service-name"}`: 1024, + `testspace_domain_origin_fetch_resp_header_bytes{datacenter="aggregate",domain="testhost",service_id="my-service-id",service_name="my-service-name"}`: 48, + `testspace_domain_origin_fetches{datacenter="aggregate",domain="testhost",service_id="my-service-id",service_name="my-service-name"}`: 5, + `testspace_domain_origin_offload{datacenter="aggregate",domain="testhost",service_id="my-service-id",service_name="my-service-name"}`: 5, + `testspace_domain_origin_status_code_total{datacenter="aggregate",domain="testhost",service_id="my-service-id",service_name="my-service-name",status_code="200"}`: 5, + `testspace_domain_origin_status_code_total{datacenter="aggregate",domain="testhost",service_id="my-service-id",service_name="my-service-name",status_code="204"}`: 0, + `testspace_domain_origin_status_code_total{datacenter="aggregate",domain="testhost",service_id="my-service-id",service_name="my-service-name",status_code="206"}`: 0, + `testspace_domain_origin_status_code_total{datacenter="aggregate",domain="testhost",service_id="my-service-id",service_name="my-service-name",status_code="301"}`: 0, + `testspace_domain_origin_status_code_total{datacenter="aggregate",domain="testhost",service_id="my-service-id",service_name="my-service-name",status_code="302"}`: 0, + `testspace_domain_origin_status_code_total{datacenter="aggregate",domain="testhost",service_id="my-service-id",service_name="my-service-name",status_code="304"}`: 0, + `testspace_domain_origin_status_code_total{datacenter="aggregate",domain="testhost",service_id="my-service-id",service_name="my-service-name",status_code="400"}`: 0, + `testspace_domain_origin_status_code_total{datacenter="aggregate",domain="testhost",service_id="my-service-id",service_name="my-service-name",status_code="401"}`: 0, + `testspace_domain_origin_status_code_total{datacenter="aggregate",domain="testhost",service_id="my-service-id",service_name="my-service-name",status_code="403"}`: 0, + `testspace_domain_origin_status_code_total{datacenter="aggregate",domain="testhost",service_id="my-service-id",service_name="my-service-name",status_code="404"}`: 0, + `testspace_domain_origin_status_code_total{datacenter="aggregate",domain="testhost",service_id="my-service-id",service_name="my-service-name",status_code="416"}`: 0, + `testspace_domain_origin_status_code_total{datacenter="aggregate",domain="testhost",service_id="my-service-id",service_name="my-service-name",status_code="429"}`: 0, + `testspace_domain_origin_status_code_total{datacenter="aggregate",domain="testhost",service_id="my-service-id",service_name="my-service-name",status_code="500"}`: 0, + `testspace_domain_origin_status_code_total{datacenter="aggregate",domain="testhost",service_id="my-service-id",service_name="my-service-name",status_code="501"}`: 0, + `testspace_domain_origin_status_code_total{datacenter="aggregate",domain="testhost",service_id="my-service-id",service_name="my-service-name",status_code="502"}`: 0, + `testspace_domain_origin_status_code_total{datacenter="aggregate",domain="testhost",service_id="my-service-id",service_name="my-service-name",status_code="503"}`: 0, + `testspace_domain_origin_status_code_total{datacenter="aggregate",domain="testhost",service_id="my-service-id",service_name="my-service-name",status_code="504"}`: 0, + `testspace_domain_origin_status_code_total{datacenter="aggregate",domain="testhost",service_id="my-service-id",service_name="my-service-name",status_code="505"}`: 0, + `testspace_domain_origin_status_group_total{datacenter="aggregate",domain="testhost",service_id="my-service-id",service_name="my-service-name",status_group="1xx"}`: 0, + `testspace_domain_origin_status_group_total{datacenter="aggregate",domain="testhost",service_id="my-service-id",service_name="my-service-name",status_group="2xx"}`: 5, + `testspace_domain_origin_status_group_total{datacenter="aggregate",domain="testhost",service_id="my-service-id",service_name="my-service-name",status_group="3xx"}`: 0, + `testspace_domain_origin_status_group_total{datacenter="aggregate",domain="testhost",service_id="my-service-id",service_name="my-service-name",status_group="4xx"}`: 0, + `testspace_domain_origin_status_group_total{datacenter="aggregate",domain="testhost",service_id="my-service-id",service_name="my-service-name",status_group="5xx"}`: 0, + `testspace_domain_requests_total{datacenter="aggregate",domain="testhost",service_id="my-service-id",service_name="my-service-name"}`: 10, + `testspace_domain_resp_body_bytes_total{datacenter="aggregate",domain="testhost",service_id="my-service-id",service_name="my-service-name"}`: 1024, + `testspace_domain_resp_header_bytes_total{datacenter="aggregate",domain="testhost",service_id="my-service-id",service_name="my-service-name"}`: 48, + `testspace_domain_status_code_total{datacenter="aggregate",domain="testhost",service_id="my-service-id",service_name="my-service-name",status_code="200"}`: 10, + `testspace_domain_status_code_total{datacenter="aggregate",domain="testhost",service_id="my-service-id",service_name="my-service-name",status_code="204"}`: 0, + `testspace_domain_status_code_total{datacenter="aggregate",domain="testhost",service_id="my-service-id",service_name="my-service-name",status_code="206"}`: 0, + `testspace_domain_status_code_total{datacenter="aggregate",domain="testhost",service_id="my-service-id",service_name="my-service-name",status_code="301"}`: 0, + `testspace_domain_status_code_total{datacenter="aggregate",domain="testhost",service_id="my-service-id",service_name="my-service-name",status_code="302"}`: 0, + `testspace_domain_status_code_total{datacenter="aggregate",domain="testhost",service_id="my-service-id",service_name="my-service-name",status_code="304"}`: 0, + `testspace_domain_status_code_total{datacenter="aggregate",domain="testhost",service_id="my-service-id",service_name="my-service-name",status_code="400"}`: 0, + `testspace_domain_status_code_total{datacenter="aggregate",domain="testhost",service_id="my-service-id",service_name="my-service-name",status_code="401"}`: 0, + `testspace_domain_status_code_total{datacenter="aggregate",domain="testhost",service_id="my-service-id",service_name="my-service-name",status_code="403"}`: 0, + `testspace_domain_status_code_total{datacenter="aggregate",domain="testhost",service_id="my-service-id",service_name="my-service-name",status_code="404"}`: 0, + `testspace_domain_status_code_total{datacenter="aggregate",domain="testhost",service_id="my-service-id",service_name="my-service-name",status_code="416"}`: 0, + `testspace_domain_status_code_total{datacenter="aggregate",domain="testhost",service_id="my-service-id",service_name="my-service-name",status_code="429"}`: 0, + `testspace_domain_status_code_total{datacenter="aggregate",domain="testhost",service_id="my-service-id",service_name="my-service-name",status_code="500"}`: 0, + `testspace_domain_status_code_total{datacenter="aggregate",domain="testhost",service_id="my-service-id",service_name="my-service-name",status_code="501"}`: 0, + `testspace_domain_status_code_total{datacenter="aggregate",domain="testhost",service_id="my-service-id",service_name="my-service-name",status_code="502"}`: 0, + `testspace_domain_status_code_total{datacenter="aggregate",domain="testhost",service_id="my-service-id",service_name="my-service-name",status_code="503"}`: 0, + `testspace_domain_status_code_total{datacenter="aggregate",domain="testhost",service_id="my-service-id",service_name="my-service-name",status_code="504"}`: 0, + `testspace_domain_status_code_total{datacenter="aggregate",domain="testhost",service_id="my-service-id",service_name="my-service-name",status_code="505"}`: 0, + `testspace_domain_status_group_total{datacenter="aggregate",domain="testhost",service_id="my-service-id",service_name="my-service-name",status_group="1xx"}`: 0, + `testspace_domain_status_group_total{datacenter="aggregate",domain="testhost",service_id="my-service-id",service_name="my-service-name",status_group="2xx"}`: 10, + `testspace_domain_status_group_total{datacenter="aggregate",domain="testhost",service_id="my-service-id",service_name="my-service-name",status_group="3xx"}`: 0, + `testspace_domain_status_group_total{datacenter="aggregate",domain="testhost",service_id="my-service-id",service_name="my-service-name",status_group="4xx"}`: 0, + `testspace_domain_status_group_total{datacenter="aggregate",domain="testhost",service_id="my-service-id",service_name="my-service-name",status_group="5xx"}`: 0, +} diff --git a/pkg/rt/subscriber.go b/pkg/rt/subscriber.go index fa9fbac..c7a86fd 100644 --- a/pkg/rt/subscriber.go +++ b/pkg/rt/subscriber.go @@ -35,16 +35,17 @@ type MetadataProvider interface { // Subscriber polls rt.fastly.com endpoints for a single service ID. It emits // the received stats data to Prometheus metrics. type Subscriber struct { - client HTTPClient - token string - serviceID string - provider MetadataProvider - metrics *prom.Metrics - postprocess func() - logger log.Logger - rtDelayCount int - oiDelayCount int - diDelayCount int + client HTTPClient + token string + serviceID string + provider MetadataProvider + metrics *prom.Metrics + postprocess func() + logger log.Logger + rtDelayCount int + oiDelayCount int + diDelayCount int + aggregateOnly bool } // SubscriberOption provides some additional behavior to a subscriber. @@ -71,6 +72,13 @@ func WithPostprocess(f func()) SubscriberOption { return func(s *Subscriber) { s.postprocess = f } } +// WithAggregateOnly sets whether aggregate metrics are output instead of +// per datacenter metrics. By default, per datacenter are provided. Enabling +// this feature will significantly reduce the payload size of the metrics endpoint. +func WithAggregateOnly(aggregateOnly bool) SubscriberOption { + return func(s *Subscriber) { s.aggregateOnly = aggregateOnly } +} + // NewSubscriber returns a ready-to-use subscriber. Callers must be sure to // invoke the Run method of the returned subscriber in order to actually update // any metrics. @@ -223,7 +231,7 @@ func (s *Subscriber) queryRealtime(ctx context.Context, ts uint64) (currentName s.rtDelayCount = 0 result = apiResultSuccess } - realtime.Process(&response, s.serviceID, name, version, s.metrics.Realtime) + realtime.Process(&response, s.serviceID, name, version, s.metrics.Realtime, s.aggregateOnly) s.postprocess() case http.StatusUnauthorized, http.StatusForbidden: @@ -287,7 +295,7 @@ func (s *Subscriber) queryOrigins(ctx context.Context, ts uint64) (currentName s s.oiDelayCount = 0 result = apiResultSuccess } - origin.Process(&response, s.serviceID, name, version, s.metrics.Origin) + origin.Process(&response, s.serviceID, name, version, s.metrics.Origin, s.aggregateOnly) s.postprocess() case http.StatusUnauthorized, http.StatusForbidden: @@ -351,7 +359,7 @@ func (s *Subscriber) queryDomains(ctx context.Context, ts uint64) (currentName s s.diDelayCount = 0 result = apiResultSuccess } - domain.Process(&response, s.serviceID, name, version, s.metrics.Domain) + domain.Process(&response, s.serviceID, name, version, s.metrics.Domain, s.aggregateOnly) s.postprocess() case http.StatusUnauthorized, http.StatusForbidden: diff --git a/pkg/rt/subscriber_test.go b/pkg/rt/subscriber_test.go index c6c0030..7f0cf77 100644 --- a/pkg/rt/subscriber_test.go +++ b/pkg/rt/subscriber_test.go @@ -62,6 +62,54 @@ func TestRTSubscriberFixture(t *testing.T) { } } +func TestRTSubscriberAggOnlyFixture(t *testing.T) { + var ( + namespace = "testspace" + subsystem = "testsystem" + registry = prometheus.NewRegistry() + nameFilter = filter.Filter{} + metrics = prom.NewMetrics(namespace, subsystem, nameFilter, registry) + ) + + // Set up a subscriber. + var ( + client = newMockRealtimeClient(rtResponseFixture, `{}`) + serviceID = "my-service-id" + serviceName = "my-service-name" + serviceVersion = 123 + cache = &mockCache{} + processed = make(chan struct{}) + postprocess = func() { close(processed) } + options = []rt.SubscriberOption{rt.WithMetadataProvider(cache), rt.WithPostprocess(postprocess), rt.WithAggregateOnly(true)} + subscriber = rt.NewSubscriber(client, "irrelevant token", serviceID, metrics, options...) + ) + + // Prep the mock cache. + cache.update([]api.Service{{ID: serviceID, Name: serviceName, Version: serviceVersion}}) + + // Tell the subscriber to fetch real-time stats. + ctx, cancel := context.WithCancel(context.Background()) + errc := make(chan error, 1) + go func() { errc <- subscriber.RunRealtime(ctx) }() + + // Block until the subscriber does finishes one fetch + <-processed + + // Assert the Prometheus metrics. + output := prometheusOutput(t, registry, namespace+"_"+subsystem+"_") + assertMetricOutput(t, expectedRTMetricsAggOutputMap, output) + + // Kill the subscriber's goroutine, and wait for it to finish. + cancel() + err := <-errc + switch { + case err == nil: + case errors.Is(err, context.Canceled): + case err != nil: + t.Fatal(err) + } +} + func TestOriginSubscriberFixture(t *testing.T) { var ( namespace = "testspace" @@ -110,6 +158,54 @@ func TestOriginSubscriberFixture(t *testing.T) { } } +func TestOriginSubscriberAggOnlyFixture(t *testing.T) { + var ( + namespace = "testspace" + subsystem = "testsytem" + registry = prometheus.NewRegistry() + nameFilter = filter.Filter{} + metrics = prom.NewMetrics(namespace, subsystem, nameFilter, registry) + ) + + // Set up a subscriber. + var ( + client = newMockRealtimeClient(originsResponseFixture, `{}`) + serviceID = "my-service-id" + serviceName = "my-service-name" + serviceVersion = 123 + cache = &mockCache{} + processed = make(chan struct{}) + postprocess = func() { close(processed) } + options = []rt.SubscriberOption{rt.WithMetadataProvider(cache), rt.WithPostprocess(postprocess), rt.WithAggregateOnly(true)} + subscriber = rt.NewSubscriber(client, "irrelevant token", serviceID, metrics, options...) + ) + + // Prep the mock cache. + cache.update([]api.Service{{ID: serviceID, Name: serviceName, Version: serviceVersion}}) + + // Tell the subscriber to fetch real-time stats. + ctx, cancel := context.WithCancel(context.Background()) + errc := make(chan error, 1) + go func() { errc <- subscriber.RunOrigins(ctx) }() + + // Block until the subscriber does finishes one fetch + <-processed + + // Assert the Prometheus metrics. + output := prometheusOutput(t, registry, namespace+"_origin_") + assertMetricOutput(t, expectedOriginsMetricsAggOutputMap, output) + + // Kill the subscriber's goroutine, and wait for it to finish. + cancel() + err := <-errc + switch { + case err == nil: + case errors.Is(err, context.Canceled): + case err != nil: + t.Fatal(err) + } +} + func TestDomainSubscriberFixture(t *testing.T) { var ( namespace = "testspace" @@ -158,6 +254,54 @@ func TestDomainSubscriberFixture(t *testing.T) { } } +func TestDomainSubscriberAggOnlyFixture(t *testing.T) { + var ( + namespace = "testspace" + subsystem = "testsytem" + registry = prometheus.NewRegistry() + nameFilter = filter.Filter{} + metrics = prom.NewMetrics(namespace, subsystem, nameFilter, registry) + ) + + // Set up a subscriber. + var ( + client = newMockRealtimeClient(domainsResponseFixture, `{}`) + serviceID = "my-service-id" + serviceName = "my-service-name" + serviceVersion = 123 + cache = &mockCache{} + processed = make(chan struct{}) + postprocess = func() { close(processed) } + options = []rt.SubscriberOption{rt.WithMetadataProvider(cache), rt.WithPostprocess(postprocess), rt.WithAggregateOnly(true)} + subscriber = rt.NewSubscriber(client, "irrelevant token", serviceID, metrics, options...) + ) + + // Prep the mock cache. + cache.update([]api.Service{{ID: serviceID, Name: serviceName, Version: serviceVersion}}) + + // Tell the subscriber to fetch real-time stats. + ctx, cancel := context.WithCancel(context.Background()) + errc := make(chan error, 1) + go func() { errc <- subscriber.RunDomains(ctx) }() + + // Block until the subscriber does finishes one fetch + <-processed + + // Assert the Prometheus metrics. + output := prometheusOutput(t, registry, namespace+"_domain_") + assertMetricOutput(t, expectedDomainsMetricsAggOutputMap, output) + + // Kill the subscriber's goroutine, and wait for it to finish. + cancel() + err := <-errc + switch { + case err == nil: + case errors.Is(err, context.Canceled): + case err != nil: + t.Fatal(err) + } +} + func TestSubscriberNoData(t *testing.T) { var ( client = newMockRealtimeClient(`{"Error": "No data available, please retry"}`, `{}`)