Skip to content

Commit

Permalink
CORE-13504: Add CryptoRewrapBusProcessor metrics to Grafana
Browse files Browse the repository at this point in the history
  • Loading branch information
malachyb authored Dec 18, 2023
1 parent 462ab74 commit 3c8554e
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import net.corda.crypto.core.CryptoService
import net.corda.data.crypto.wire.ops.key.rotation.IndividualKeyRotationRequest
import net.corda.messaging.api.processor.DurableProcessor
import net.corda.messaging.api.records.Record
import net.corda.metrics.CordaMetrics

private const val REWRAP_KEYS_OPERATION_NAME = "rewrapKeys"

/**
* This processor does actual re-wrapping of the keys.
Expand All @@ -15,10 +18,15 @@ class CryptoRewrapBusProcessor(
) : DurableProcessor<String, IndividualKeyRotationRequest> {
override val keyClass: Class<String> = String::class.java
override val valueClass = IndividualKeyRotationRequest::class.java
private val rewrapTimer = CordaMetrics.Metric.Crypto.RewrapKeysTimer.builder()
.withTag(CordaMetrics.Tag.OperationName, REWRAP_KEYS_OPERATION_NAME)
.build()

override fun onNext(events: List<Record<String, IndividualKeyRotationRequest>>): List<Record<*, *>> {
events.mapNotNull { it.value }.map { request ->
cryptoService.rewrapWrappingKey(request.tenantId, request.targetKeyAlias, request.newParentKeyAlias)
rewrapTimer.recordCallable {
cryptoService.rewrapWrappingKey(request.tenantId, request.targetKeyAlias, request.newParentKeyAlias)
}
}
return emptyList()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,11 @@ object CordaMetrics {
*/
object SignatureSpecTimer: Metric<Timer>("$PREFIX.signature.spec.time", CordaMetrics::timer)

/**
* The time taken for rewrapping keys in key rotation
*/
object RewrapKeysTimer: Metric<Timer>("$PREFIX.rewrap.time", CordaMetrics::timer)

}

object Membership {
Expand Down
109 changes: 109 additions & 0 deletions metrics/grafana/provisioning/dashboards/corda.json
Original file line number Diff line number Diff line change
Expand Up @@ -3604,6 +3604,115 @@
],
"title": "Cache",
"type": "row"
},
{
"collapsed": true,
"gridPos": {
"h": 1,
"w": 24,
"x": 0,
"y": 6
},
"id": 70,
"panels": [
{
"datasource": {
"type": "prometheus",
"uid": "dnOZedS4z"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisBorderShow": false,
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 0,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"insertNulls": false,
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 7
},
"id": 71,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "dnOZedS4z"
},
"editorMode": "code",
"expr": "rate(corda_crypto_rewrap_time_seconds_sum[$__rate_interval]) /\nrate(corda_crypto_rewrap_time_seconds_count[$__rate_interval])",
"instant": false,
"legendFormat": "__auto",
"range": true,
"refId": "A"
}
],
"title": "Unmanaged Individual Key Rotation",
"type": "timeseries"
}
],
"title": "Crypto",
"type": "row"
}
],
"refresh": "30s",
Expand Down

0 comments on commit 3c8554e

Please sign in to comment.