Skip to content

Commit

Permalink
envoy: add support for tls_inspector metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
wdauchy committed Sep 9, 2024
1 parent 2d82a48 commit 79f645f
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 3 deletions.
1 change: 1 addition & 0 deletions envoy/changelog.d/18536.added
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add support for tls_inspector metrics
8 changes: 8 additions & 0 deletions envoy/datadog_checks/envoy/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,14 @@
'envoy_cluster_client_ssl_socket_factory_downstream_context_secrets_not_ready': 'cluster.client_ssl_socket_factory.downstream_context_secrets_not_ready', # noqa: E501
'envoy_connection_limit_active_connections': 'connection_limit.active_connections',
'envoy_connection_limit_limited_connections': 'connection_limit.limited_connections',
'envoy_tls_inspector_client_hello_too_large': 'tls_inspector.client_hello_too_large',
'envoy_tls_inspector_tls_found': 'tls_inspector.tls.found',
'envoy_tls_inspector_tls_not_found': 'tls_inspector.tls.not_found',
'envoy_tls_inspector_alpn_found': 'tls_inspector.alpn.found',
'envoy_tls_inspector_alpn_not_found': 'tls_inspector.alpn.not_found',
'envoy_tls_inspector_sni_found': 'tls_inspector.sni.found',
'envoy_tls_inspector_sni_not_found': 'tls_inspector.sni.not_found',
'envoy_tls_inspector_bytes_processed': 'tls_inspector.bytes_processed',
}

# fmt: off
Expand Down
10 changes: 10 additions & 0 deletions envoy/metadata.csv
Original file line number Diff line number Diff line change
Expand Up @@ -988,3 +988,13 @@ envoy.cluster.client_ssl_socket_factory.upstream_context_secrets_not_ready.count
envoy.listener.server_ssl_socket_factory.downstream_context_secrets_not_ready.count,count,,,,[OpenMetrics V2] The count of SSL context updates for the client's SSL socket factory performed by Secret Discovery Service.,-1,envoy,,
envoy.listener.server_ssl_socket_factory.ssl_context_update_by_sds.count,count,,,,[OpenMetrics V2] The count of upstream SSL context secrets of the client's SSL socket factory that are not ready.,-1,envoy,,
envoy.listener.server_ssl_socket_factory.upstream_context_secrets_not_ready.count,count,,,,[OpenMetrics V2] The count of downstream SSL context secrets for the client SSL socket factory that are not yet ready.,-1,envoy,,
envoy.tls_inspector.client_hello_too_large.count,count,,,,[OpenMetrics V2] Total unreasonably large client hello received,0,envoy,,
envoy.tls_inspector.tls.found.count,count,,,,[OpenMetrics V2] Total number of times TLS was found,0,envoy,,
envoy.tls_inspector.tls.not_found.count,count,,,,[OpenMetrics V2] Total number of times TLS was not found,0,envoy,,
envoy.tls_inspector.alpn.found.count,count,,,,[OpenMetrics V2] Total number of times Application-Layer Protocol Negotiation was successful,0,envoy,,
envoy.tls_inspector.alpn.not_found.count,count,,,,[OpenMetrics V2] Total number of times Application-Layer Protocol Negotiation has failed,0,envoy,,
envoy.tls_inspector.sni.found.count,count,,,,[OpenMetrics V2] Total number of times Server Name Indication was found,0,envoy,,
envoy.tls_inspector.sni.not_found.count,count,,,,[OpenMetrics V2] Total number of times Server Name Indication was not found,0,envoy,,
envoy.tls_inspector.bytes_processed.bucket,count,,,,[OpenMetrics V2] Records sizes which records the number of bytes the tls_inspector processed while analyzing for tls usage,0,envoy,,
envoy.tls_inspector.bytes_processed.count,count,,,,[OpenMetrics V2] Count of records sizes which records the number of bytes the tls_inspector processed while analyzing for tls usage,0,envoy,,
envoy.tls_inspector.bytes_processed.sum,count,,,,[OpenMetrics V2] Total sum of records sizes which records the number of bytes the tls_inspector processed while analyzing for tls usage,0,envoy,,
13 changes: 13 additions & 0 deletions envoy/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,19 @@

CONNECTION_LIMIT_STAT_PREFIX_TAG = 'stat_prefix:ingress_http'

TLS_INSPECTOR_METRICS = [
"tls_inspector.client_hello_too_large.count",
"tls_inspector.tls.found.count",
"tls_inspector.tls.not_found.count",
"tls_inspector.alpn.found.count",
"tls_inspector.alpn.not_found.count",
"tls_inspector.sni.found.count",
"tls_inspector.sni.not_found.count",
"tls_inspector.bytes_processed.bucket",
"tls_inspector.bytes_processed.count",
"tls_inspector.bytes_processed.sum",
]

LOCAL_RATE_LIMIT_METRICS = [
"http.local_rate_limit_enabled.count",
"http.local_rate_limit_enforced.count",
Expand Down
4 changes: 4 additions & 0 deletions envoy/tests/docker/api_v3/front-envoy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ static_resources:
listeners:
- address:
socket_address: {address: 0.0.0.0, port_value: 80}
listener_filters:
- name: envoy.filters.listeners.tls_inspector
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.listener.tls_inspector.v3.TlsInspector
filter_chains:
- filters:
- name: envoy.filters.network.connection_limit
Expand Down
37 changes: 37 additions & 0 deletions envoy/tests/fixtures/openmetrics/openmetrics.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1340,3 +1340,40 @@ envoy_cluster_client_ssl_socket_factory_ssl_context_update_by_sds{envoy_cluster_
envoy_cluster_client_ssl_socket_factory_upstream_context_secrets_not_ready{envoy_cluster_name="foo_cluster"} 2
# TYPE envoy_cluster_client_ssl_socket_factory_downstream_context_secrets_not_ready counter
envoy_cluster_client_ssl_socket_factory_downstream_context_secrets_not_ready{envoy_cluster_name="foo_cluster"} 0
# TYPE envoy_tls_inspector_alpn_found counter
envoy_tls_inspector_alpn_found{} 0
# TYPE envoy_tls_inspector_alpn_not_found counter
envoy_tls_inspector_alpn_not_found{} 0
# TYPE envoy_tls_inspector_client_hello_too_large counter
envoy_tls_inspector_client_hello_too_large{} 0
# TYPE envoy_tls_inspector_sni_found counter
envoy_tls_inspector_sni_found{} 0
# TYPE envoy_tls_inspector_sni_not_found counter
envoy_tls_inspector_sni_not_found{} 0
# TYPE envoy_tls_inspector_tls_found counter
envoy_tls_inspector_tls_found{} 0
# TYPE envoy_tls_inspector_tls_not_found counter
envoy_tls_inspector_tls_not_found{} 0
# TYPE envoy_tls_inspector_bytes_processed histogram
envoy_tls_inspector_bytes_processed_bucket{le="0.5"} 0
envoy_tls_inspector_bytes_processed_bucket{le="1"} 0
envoy_tls_inspector_bytes_processed_bucket{le="5"} 0
envoy_tls_inspector_bytes_processed_bucket{le="10"} 0
envoy_tls_inspector_bytes_processed_bucket{le="25"} 0
envoy_tls_inspector_bytes_processed_bucket{le="50"} 0
envoy_tls_inspector_bytes_processed_bucket{le="100"} 0
envoy_tls_inspector_bytes_processed_bucket{le="250"} 0
envoy_tls_inspector_bytes_processed_bucket{le="500"} 0
envoy_tls_inspector_bytes_processed_bucket{le="1000"} 0
envoy_tls_inspector_bytes_processed_bucket{le="2500"} 0
envoy_tls_inspector_bytes_processed_bucket{le="5000"} 0
envoy_tls_inspector_bytes_processed_bucket{le="10000"} 0
envoy_tls_inspector_bytes_processed_bucket{le="30000"} 0
envoy_tls_inspector_bytes_processed_bucket{le="60000"} 0
envoy_tls_inspector_bytes_processed_bucket{le="300000"} 0
envoy_tls_inspector_bytes_processed_bucket{le="600000"} 0
envoy_tls_inspector_bytes_processed_bucket{le="1800000"} 0
envoy_tls_inspector_bytes_processed_bucket{le="3600000"} 0
envoy_tls_inspector_bytes_processed_bucket{le="+Inf"} 0
envoy_tls_inspector_bytes_processed_sum{} 0
envoy_tls_inspector_bytes_processed_count{} 0
3 changes: 2 additions & 1 deletion envoy/tests/test_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
FLAKY_METRICS,
LOCAL_RATE_LIMIT_METRICS,
PROMETHEUS_METRICS,
TLS_INSPECTOR_METRICS,
requires_new_environment,
)

Expand All @@ -23,7 +24,7 @@
def test_e2e(dd_agent_check):
aggregator = dd_agent_check(DEFAULT_INSTANCE, rate=True)

for metric in PROMETHEUS_METRICS + LOCAL_RATE_LIMIT_METRICS + CONNECTION_LIMIT_METRICS:
for metric in PROMETHEUS_METRICS + LOCAL_RATE_LIMIT_METRICS + CONNECTION_LIMIT_METRICS + TLS_INSPECTOR_METRICS:
formatted_metric = "envoy.{}".format(metric)
if metric in FLAKY_METRICS:
aggregator.assert_metric(formatted_metric, at_least=0)
Expand Down
3 changes: 2 additions & 1 deletion envoy/tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
FLAKY_METRICS,
LOCAL_RATE_LIMIT_METRICS,
PROMETHEUS_METRICS,
TLS_INSPECTOR_METRICS,
requires_new_environment,
)

Expand All @@ -37,7 +38,7 @@ def test_check(aggregator, dd_run_check, check):
dd_run_check(c)
dd_run_check(c)

for metric in PROMETHEUS_METRICS + LOCAL_RATE_LIMIT_METRICS + CONNECTION_LIMIT_METRICS:
for metric in PROMETHEUS_METRICS + LOCAL_RATE_LIMIT_METRICS + CONNECTION_LIMIT_METRICS + TLS_INSPECTOR_METRICS:
formatted_metric = "envoy.{}".format(metric)
if metric in FLAKY_METRICS:
aggregator.assert_metric(formatted_metric, at_least=0)
Expand Down
5 changes: 4 additions & 1 deletion envoy/tests/test_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
LOCAL_RATE_LIMIT_METRICS,
MOCKED_PROMETHEUS_METRICS,
RATE_LIMIT_STAT_PREFIX_TAG,
TLS_INSPECTOR_METRICS,
get_fixture_path,
)

Expand Down Expand Up @@ -48,7 +49,9 @@ def test_check(aggregator, dd_run_check, check, mock_http_response):

dd_run_check(c)

for metric in MOCKED_PROMETHEUS_METRICS + LOCAL_RATE_LIMIT_METRICS + CLUSTER_AND_LISTENER_SSL_METRICS:
for metric in (
MOCKED_PROMETHEUS_METRICS + LOCAL_RATE_LIMIT_METRICS + CLUSTER_AND_LISTENER_SSL_METRICS + TLS_INSPECTOR_METRICS
):
aggregator.assert_metric("envoy.{}".format(metric))

for metric in CONNECT_STATE_METRIC:
Expand Down

0 comments on commit 79f645f

Please sign in to comment.