Skip to content

Commit

Permalink
envoy: add rbac metrics (#16165)
Browse files Browse the repository at this point in the history
* envoy: add rbac metrics

* Add envoy rbac metrics
* unit test
* changelog
* Update metadata.csv

see also
https://www.envoyproxy.io/docs/envoy/latest/configuration/http/http_filters/rbac_filter

Signed-off-by: William Dauchy <[email protected]>

* fix changelog

---------

Signed-off-by: William Dauchy <[email protected]>
Co-authored-by: steveny91 <[email protected]>
  • Loading branch information
wdauchy and steveny91 authored Nov 10, 2023
1 parent b36ca91 commit e002859
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions envoy/changelog.d/16165.added
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add rbac metrics
4 changes: 4 additions & 0 deletions envoy/datadog_checks/envoy/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,10 @@
'envoy_tcp_on_demand_cluster_timeout': 'tcp.on_demand_cluster_timeout',
'envoy_tcp_upstream_flush': 'tcp.upstream_flush',
'envoy_tcp_upstream_flush_active': 'tcp.upstream_flush_active',
'envoy_http_rbac_allowed': 'http.rbac_allowed',
'envoy_http_rbac_denied': 'http.rbac_denied',
'envoy_http_rbac_shadow_allowed': 'http.rbac_shadow_allowed',
'envoy_http_rbac_shadow_denied': 'http.rbac_shadow_denied',
}

# fmt: off
Expand Down
4 changes: 4 additions & 0 deletions envoy/metadata.csv
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,10 @@ envoy.http.downstream_rq_3xx,count,,response,,[Legacy] Total 3xx responses,0,env
envoy.http.downstream_rq_4xx,count,,response,,[Legacy] Total 4xx responses,-1,envoy,,
envoy.http.downstream_rq_5xx,count,,response,,[Legacy] Total 5xx responses,-1,envoy,,
envoy.http.downstream_rq_ws_on_non_ws_route,count,,request,,[Legacy] Total WebSocket upgrade requests rejected by non WebSocket routes,0,envoy,,
envoy.http.rbac_allowed.count,count,,request,,[OpenMetrics V2] Total requests that were allowed access,-1,envoy,,
envoy.http.rbac_denied.count,count,,request,,[OpenMetrics V2] Total requests that were denied access,-1,envoy,,
envoy.http.rbac_shadow_allowed.count,count,,request,,[OpenMetrics V2] Total requests that would be allowed access by the filter's shadow rules,-1,envoy,,
envoy.http.rbac_shadow_denied.count,count,,request,,[OpenMetrics V2] Total requests that would be denied access by the filter's shadow rules,-1,envoy,,
envoy.http.rs_too_large,count,,error,,[Legacy] Total response errors due to buffering an overly large body,-1,envoy,,
envoy.http.user_agent.downstream_cx_total,count,,connection,,[Legacy] Total connections,0,envoy,,
envoy.http.user_agent.downstream_cx_destroy_remote_active_rq,count,,connection,,[Legacy] Total connections destroyed remotely with active requests,-1,envoy,,
Expand Down
8 changes: 8 additions & 0 deletions envoy/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,10 @@
"http.passthrough_internal_redirect_predicate.count",
"http.passthrough_internal_redirect_too_many_redirects.count",
"http.passthrough_internal_redirect_unsafe_scheme.count",
"http.rbac_allowed.count",
"http.rbac_denied.count",
"http.rbac_shadow_allowed.count",
"http.rbac_shadow_denied.count",
"http.rq_direct_response.count",
"http.rq_redirect.count",
"http.rq_reset_after_downstream_response_started.count",
Expand Down Expand Up @@ -584,6 +588,10 @@
"http.downstream_rq_xx.count",
"http.no_cluster.count",
"http.no_route.count",
"http.rbac_allowed.count",
"http.rbac_denied.count",
"http.rbac_shadow_allowed.count",
"http.rbac_shadow_denied.count",
"http.rq.count",
"http.rq_direct_response.count",
"http.rq_redirect.count",
Expand Down
7 changes: 7 additions & 0 deletions envoy/tests/docker/api_v3/front-envoy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ static_resources:
"@type": type.googleapis.com/envoy.extensions.filters.http.ext_authz.v3.ExtAuthzPerRoute
disabled: true
http_filters:
- name: envoy.filters.http.rbac
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.rbac.v3.RBAC
rules:
action: DENY
shadow_rules:
action: DENY
- name: envoy.filters.http.ext_authz
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.ext_authz.v3.ExtAuthz
Expand Down
8 changes: 8 additions & 0 deletions envoy/tests/fixtures/openmetrics.txt
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,14 @@ envoy_http_downstream_cx_destroy_local_active_rq{envoy_http_conn_manager_prefix=
# TYPE envoy_http_downstream_rq_ws_on_non_ws_route counter
envoy_http_downstream_rq_ws_on_non_ws_route{envoy_http_conn_manager_prefix="ingress_http"} 0
envoy_http_downstream_rq_xx{envoy_response_code_class="4",envoy_http_conn_manager_prefix="ingress_http"} 0
# TYPE envoy_http_rbac_allowed counter
envoy_http_rbac_allowed{envoy_http_conn_manager_prefix="ingress_http"} 0
# TYPE envoy_http_rbac_denied counter
envoy_http_rbac_denied{envoy_http_conn_manager_prefix="ingress_http"} 0
# TYPE envoy_http_rbac_shadow_allowed counter
envoy_http_rbac_shadow_allowed{envoy_http_conn_manager_prefix="ingress_http"} 0
# TYPE envoy_http_rbac_shadow_denied counter
envoy_http_rbac_shadow_denied{envoy_http_conn_manager_prefix="ingress_http"} 0
# TYPE envoy_listener_worker_4_downstream_cx_total counter
envoy_listener_worker_4_downstream_cx_total{envoy_listener_address="0.0.0.0_80"} 0
# TYPE envoy_listener_http_downstream_rq_xx counter
Expand Down

0 comments on commit e002859

Please sign in to comment.