Created
August 9, 2019 12:14
-
-
Save philandstuff/3c7e564b7a151cdf691d0d7fdf3886a9 to your computer and use it in GitHub Desktop.
configure istio to collect custom metrics
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
apiVersion: config.istio.io/v1alpha2 | |
kind: metric | |
metadata: | |
labels: | |
app: canary | |
owner: canary-hack | |
name: requestcountbypath | |
namespace: sandbox-main | |
spec: | |
dimensions: | |
connection_security_policy: conditional((context.reporter.kind | "inbound") == | |
"outbound", "unknown", conditional(connection.mtls | false, "mutual_tls", "none")) | |
destination_app: destination.labels["app"] | "unknown" | |
destination_principal: destination.principal | "unknown" | |
destination_version: destination.labels["version"] | "unknown" | |
destination_workload: destination.workload.name | "unknown" | |
destination_workload_namespace: destination.workload.namespace | "unknown" | |
permissive_response_code: rbac.permissive.response_code | "none" | |
permissive_response_policyid: rbac.permissive.effective_policy_id | "none" | |
reporter: conditional((context.reporter.kind | "inbound") == "outbound", "source", | |
"destination") | |
request_path: request.path | "unknown" | |
request_protocol: api.protocol | context.protocol | "unknown" | |
response_code: response.code | 200 | |
response_flags: context.proxy_error_code | "-" | |
source_app: source.labels["app"] | "unknown" | |
source_principal: source.principal | "unknown" | |
source_version: source.labels["version"] | "unknown" | |
source_workload: source.workload.name | "unknown" | |
source_workload_namespace: source.workload.namespace | "unknown" | |
value: "1" | |
--- | |
apiVersion: config.istio.io/v1alpha2 | |
kind: rule | |
metadata: | |
labels: | |
app: canary | |
owner: canary-hack | |
name: promhttpbypath | |
namespace: sandbox-main | |
spec: | |
actions: | |
- handler: prometheusbypath | |
instances: | |
- requestcountbypath.metric | |
match: (context.protocol == "http") && (destination.workload.namespace == "sandbox-main") && (match((request.useragent | |
| "-"), "kube-probe*") == false) | |
--- | |
apiVersion: config.istio.io/v1alpha2 | |
kind: handler | |
metadata: | |
labels: | |
app: canary | |
owner: canary-hack | |
name: prometheusbypath | |
namespace: sandbox-main | |
spec: | |
compiledAdapter: prometheus | |
params: | |
metrics: | |
- instance_name: requestcountbypath.metric.sandbox-main | |
kind: COUNTER | |
label_names: | |
- reporter | |
- source_app | |
- source_principal | |
- source_workload | |
- source_workload_namespace | |
- source_version | |
- destination_app | |
- destination_principal | |
- destination_workload | |
- destination_workload_namespace | |
- destination_version | |
- request_path | |
- request_protocol | |
- response_code | |
- response_flags | |
- permissive_response_code | |
- permissive_response_policyid | |
- connection_security_policy | |
name: requests_by_path_total | |
metricsExpirationPolicy: | |
metricsExpiryDuration: 10m | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment