Skip to content

Commit

Permalink
feat: reuse template and add color in dashboard table
Browse files Browse the repository at this point in the history
  • Loading branch information
Hardikl committed Jun 24, 2024
1 parent 618b649 commit 75352c9
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 67 deletions.
2 changes: 0 additions & 2 deletions cmd/collectors/rest/plugins/certificate/certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,9 @@ func (my *Certificate) Run(dataMap map[string]*matrix.Matrix) ([]*matrix.Matrix,
// update certificate instance based on admin vaserver serial
for _, certificateInstance := range data.GetInstances() {
if certificateInstance.IsExportable() {
certificateInstance.SetExportable(false)
serialNumber := certificateInstance.GetLabel("serial_number")

if serialNumber == adminVserverSerial {
certificateInstance.SetExportable(true)
// Admin SVM certificate is cluster scoped, but the REST API does not return the SVM name in its response. Add here for ZAPI parity
certificateInstance.SetLabel("svm", adminVserver)
my.setCertificateIssuerType(certificateInstance)
Expand Down
2 changes: 0 additions & 2 deletions cmd/collectors/zapi/plugins/certificate/certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,9 @@ func (my *Certificate) Run(dataMap map[string]*matrix.Matrix) ([]*matrix.Matrix,
// update certificate instance based on admin vaserver serial
for certificateInstanceKey, certificateInstance := range data.GetInstances() {
if certificateInstance.IsExportable() {
certificateInstance.SetExportable(false)
serialNumber := certificateInstance.GetLabel("serial_number")

if serialNumber == adminVserverSerial {
certificateInstance.SetExportable(true)
my.setCertificateIssuerType(certificateInstance, certificateInstanceKey)
my.setCertificateValidity(data, certificateInstance)
}
Expand Down
23 changes: 0 additions & 23 deletions conf/rest/9.12.0/certificate.yaml

This file was deleted.

5 changes: 2 additions & 3 deletions conf/rest/9.12.0/security_certificate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@ object: security_certificate

counters:
- ^^uuid
- ^expiry_time => expiry_time
- ^name
- ^public_certificate => certificatePEM
- ^scope => scope
- ^serial_number => serial_number
- ^svm.name => svm
- ^type => type
- expiry_time(timestamp) => expiry_time
- filter:
- scope=!"svm"
- type="server"

plugins:
- Certificate:
Expand All @@ -23,6 +21,7 @@ plugins:

export_options:
instance_keys:
- expiry_time
- uuid
instance_labels:
- certificateExpiryStatus
Expand Down
1 change: 0 additions & 1 deletion conf/rest/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ schedule:

objects:
Aggregate: aggr.yaml
Certificate: certificate.yaml
# The CIFSSession template may slow down data collection due to a high number of metrics.
# CIFSSession: cifs_session.yaml
# CIFSShare: cifs_share.yaml
Expand Down
4 changes: 1 addition & 3 deletions conf/zapi/cdot/9.8.0/security_certificate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ counters:
- expiration-date => expiry_time

plugins:
- LabelAgent:
include_equals:
- type `server`
- Certificate:
schedule:
- data: 3m # should be multiple of data poll duration
Expand All @@ -28,4 +25,5 @@ export_options:
instance_labels:
- certificateExpiryStatus
- certificateIssuerType
- expiry_time
- type
131 changes: 98 additions & 33 deletions grafana/dashboards/cmode/security.json
Original file line number Diff line number Diff line change
Expand Up @@ -1911,11 +1911,8 @@
},
"custom": {
"align": "left",
"cellOptions": {
"type": "auto"
},
"filterable": true,
"inspect": false
"displayMode": "color-background-solid",
"filterable": true
},
"mappings": [],
"thresholds": {
Expand All @@ -1924,10 +1921,14 @@
{
"color": "green",
"value": null
},
{
"color": "red",
"value": ""
}
]
},
"unitScale": true
"unit": "locale"
},
"overrides": [
{
Expand All @@ -1945,20 +1946,20 @@
{
"matcher": {
"id": "byName",
"options": "cluster"
"options": "svm"
},
"properties": [
{
"id": "displayName",
"value": "Cluster"
"value": "SVM"
},
{
"id": "links",
"value": [
{
"targetBlank": true,
"title": "",
"url": "/d/cdot-cluster/ontap-cluster?orgId=1&${Datacenter:queryparam}&${__url_time_range}&var-Cluster=${__value.raw}"
"url": "/d/cdot-svm/ontap-svm?orgId=1&${Datacenter:queryparam}&${Cluster:queryparam}&${__url_time_range}&var-SVM=${__value.raw}"
}
]
}
Expand All @@ -1967,24 +1968,63 @@
{
"matcher": {
"id": "byName",
"options": "svm"
"options": "Expiry"
},
"properties": [
{
"id": "displayName",
"value": "SVM"
},
{
"id": "links",
"id": "mappings",
"value": [
{
"targetBlank": true,
"title": "",
"url": "/d/cdot-svm/ontap-svm?orgId=1&${Datacenter:queryparam}&${Cluster:queryparam}&${__url_time_range}&var-SVM=${__value.raw}"
"options": {
"from": -100000000000000000000,
"result": {
"color": "red",
"index": 0,
"text": "Expired"
},
"to": 0
},
"type": "range"
},
{
"options": {
"from": 0,
"result": {
"color": "orange",
"index": 1,
"text": "This Month"
},
"to": 2678400
},
"type": "range"
},
{
"options": {
"from": 2678400,
"result": {
"color": "green",
"index": 2,
"text": "OK"
},
"to": 100000000000000000000
},
"type": "range"
}
]
}
]
},
{
"matcher": {
"id": "byName",
"options": "Expiry Date"
},
"properties": [
{
"id": "custom.width",
"value": 204
}
]
}
]
},
Expand All @@ -2005,36 +2045,58 @@
],
"show": false
},
"showHeader": true
"showHeader": true,
"sortBy": [
{
"desc": false,
"displayName": "Expiry"
}
]
},
"pluginVersion": "10.3.1",
"pluginVersion": "8.3.4",
"targets": [
{
"datasource": "${DS_PROMETHEUS}",
"editorMode": "code",
"exemplar": false,
"expr": "certificate_labels{datacenter=~\"$Datacenter\", cluster=~\"$Cluster\"}",
"expr": "security_certificate_labels{datacenter=~\"$Datacenter\", cluster=~\"$Cluster\"}",
"format": "table",
"hide": false,
"instant": true,
"interval": "",
"legendFormat": "",
"refId": "A"
},
{
"datasource": "${DS_PROMETHEUS}",
"exemplar": false,
"expr": "security_certificate_expiry_time{datacenter=~\"$Datacenter\", cluster=~\"$Cluster\"}-time()",
"format": "table",
"hide": false,
"instant": true,
"interval": "",
"legendFormat": "",
"refId": "B"
}
],
"title": "SSL Certificates Expiration",
"transformations": [
{
"id": "seriesToColumns",
"options": {
"byField": "expiry_time"
}
},
{
"id": "filterFieldsByName",
"options": {
"include": {
"names": [
"cluster",
"expiry_time",
"name",
"scope",
"svm",
"type"
"type",
"Value #B"
]
}
}
Expand All @@ -2055,18 +2117,21 @@
{
"id": "organize",
"options": {
"excludeByName": {},
"excludeByName": {
"Value #B": false
},
"includeByName": {},
"indexByName": {
"Expiry Date": 5,
"cluster": 0,
"expiry_time": 6,
"name": 2,
"scope": 4,
"svm": 1,
"type": 3
"Expiry Date": 3,
"Value #B": 4,
"expiry_time": 5,
"scope": 2,
"svm": 0,
"type": 1
},
"renameByName": {
"Expiry Date": "",
"Value #B": "Expiry",
"expiry_time": "Expires In",
"name": "Certificate Name",
"scope": "Scope",
Expand Down Expand Up @@ -3764,7 +3829,7 @@
},
{
"exemplar": false,
"expr": "security_certificate_labels{datacenter=~\"$Datacenter\",cluster=~\"$Cluster\"}",
"expr": "security_certificate_labels{datacenter=~\"$Datacenter\",cluster=~\"$Cluster\",certificateExpiryStatus!=\"\",certificateIssuerType!=\"\"}",
"format": "table",
"hide": false,
"instant": true,
Expand Down

0 comments on commit 75352c9

Please sign in to comment.