From 5a61853ccf061026b9e8167c7690212cfe22c9a4 Mon Sep 17 00:00:00 2001 From: ka3de Date: Wed, 29 Nov 2023 11:06:22 +0100 Subject: [PATCH] Add gRPC test cases to scraper's TestValidateMetrics This also adds the test data corresponding to the gRPC probe metrics and updates the active series count data. --- internal/scraper/scraper_test.go | 121 ++++++++++++++++++- internal/scraper/testdata/grpc.txt | 103 ++++++++++++++++ internal/scraper/testdata/grpc_basic.txt | 57 +++++++++ internal/scraper/testdata/grpc_ssl.txt | 109 +++++++++++++++++ internal/scraper/testdata/grpc_ssl_basic.txt | 63 ++++++++++ pkg/accounting/data.go | 4 + 6 files changed, 455 insertions(+), 2 deletions(-) create mode 100644 internal/scraper/testdata/grpc.txt create mode 100644 internal/scraper/testdata/grpc_basic.txt create mode 100644 internal/scraper/testdata/grpc_ssl.txt create mode 100644 internal/scraper/testdata/grpc_ssl_basic.txt diff --git a/internal/scraper/scraper_test.go b/internal/scraper/scraper_test.go index bac650e14..aa902ea8d 100644 --- a/internal/scraper/scraper_test.go +++ b/internal/scraper/scraper_test.go @@ -26,6 +26,7 @@ import ( "github.com/grafana/synthetic-monitoring-agent/internal/pkg/logproto" "github.com/grafana/synthetic-monitoring-agent/internal/prober" dnsProber "github.com/grafana/synthetic-monitoring-agent/internal/prober/dns" + grpcProber "github.com/grafana/synthetic-monitoring-agent/internal/prober/grpc" httpProber "github.com/grafana/synthetic-monitoring-agent/internal/prober/http" "github.com/grafana/synthetic-monitoring-agent/internal/prober/icmp" "github.com/grafana/synthetic-monitoring-agent/internal/prober/k6" @@ -46,6 +47,9 @@ import ( "github.com/prometheus/prometheus/promql/parser" "github.com/rs/zerolog" "github.com/stretchr/testify/require" + "google.golang.org/grpc" + "google.golang.org/grpc/credentials" + grpchealth "google.golang.org/grpc/health/grpc_health_v1" "kernel.org/pub/linux/libs/security/libcap/cap" ) @@ -344,6 +348,58 @@ func TestValidateMetrics(t *testing.T) { return prober, check, httpSrv.Close }, }, + + "grpc": { + setup: func(ctx context.Context, t *testing.T) (prober.Prober, sm.Check, func()) { + srv, clean := setupGRPCServer(t) + check := sm.Check{ + Target: srv, + Timeout: 2000, + Settings: sm.CheckSettings{ + Grpc: &sm.GrpcSettings{ + IpVersion: sm.IpVersion_V4, + }, + }, + } + prober, err := grpcProber.NewProber( + ctx, + check, + zerolog.New(io.Discard)) + if err != nil { + clean() + t.Fatalf("cannot create gRPC prober: %s", err) + } + return prober, check, clean + }, + }, + + "grpc_ssl": { + setup: func(ctx context.Context, t *testing.T) (prober.Prober, sm.Check, func()) { + srv, clean := setupGRPCServerWithSSL(t) + check := sm.Check{ + Target: srv, + Timeout: 2000, + Settings: sm.CheckSettings{ + Grpc: &sm.GrpcSettings{ + IpVersion: sm.IpVersion_V4, + Tls: true, + TlsConfig: &sm.TLSConfig{ + InsecureSkipVerify: true, + }, + }, + }, + } + prober, err := grpcProber.NewProber( + ctx, + check, + zerolog.New(io.Discard)) + if err != nil { + clean() + t.Fatalf("cannot create gRPC prober: %s", err) + } + return prober, check, clean + }, + }, } for name, testcase := range testcases { @@ -630,6 +686,68 @@ func setupTCPServerWithSSL(t *testing.T) (string, func()) { } } +type gRPCSrv struct { + grpchealth.HealthServer +} + +func (s *gRPCSrv) Check( + context.Context, *grpchealth.HealthCheckRequest, +) (*grpchealth.HealthCheckResponse, error) { + return &grpchealth.HealthCheckResponse{ + Status: grpchealth.HealthCheckResponse_SERVING, + }, nil +} + +func setupGRPCServer(t *testing.T) (string, func()) { + lis, err := net.Listen("tcp4", ":0") + if err != nil { + t.Fatalf("Error listening on socket: %v", err) + } + + srv := grpc.NewServer() + grpchealth.RegisterHealthServer(srv, &gRPCSrv{}) + + go func() { + _ = srv.Serve(lis) + }() + + return lis.Addr().String(), func() { + srv.Stop() + lis.Close() + } +} + +func setupGRPCServerWithSSL(t *testing.T) (string, func()) { + lis, err := net.Listen("tcp4", ":0") + if err != nil { + t.Fatalf("Error listening on socket: %v", err) + } + + cert, err := tls.X509KeyPair(localhostCert, localhostKey) + if err != nil { + t.Fatalf("Error creating X509 key pair: %v", err) + } + + tlsCfg := tls.Config{ + Certificates: []tls.Certificate{cert}, + NextProtos: []string{"foo"}, + } + + srv := grpc.NewServer( + grpc.Creds(credentials.NewTLS(&tlsCfg)), + ) + grpchealth.RegisterHealthServer(srv, &gRPCSrv{}) + + go func() { + _ = srv.Serve(lis) + }() + + return lis.Addr().String(), func() { + srv.Stop() + lis.Close() + } +} + func TestMakeTimeseries(t *testing.T) { testTime := time.Now() testValue := 42.0 @@ -1403,8 +1521,7 @@ func (f testProbeFactory) New(ctx context.Context, logger zerolog.Logger, check return f.builder(), check.Target, nil } -type testPublisher struct { -} +type testPublisher struct{} func (testPublisher) Publish(pusher.Payload) { } diff --git a/internal/scraper/testdata/grpc.txt b/internal/scraper/testdata/grpc.txt new file mode 100644 index 000000000..87eb7090c --- /dev/null +++ b/internal/scraper/testdata/grpc.txt @@ -0,0 +1,103 @@ +# HELP probe_dns_lookup_time_seconds Returns the time taken for probe dns lookup in seconds +# TYPE probe_dns_lookup_time_seconds gauge +probe_dns_lookup_time_seconds 2.431e-06 +# HELP probe_duration_seconds Returns how long the probe took to complete in seconds +# TYPE probe_duration_seconds gauge +probe_duration_seconds 0.00072303 +# HELP probe_grpc_duration_seconds Duration of gRPC request by phase +# TYPE probe_grpc_duration_seconds gauge +probe_grpc_duration_seconds{phase="check"} 0.000652168 +probe_grpc_duration_seconds{phase="resolve"} 2.431e-06 +# HELP probe_grpc_healthcheck_response Response HealthCheck response +# TYPE probe_grpc_healthcheck_response gauge +probe_grpc_healthcheck_response{serving_status="NOT_SERVING"} 0 +probe_grpc_healthcheck_response{serving_status="SERVICE_UNKNOWN"} 0 +probe_grpc_healthcheck_response{serving_status="SERVING"} 1 +probe_grpc_healthcheck_response{serving_status="UNKNOWN"} 0 +# HELP probe_grpc_ssl Indicates if SSL was used for the connection +# TYPE probe_grpc_ssl gauge +probe_grpc_ssl 0 +# HELP probe_grpc_status_code Response gRPC status code +# TYPE probe_grpc_status_code gauge +probe_grpc_status_code 0 +# HELP probe_ip_addr_hash Specifies the hash of IP address. It's useful to detect if the IP address changes. +# TYPE probe_ip_addr_hash gauge +probe_ip_addr_hash 1.268118805e+09 +# HELP probe_ip_protocol Specifies whether probe ip protocol is IP4 or IP6 +# TYPE probe_ip_protocol gauge +probe_ip_protocol 4 +# HELP probe_ssl_earliest_cert_expiry Returns last SSL chain expiry in unixtime +# TYPE probe_ssl_earliest_cert_expiry gauge +probe_ssl_earliest_cert_expiry 0 +# HELP probe_success Displays whether or not the probe was a success +# TYPE probe_success gauge +probe_success 1 +# HELP sm_check_info Provides information about a single check configuration +# TYPE sm_check_info gauge +sm_check_info 1 +# HELP probe_all_duration_seconds Returns how long the probe took to complete in seconds (histogram) +# TYPE probe_all_duration_seconds histogram +probe_all_duration_seconds_bucket{le="0.005"} 1 +probe_all_duration_seconds_bucket{le="0.01"} 1 +probe_all_duration_seconds_bucket{le="0.025"} 1 +probe_all_duration_seconds_bucket{le="0.05"} 1 +probe_all_duration_seconds_bucket{le="0.1"} 1 +probe_all_duration_seconds_bucket{le="0.25"} 1 +probe_all_duration_seconds_bucket{le="0.5"} 1 +probe_all_duration_seconds_bucket{le="1"} 1 +probe_all_duration_seconds_bucket{le="2.5"} 1 +probe_all_duration_seconds_bucket{le="5"} 1 +probe_all_duration_seconds_bucket{le="10"} 1 +probe_all_duration_seconds_bucket{le="+Inf"} 1 +probe_all_duration_seconds_sum 0.00072303 +probe_all_duration_seconds_count 1 +# HELP probe_all_success Displays whether or not the probe was a success (summary) +# TYPE probe_all_success summary +probe_all_success_sum 1 +probe_all_success_count 1 +# HELP probe_dns_lookup_all_time_seconds Returns the time taken for probe dns lookup in seconds (histogram) +# TYPE probe_dns_lookup_all_time_seconds histogram +probe_dns_lookup_all_time_seconds_bucket{le="0.005"} 1 +probe_dns_lookup_all_time_seconds_bucket{le="0.01"} 1 +probe_dns_lookup_all_time_seconds_bucket{le="0.025"} 1 +probe_dns_lookup_all_time_seconds_bucket{le="0.05"} 1 +probe_dns_lookup_all_time_seconds_bucket{le="0.1"} 1 +probe_dns_lookup_all_time_seconds_bucket{le="0.25"} 1 +probe_dns_lookup_all_time_seconds_bucket{le="0.5"} 1 +probe_dns_lookup_all_time_seconds_bucket{le="1"} 1 +probe_dns_lookup_all_time_seconds_bucket{le="2.5"} 1 +probe_dns_lookup_all_time_seconds_bucket{le="5"} 1 +probe_dns_lookup_all_time_seconds_bucket{le="10"} 1 +probe_dns_lookup_all_time_seconds_bucket{le="+Inf"} 1 +probe_dns_lookup_all_time_seconds_sum 2.431e-06 +probe_dns_lookup_all_time_seconds_count 1 +# HELP probe_grpc_all_duration_seconds Duration of gRPC request by phase (histogram) +# TYPE probe_grpc_all_duration_seconds histogram +probe_grpc_all_duration_seconds_bucket{phase="check",le="0.005"} 1 +probe_grpc_all_duration_seconds_bucket{phase="check",le="0.01"} 1 +probe_grpc_all_duration_seconds_bucket{phase="check",le="0.025"} 1 +probe_grpc_all_duration_seconds_bucket{phase="check",le="0.05"} 1 +probe_grpc_all_duration_seconds_bucket{phase="check",le="0.1"} 1 +probe_grpc_all_duration_seconds_bucket{phase="check",le="0.25"} 1 +probe_grpc_all_duration_seconds_bucket{phase="check",le="0.5"} 1 +probe_grpc_all_duration_seconds_bucket{phase="check",le="1"} 1 +probe_grpc_all_duration_seconds_bucket{phase="check",le="2.5"} 1 +probe_grpc_all_duration_seconds_bucket{phase="check",le="5"} 1 +probe_grpc_all_duration_seconds_bucket{phase="check",le="10"} 1 +probe_grpc_all_duration_seconds_bucket{phase="check",le="+Inf"} 1 +probe_grpc_all_duration_seconds_sum{phase="check"} 0.000652168 +probe_grpc_all_duration_seconds_count{phase="check"} 1 +probe_grpc_all_duration_seconds_bucket{phase="resolve",le="0.005"} 1 +probe_grpc_all_duration_seconds_bucket{phase="resolve",le="0.01"} 1 +probe_grpc_all_duration_seconds_bucket{phase="resolve",le="0.025"} 1 +probe_grpc_all_duration_seconds_bucket{phase="resolve",le="0.05"} 1 +probe_grpc_all_duration_seconds_bucket{phase="resolve",le="0.1"} 1 +probe_grpc_all_duration_seconds_bucket{phase="resolve",le="0.25"} 1 +probe_grpc_all_duration_seconds_bucket{phase="resolve",le="0.5"} 1 +probe_grpc_all_duration_seconds_bucket{phase="resolve",le="1"} 1 +probe_grpc_all_duration_seconds_bucket{phase="resolve",le="2.5"} 1 +probe_grpc_all_duration_seconds_bucket{phase="resolve",le="5"} 1 +probe_grpc_all_duration_seconds_bucket{phase="resolve",le="10"} 1 +probe_grpc_all_duration_seconds_bucket{phase="resolve",le="+Inf"} 1 +probe_grpc_all_duration_seconds_sum{phase="resolve"} 2.431e-06 +probe_grpc_all_duration_seconds_count{phase="resolve"} 1 diff --git a/internal/scraper/testdata/grpc_basic.txt b/internal/scraper/testdata/grpc_basic.txt new file mode 100644 index 000000000..f50ac0fc9 --- /dev/null +++ b/internal/scraper/testdata/grpc_basic.txt @@ -0,0 +1,57 @@ +# HELP probe_dns_lookup_time_seconds Returns the time taken for probe dns lookup in seconds +# TYPE probe_dns_lookup_time_seconds gauge +probe_dns_lookup_time_seconds 2.765e-06 +# HELP probe_duration_seconds Returns how long the probe took to complete in seconds +# TYPE probe_duration_seconds gauge +probe_duration_seconds 0.00047477 +# HELP probe_grpc_duration_seconds Duration of gRPC request by phase +# TYPE probe_grpc_duration_seconds gauge +probe_grpc_duration_seconds{phase="check"} 0.000359518 +probe_grpc_duration_seconds{phase="resolve"} 2.765e-06 +# HELP probe_grpc_healthcheck_response Response HealthCheck response +# TYPE probe_grpc_healthcheck_response gauge +probe_grpc_healthcheck_response{serving_status="NOT_SERVING"} 0 +probe_grpc_healthcheck_response{serving_status="SERVICE_UNKNOWN"} 0 +probe_grpc_healthcheck_response{serving_status="SERVING"} 1 +probe_grpc_healthcheck_response{serving_status="UNKNOWN"} 0 +# HELP probe_grpc_ssl Indicates if SSL was used for the connection +# TYPE probe_grpc_ssl gauge +probe_grpc_ssl 0 +# HELP probe_grpc_status_code Response gRPC status code +# TYPE probe_grpc_status_code gauge +probe_grpc_status_code 0 +# HELP probe_ip_addr_hash Specifies the hash of IP address. It's useful to detect if the IP address changes. +# TYPE probe_ip_addr_hash gauge +probe_ip_addr_hash 1.268118805e+09 +# HELP probe_ip_protocol Specifies whether probe ip protocol is IP4 or IP6 +# TYPE probe_ip_protocol gauge +probe_ip_protocol 4 +# HELP probe_ssl_earliest_cert_expiry Returns last SSL chain expiry in unixtime +# TYPE probe_ssl_earliest_cert_expiry gauge +probe_ssl_earliest_cert_expiry 0 +# HELP probe_success Displays whether or not the probe was a success +# TYPE probe_success gauge +probe_success 1 +# HELP sm_check_info Provides information about a single check configuration +# TYPE sm_check_info gauge +sm_check_info 1 +# HELP probe_all_duration_seconds Returns how long the probe took to complete in seconds (histogram) +# TYPE probe_all_duration_seconds histogram +probe_all_duration_seconds_bucket{le="0.005"} 1 +probe_all_duration_seconds_bucket{le="0.01"} 1 +probe_all_duration_seconds_bucket{le="0.025"} 1 +probe_all_duration_seconds_bucket{le="0.05"} 1 +probe_all_duration_seconds_bucket{le="0.1"} 1 +probe_all_duration_seconds_bucket{le="0.25"} 1 +probe_all_duration_seconds_bucket{le="0.5"} 1 +probe_all_duration_seconds_bucket{le="1"} 1 +probe_all_duration_seconds_bucket{le="2.5"} 1 +probe_all_duration_seconds_bucket{le="5"} 1 +probe_all_duration_seconds_bucket{le="10"} 1 +probe_all_duration_seconds_bucket{le="+Inf"} 1 +probe_all_duration_seconds_sum 0.00047477 +probe_all_duration_seconds_count 1 +# HELP probe_all_success Displays whether or not the probe was a success (summary) +# TYPE probe_all_success summary +probe_all_success_sum 1 +probe_all_success_count 1 diff --git a/internal/scraper/testdata/grpc_ssl.txt b/internal/scraper/testdata/grpc_ssl.txt new file mode 100644 index 000000000..cd307103e --- /dev/null +++ b/internal/scraper/testdata/grpc_ssl.txt @@ -0,0 +1,109 @@ +# HELP probe_dns_lookup_time_seconds Returns the time taken for probe dns lookup in seconds +# TYPE probe_dns_lookup_time_seconds gauge +probe_dns_lookup_time_seconds 3.961e-06 +# HELP probe_duration_seconds Returns how long the probe took to complete in seconds +# TYPE probe_duration_seconds gauge +probe_duration_seconds 0.001690042 +# HELP probe_grpc_duration_seconds Duration of gRPC request by phase +# TYPE probe_grpc_duration_seconds gauge +probe_grpc_duration_seconds{phase="check"} 0.001552342 +probe_grpc_duration_seconds{phase="resolve"} 3.961e-06 +# HELP probe_grpc_healthcheck_response Response HealthCheck response +# TYPE probe_grpc_healthcheck_response gauge +probe_grpc_healthcheck_response{serving_status="NOT_SERVING"} 0 +probe_grpc_healthcheck_response{serving_status="SERVICE_UNKNOWN"} 0 +probe_grpc_healthcheck_response{serving_status="SERVING"} 1 +probe_grpc_healthcheck_response{serving_status="UNKNOWN"} 0 +# HELP probe_grpc_ssl Indicates if SSL was used for the connection +# TYPE probe_grpc_ssl gauge +probe_grpc_ssl 1 +# HELP probe_grpc_status_code Response gRPC status code +# TYPE probe_grpc_status_code gauge +probe_grpc_status_code 0 +# HELP probe_ip_addr_hash Specifies the hash of IP address. It's useful to detect if the IP address changes. +# TYPE probe_ip_addr_hash gauge +probe_ip_addr_hash 1.268118805e+09 +# HELP probe_ip_protocol Specifies whether probe ip protocol is IP4 or IP6 +# TYPE probe_ip_protocol gauge +probe_ip_protocol 4 +# HELP probe_ssl_earliest_cert_expiry Returns last SSL chain expiry in unixtime +# TYPE probe_ssl_earliest_cert_expiry gauge +probe_ssl_earliest_cert_expiry 3.6e+09 +# HELP probe_ssl_last_chain_info Contains SSL leaf certificate information +# TYPE probe_ssl_last_chain_info gauge +probe_ssl_last_chain_info{fingerprint_sha256="efc04a3afb86376b3a4db1b1d2f454afc60d192a573d78541836d83e4c849813",issuer="O=Acme Co",subject="O=Acme Co",subjectalternative="example.com"} 1 +# HELP probe_success Displays whether or not the probe was a success +# TYPE probe_success gauge +probe_success 1 +# HELP probe_tls_version_info Returns the TLS version used or NaN when unknown +# TYPE probe_tls_version_info gauge +probe_tls_version_info{version="TLS 1.3"} 1 +# HELP sm_check_info Provides information about a single check configuration +# TYPE sm_check_info gauge +sm_check_info 1 +# HELP probe_all_duration_seconds Returns how long the probe took to complete in seconds (histogram) +# TYPE probe_all_duration_seconds histogram +probe_all_duration_seconds_bucket{le="0.005"} 1 +probe_all_duration_seconds_bucket{le="0.01"} 1 +probe_all_duration_seconds_bucket{le="0.025"} 1 +probe_all_duration_seconds_bucket{le="0.05"} 1 +probe_all_duration_seconds_bucket{le="0.1"} 1 +probe_all_duration_seconds_bucket{le="0.25"} 1 +probe_all_duration_seconds_bucket{le="0.5"} 1 +probe_all_duration_seconds_bucket{le="1"} 1 +probe_all_duration_seconds_bucket{le="2.5"} 1 +probe_all_duration_seconds_bucket{le="5"} 1 +probe_all_duration_seconds_bucket{le="10"} 1 +probe_all_duration_seconds_bucket{le="+Inf"} 1 +probe_all_duration_seconds_sum 0.001690042 +probe_all_duration_seconds_count 1 +# HELP probe_all_success Displays whether or not the probe was a success (summary) +# TYPE probe_all_success summary +probe_all_success_sum 1 +probe_all_success_count 1 +# HELP probe_dns_lookup_all_time_seconds Returns the time taken for probe dns lookup in seconds (histogram) +# TYPE probe_dns_lookup_all_time_seconds histogram +probe_dns_lookup_all_time_seconds_bucket{le="0.005"} 1 +probe_dns_lookup_all_time_seconds_bucket{le="0.01"} 1 +probe_dns_lookup_all_time_seconds_bucket{le="0.025"} 1 +probe_dns_lookup_all_time_seconds_bucket{le="0.05"} 1 +probe_dns_lookup_all_time_seconds_bucket{le="0.1"} 1 +probe_dns_lookup_all_time_seconds_bucket{le="0.25"} 1 +probe_dns_lookup_all_time_seconds_bucket{le="0.5"} 1 +probe_dns_lookup_all_time_seconds_bucket{le="1"} 1 +probe_dns_lookup_all_time_seconds_bucket{le="2.5"} 1 +probe_dns_lookup_all_time_seconds_bucket{le="5"} 1 +probe_dns_lookup_all_time_seconds_bucket{le="10"} 1 +probe_dns_lookup_all_time_seconds_bucket{le="+Inf"} 1 +probe_dns_lookup_all_time_seconds_sum 3.961e-06 +probe_dns_lookup_all_time_seconds_count 1 +# HELP probe_grpc_all_duration_seconds Duration of gRPC request by phase (histogram) +# TYPE probe_grpc_all_duration_seconds histogram +probe_grpc_all_duration_seconds_bucket{phase="check",le="0.005"} 1 +probe_grpc_all_duration_seconds_bucket{phase="check",le="0.01"} 1 +probe_grpc_all_duration_seconds_bucket{phase="check",le="0.025"} 1 +probe_grpc_all_duration_seconds_bucket{phase="check",le="0.05"} 1 +probe_grpc_all_duration_seconds_bucket{phase="check",le="0.1"} 1 +probe_grpc_all_duration_seconds_bucket{phase="check",le="0.25"} 1 +probe_grpc_all_duration_seconds_bucket{phase="check",le="0.5"} 1 +probe_grpc_all_duration_seconds_bucket{phase="check",le="1"} 1 +probe_grpc_all_duration_seconds_bucket{phase="check",le="2.5"} 1 +probe_grpc_all_duration_seconds_bucket{phase="check",le="5"} 1 +probe_grpc_all_duration_seconds_bucket{phase="check",le="10"} 1 +probe_grpc_all_duration_seconds_bucket{phase="check",le="+Inf"} 1 +probe_grpc_all_duration_seconds_sum{phase="check"} 0.001552342 +probe_grpc_all_duration_seconds_count{phase="check"} 1 +probe_grpc_all_duration_seconds_bucket{phase="resolve",le="0.005"} 1 +probe_grpc_all_duration_seconds_bucket{phase="resolve",le="0.01"} 1 +probe_grpc_all_duration_seconds_bucket{phase="resolve",le="0.025"} 1 +probe_grpc_all_duration_seconds_bucket{phase="resolve",le="0.05"} 1 +probe_grpc_all_duration_seconds_bucket{phase="resolve",le="0.1"} 1 +probe_grpc_all_duration_seconds_bucket{phase="resolve",le="0.25"} 1 +probe_grpc_all_duration_seconds_bucket{phase="resolve",le="0.5"} 1 +probe_grpc_all_duration_seconds_bucket{phase="resolve",le="1"} 1 +probe_grpc_all_duration_seconds_bucket{phase="resolve",le="2.5"} 1 +probe_grpc_all_duration_seconds_bucket{phase="resolve",le="5"} 1 +probe_grpc_all_duration_seconds_bucket{phase="resolve",le="10"} 1 +probe_grpc_all_duration_seconds_bucket{phase="resolve",le="+Inf"} 1 +probe_grpc_all_duration_seconds_sum{phase="resolve"} 3.961e-06 +probe_grpc_all_duration_seconds_count{phase="resolve"} 1 diff --git a/internal/scraper/testdata/grpc_ssl_basic.txt b/internal/scraper/testdata/grpc_ssl_basic.txt new file mode 100644 index 000000000..7b32c9657 --- /dev/null +++ b/internal/scraper/testdata/grpc_ssl_basic.txt @@ -0,0 +1,63 @@ +# HELP probe_dns_lookup_time_seconds Returns the time taken for probe dns lookup in seconds +# TYPE probe_dns_lookup_time_seconds gauge +probe_dns_lookup_time_seconds 4.911e-06 +# HELP probe_duration_seconds Returns how long the probe took to complete in seconds +# TYPE probe_duration_seconds gauge +probe_duration_seconds 0.002287457 +# HELP probe_grpc_duration_seconds Duration of gRPC request by phase +# TYPE probe_grpc_duration_seconds gauge +probe_grpc_duration_seconds{phase="check"} 0.002128242 +probe_grpc_duration_seconds{phase="resolve"} 4.911e-06 +# HELP probe_grpc_healthcheck_response Response HealthCheck response +# TYPE probe_grpc_healthcheck_response gauge +probe_grpc_healthcheck_response{serving_status="NOT_SERVING"} 0 +probe_grpc_healthcheck_response{serving_status="SERVICE_UNKNOWN"} 0 +probe_grpc_healthcheck_response{serving_status="SERVING"} 1 +probe_grpc_healthcheck_response{serving_status="UNKNOWN"} 0 +# HELP probe_grpc_ssl Indicates if SSL was used for the connection +# TYPE probe_grpc_ssl gauge +probe_grpc_ssl 1 +# HELP probe_grpc_status_code Response gRPC status code +# TYPE probe_grpc_status_code gauge +probe_grpc_status_code 0 +# HELP probe_ip_addr_hash Specifies the hash of IP address. It's useful to detect if the IP address changes. +# TYPE probe_ip_addr_hash gauge +probe_ip_addr_hash 1.268118805e+09 +# HELP probe_ip_protocol Specifies whether probe ip protocol is IP4 or IP6 +# TYPE probe_ip_protocol gauge +probe_ip_protocol 4 +# HELP probe_ssl_earliest_cert_expiry Returns last SSL chain expiry in unixtime +# TYPE probe_ssl_earliest_cert_expiry gauge +probe_ssl_earliest_cert_expiry 3.6e+09 +# HELP probe_ssl_last_chain_info Contains SSL leaf certificate information +# TYPE probe_ssl_last_chain_info gauge +probe_ssl_last_chain_info{fingerprint_sha256="efc04a3afb86376b3a4db1b1d2f454afc60d192a573d78541836d83e4c849813",issuer="O=Acme Co",subject="O=Acme Co",subjectalternative="example.com"} 1 +# HELP probe_success Displays whether or not the probe was a success +# TYPE probe_success gauge +probe_success 1 +# HELP probe_tls_version_info Returns the TLS version used or NaN when unknown +# TYPE probe_tls_version_info gauge +probe_tls_version_info{version="TLS 1.3"} 1 +# HELP sm_check_info Provides information about a single check configuration +# TYPE sm_check_info gauge +sm_check_info 1 +# HELP probe_all_duration_seconds Returns how long the probe took to complete in seconds (histogram) +# TYPE probe_all_duration_seconds histogram +probe_all_duration_seconds_bucket{le="0.005"} 1 +probe_all_duration_seconds_bucket{le="0.01"} 1 +probe_all_duration_seconds_bucket{le="0.025"} 1 +probe_all_duration_seconds_bucket{le="0.05"} 1 +probe_all_duration_seconds_bucket{le="0.1"} 1 +probe_all_duration_seconds_bucket{le="0.25"} 1 +probe_all_duration_seconds_bucket{le="0.5"} 1 +probe_all_duration_seconds_bucket{le="1"} 1 +probe_all_duration_seconds_bucket{le="2.5"} 1 +probe_all_duration_seconds_bucket{le="5"} 1 +probe_all_duration_seconds_bucket{le="10"} 1 +probe_all_duration_seconds_bucket{le="+Inf"} 1 +probe_all_duration_seconds_sum 0.002287457 +probe_all_duration_seconds_count 1 +# HELP probe_all_success Displays whether or not the probe was a success (summary) +# TYPE probe_all_success summary +probe_all_success_sum 1 +probe_all_success_count 1 diff --git a/pkg/accounting/data.go b/pkg/accounting/data.go index c760c31d3..30a83c6a4 100644 --- a/pkg/accounting/data.go +++ b/pkg/accounting/data.go @@ -4,6 +4,10 @@ package accounting var activeSeriesByCheckType = map[string]int{ "dns": 85, "dns_basic": 29, + "grpc": 73, + "grpc_basic": 31, + "grpc_ssl": 75, + "grpc_ssl_basic": 33, "http": 118, "http_basic": 34, "http_ssl": 122,