Skip to content

Commit

Permalink
Merge pull request #38 from Ygnas/auth-policy-metrics
Browse files Browse the repository at this point in the history
Auth policy metrics
  • Loading branch information
david-martin committed Oct 26, 2023
2 parents 22a18c0 + 2c94d52 commit 8a1c230
Show file tree
Hide file tree
Showing 11 changed files with 3,154 additions and 38 deletions.
55 changes: 54 additions & 1 deletion config/default/custom-resource-state.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -607,4 +607,57 @@ spec:
target_group: ["group"]
target_kind: ["kind"]
target_name: ["name"]
target_namespace: ["namespace"]
target_namespace: ["namespace"]
- groupVersionKind:
group: kuadrant.io
kind: "AuthPolicy"
version: "v1beta2"
metricNamePrefix: gatewayapi_authpolicy
labelsFromPath:
name:
- metadata
- name
namespace:
- metadata
- namespace
metrics:
- name: "labels"
help: "Kubernetes labels converted to Prometheus labels."
each:
type: Info
info:
path: [metadata]
labelsFromPath:
"*": [labels]
- name: "created"
help: "created timestamp"
each:
type: Gauge
gauge:
path: [metadata, creationTimestamp]
- name: "deleted"
help: "deletion timestamp"
each:
type: Gauge
gauge:
path: [metadata, deletionTimestamp]
- name: "target_info"
help: "Target references that the authpolicy wants to be attached to"
each:
type: Info
info:
path: [spec, targetRef]
labelsFromPath:
target_group: ["group"]
target_kind: ["kind"]
target_name: ["name"]
target_namespace: ["namespace"]
- name: "status"
help: "status condition"
each:
type: Gauge
gauge:
path: [status, conditions]
labelsFromPath:
type: ["type"]
valueFrom: ["status"]
174 changes: 166 additions & 8 deletions config/examples/dashboards/policies.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
{
"matcher": {
"id": "byName",
"options": "Target Kind"
"options": "Target Name"
},
"properties": [
{
Expand All @@ -100,8 +100,8 @@
"id": "links",
"value": [
{
"title": "TLSPolicy Details",
"url": "/d/gatewayapigateways/gateway-api-state-gateways?var-tlspolicy=${__value.text}"
"title": "Gateway Details",
"url": "/d/gatewayapigateways/gateway-api-state-gateways?var-gateway=${__value.text}"
}
]
}
Expand Down Expand Up @@ -231,7 +231,7 @@
{
"matcher": {
"id": "byName",
"options": "Target Kind"
"options": "Target Name"
},
"properties": [
{
Expand All @@ -242,8 +242,8 @@
"id": "links",
"value": [
{
"title": "RateLimitPolicy Details",
"url": "/d/gatewayapihttproutes/gateway-api-state-httproutes?var-ratelimitpolicy=${__value.text}"
"title": "HTTPRoute Details",
"url": "/d/gatewayapihttproutes/gateway-api-state-httproutes?var-httproute=${__value.text}"
}
]
}
Expand Down Expand Up @@ -306,6 +306,148 @@
"y": 8
},
"id": 9,
"title": "AuthPolicy",
"type": "row"
},
{
"datasource": {
"type": "prometheus",
"uid": "$datasource"
},
"description": "Total number of AuthPolicy across all clusters",
"gridPos": {
"h": 3,
"w": 2,
"x": 0,
"y": 9
},
"id": 10,
"pluginVersion": "v10.0.0",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "$datasource"
},
"expr": "count(gatewayapi_authpolicy_status{name=~\"${authpolicy}\"})",
"instant": true
}
],
"title": "Total",
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "$datasource"
},
"description": "Total AuthPolicy with an Available state",
"gridPos": {
"h": 3,
"w": 2,
"x": 2,
"y": 9
},
"id": 11,
"pluginVersion": "v10.0.0",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "$datasource"
},
"expr": "count(gatewayapi_authpolicy_status{type=\"Available\", name=~\"${authpolicy}\"})",
"instant": true
}
],
"title": "Available",
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "$datasource"
},
"fieldConfig": {
"overrides": [
{
"matcher": {
"id": "byName",
"options": "Target Name"
},
"properties": [
{
"id": "custom.displayMode",
"value": "color-text"
},
{
"id": "links",
"value": [
{
"title": "HTTPRoute Details",
"url": "/d/gatewayapihttproutes/gateway-api-state-httproutes?var-httproute=${__value.text}"
}
]
}
]
}
]
},
"gridPos": {
"h": 6,
"w": 10,
"x": 4,
"y": 9
},
"id": 12,
"pluginVersion": "v10.0.0",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "$datasource"
},
"expr": "gatewayapi_authpolicy_target_info{name=~\"${authpolicy}\"}",
"format": "table",
"instant": true,
"range": false
}
],
"title": "AuthPolicy",
"transformations": [
{
"id": "filterFieldsByName",
"options": {
"include": {
"names": [
"name",
"target_kind",
"target_name"
]
}
}
},
{
"id": "organize",
"options": {
"renameByName": {
"name": "Name",
"target_kind": "Target Kind",
"target_name": "Target Name"
}
}
}
],
"type": "table"
},
{
"gridPos": {
"h": 1,
"w": 24,
"x": 0,
"y": 10
},
"id": 13,
"title": "BackendTLSPolicy",
"type": "row"
},
Expand All @@ -321,9 +463,9 @@
"h": 6,
"w": 10,
"x": 4,
"y": 9
"y": 10
},
"id": 10,
"id": 14,
"pluginVersion": "v10.0.0",
"targets": [
{
Expand Down Expand Up @@ -411,6 +553,22 @@
"regex": "/(.*)/",
"type": "query"
},
{
"datasource": {
"type": "prometheus",
"uid": "${datasource}"
},
"includeAll": true,
"label": "AuthPolicy",
"multi": true,
"name": "authpolicy",
"query": {
"query": "label_values(gatewayapi_authpolicy_created, name)",
"refId": "StandardVariableQuery"
},
"regex": "/(.*)/",
"type": "query"
},
{
"datasource": {
"type": "prometheus",
Expand Down
Loading

0 comments on commit 8a1c230

Please sign in to comment.