Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add custom metrics istio example #40

Merged
merged 1 commit into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 105 additions & 2 deletions examples.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -316,10 +316,22 @@ examples:
limit: 2G
category: "General"

- name: "Istio: Access Log Filtering"
- name: "Access Log Filtering"
cel: |
// Use CEL to filter access logs in Istio by response code or target cluster.
// https://istio.io/latest/docs/tasks/observability/logs/telemetry-api/#get-started-with-telemetry-api
//
// apiVersion: telemetry.istio.io/v1alpha1
// kind: Telemetry
// metadata:
// name: default-exception-logging
// namespace: istio-system
// spec:
// accessLogging:
// - providers:
// - name: otel
// filter:
// expression: "response.code >= 400 || xds.cluster_name == 'BlackHoleCluster' || xds.cluster_name == 'PassthroughCluster' "

response.code >= 400 || (xds.cluster_name == 'BlackHoleCluster' || xds.cluster_name == 'PassthroughCluster')
data: |
Expand Down Expand Up @@ -367,7 +379,98 @@ examples:
route_metadata: ""
route_name: "allow_any"
upstream_host_metadata: "NULL"
category: "General"
category: "Istio"

- name: "Custom Metrics"
cel: |
// Use CEL to customize the metrics that Istio generates
// https://istio.io/latest/docs/tasks/observability/metrics/customize-metrics/#use-expressions-for-values
//
// apiVersion: telemetry.istio.io/v1alpha1
// kind: Telemetry
// metadata:
// name: namespace-metrics
// spec:
// metrics:
// - providers:
// - name: prometheus
// overrides:
// - match:
// metric: REQUEST_COUNT
// tagOverrides:
// destination_port:
// value: "string(destination.port)" # <--- CEL
// request_host:
// value: "request.host" # <--- CEL

has(request.host) ? request.host : "unknown"
data: |
request:
duration: "4.144461ms"
headers:
x-request-id: "7a61a297-e508-43b7-94e8-b3919367e2d2"
host: "echo"
id: "7a61a297-e508-43b7-94e8-b3919367e2d2"
method: "GET"
path: "/"
protocol: "HTTP/1.1"
query: ""
referer: null
scheme: "http"
size: 0
time: "2023-10-13T20:30:38.106932+00:00"
total_size: 478
url_path: "/"
useragent: "curl/8.2.1"
response:
code: "200"
code_details: "via_upstream"
flags: "0"
grpc_status: "2"
headers:
content-type: "application/json"
size: 714
total_size: 1594
connection:
id: 36
mtls: true
dns_san_local_certificate: null
dns_san_peer_certificate: null
requested_server_name: "outbound_.80_._.echo.default.svc.cluster.local"
sha256_peer_certificate_digest: "1386a353d125910412d0ecfa7abb2f3fbee9ff3c77dd4d5c19312a8d51e27557"
subject_local_certificate: ""
subject_peer_certificate: ""
termination_details: null
tls_version: "TLSv1.3"
uri_san_local_certificate: "spiffe://cluster.local/ns/default/sa/default"
uri_san_peer_certificate: "spiffe://cluster.local/ns/default/sa/default"
upstream:
address: "10.244.0.38:80"
dns_san_local_certificate: null
dns_san_peer_certificate: null
local_address: "127.0.0.6:58023"
port: 80
sha256_peer_certificate_digest: null
subject_local_certificate: null
subject_peer_certificate: null
tls_version: null
transport_failure_reason: ""
uri_san_local_certificate: null
uri_san_peer_certificate: null
xds:
cluster_metadata:
filter_metadata:
istio:
services:
- host: "echo.default.svc.cluster.local"
name: "echo"
namespace: "default"
cluster_name: "inbound|80||"
filter_chain_name: "0.0.0.0_80"
route_metadata: ""
route_name: "default"
upstream_host_metadata: "NULL"
category: "Istio"

- name: "Blank"
cel: ""
Expand Down
12 changes: 12 additions & 0 deletions web/assets/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,18 @@
"data": "object:\n memory: 1.3G\n limit: 2G\n",
"category": "General"
},
{
"name": "Access Log Filtering",
"cel": "// Use CEL to filter access logs in Istio by response code or target cluster.\n// https://istio.io/latest/docs/tasks/observability/logs/telemetry-api/#get-started-with-telemetry-api\n//\n// apiVersion: telemetry.istio.io/v1alpha1\n// kind: Telemetry\n// metadata:\n// name: default-exception-logging\n// namespace: istio-system\n// spec:\n// accessLogging:\n// - providers:\n// - name: otel\n// filter:\n// expression: \"response.code >= 400 || xds.cluster_name == 'BlackHoleCluster' || xds.cluster_name == 'PassthroughCluster' \"\n\nresponse.code >= 400 || (xds.cluster_name == 'BlackHoleCluster' || xds.cluster_name == 'PassthroughCluster')\n",
"data": "# The following configuration is true access logs only when the response code is greater or equal to 400\n# or the request went to the BlackHoleCluster or the PassthroughCluster\nrequest:\n duration: \"173.403244ms\"\n headers:\n x-request-id: \"e8e687ab-fbbd-4662-8416-11761a29de36\"\n host: \"httpbin.org\"\n id: \"e8e687ab-fbbd-4662-8416-11761a29de36\"\n method: \"GET\"\n path: \"/get\"\n protocol: \"HTTP/1.1\"\n query: \"\"\n referer: null\n scheme: \"http\"\n size: 0\n time: \"2023-10-13T20:32:04.7006+00:00\"\n total_size: 1000\n url_path: \"/get\"\n useragent: \"curl/8.2.1\"\nresponse:\n code: 200\n code_details: \"via_upstream\"\n flags: 0\n grpc_status: 2\n headers:\n content-type: \"application/json\"\n size: 1181\n total_size: 1377\nconnection:\n id: 269\n mtls: false\n requested_server_name: \"\"\nupstream:\n address: \"54.80.46.162:80\"\n local_address: \"10.244.0.37:51128\"\n port: 80\n transport_failure_reason: \"\"\nxds:\n cluster_metadata: \"\"\n cluster_name: \"PassthroughCluster\"\n filter_chain_name: \"\"\n route_metadata: \"\"\n route_name: \"allow_any\"\n upstream_host_metadata: \"NULL\"\n",
"category": "Istio"
},
{
"name": "Custom Metrics",
"cel": "// Use CEL to customize the metrics that Istio generates\n// https://istio.io/latest/docs/tasks/observability/metrics/customize-metrics/#use-expressions-for-values\n// \n// apiVersion: telemetry.istio.io/v1alpha1\n// kind: Telemetry\n// metadata:\n// name: namespace-metrics\n// spec:\n// metrics:\n// - providers:\n// - name: prometheus\n// overrides:\n// - match:\n// metric: REQUEST_COUNT\n// tagOverrides:\n// destination_port:\n// value: \"string(destination.port)\" # <--- CEL\n// request_host:\n// value: \"request.host\" # <--- CEL\n\nhas(request.host) ? request.host : \"unknown\"\n",
"data": "request:\n duration: \"4.144461ms\"\n headers:\n x-request-id: \"7a61a297-e508-43b7-94e8-b3919367e2d2\"\n host: \"echo\"\n id: \"7a61a297-e508-43b7-94e8-b3919367e2d2\"\n method: \"GET\"\n path: \"/\"\n protocol: \"HTTP/1.1\"\n query: \"\"\n referer: null\n scheme: \"http\"\n size: 0\n time: \"2023-10-13T20:30:38.106932+00:00\"\n total_size: 478\n url_path: \"/\"\n useragent: \"curl/8.2.1\"\nresponse:\n code: \"200\"\n code_details: \"via_upstream\"\n flags: \"0\"\n grpc_status: \"2\"\n headers:\n content-type: \"application/json\"\n size: 714\n total_size: 1594\nconnection:\n id: 36\n mtls: true\n dns_san_local_certificate: null\n dns_san_peer_certificate: null\n requested_server_name: \"outbound_.80_._.echo.default.svc.cluster.local\"\n sha256_peer_certificate_digest: \"1386a353d125910412d0ecfa7abb2f3fbee9ff3c77dd4d5c19312a8d51e27557\"\n subject_local_certificate: \"\"\n subject_peer_certificate: \"\"\n termination_details: null\n tls_version: \"TLSv1.3\"\n uri_san_local_certificate: \"spiffe://cluster.local/ns/default/sa/default\"\n uri_san_peer_certificate: \"spiffe://cluster.local/ns/default/sa/default\"\nupstream:\n address: \"10.244.0.38:80\"\n dns_san_local_certificate: null\n dns_san_peer_certificate: null\n local_address: \"127.0.0.6:58023\"\n port: 80\n sha256_peer_certificate_digest: null\n subject_local_certificate: null\n subject_peer_certificate: null\n tls_version: null\n transport_failure_reason: \"\"\n uri_san_local_certificate: null\n uri_san_peer_certificate: null\nxds:\n cluster_metadata:\n filter_metadata:\n istio:\n services:\n - host: \"echo.default.svc.cluster.local\"\n name: \"echo\"\n namespace: \"default\"\n cluster_name: \"inbound|80||\"\n filter_chain_name: \"0.0.0.0_80\"\n route_metadata: \"\"\n route_name: \"default\"\n upstream_host_metadata: \"NULL\"\n",
"category": "Istio"
},
{
"name": "Blank",
"cel": "",
Expand Down