diff --git a/charts/grafana/Chart.yaml b/charts/grafana/Chart.yaml index 206db255..fb66e4e5 100644 --- a/charts/grafana/Chart.yaml +++ b/charts/grafana/Chart.yaml @@ -19,4 +19,4 @@ name: grafana sources: - https://github.com/grafana/grafana type: application -version: 6.26.12 +version: 6.26.13 diff --git a/charts/grafana/dashboards/plugins-dashboard.json b/charts/grafana/dashboards/plugins-dashboard.json index 81c3fe2c..c96531bf 100644 --- a/charts/grafana/dashboards/plugins-dashboard.json +++ b/charts/grafana/dashboards/plugins-dashboard.json @@ -21,7 +21,7 @@ "editable": true, "fiscalYearStartMonth": 0, "graphTooltip": 0, - "id": 1, + "id": 8, "links": [], "liveNow": false, "panels": [ @@ -29,7 +29,7 @@ "datasource": { "type": "vertamedia-clickhouse-datasource" }, - "description": "This panel displays all the resources from the cluster", + "description": "This panel displays the access rights for the current user and all server resources.", "fieldConfig": { "defaults": { "color": { @@ -64,7 +64,7 @@ "x": 0, "y": 0 }, - "id": 8, + "id": 10, "options": { "footer": { "fields": "", @@ -86,14 +86,14 @@ "format": "table", "formattedQuery": "SELECT $timeSeries as t, count() FROM $table WHERE $timeFilter GROUP BY t ORDER BY t", "intervalFactor": 1, - "query": "select * from default.getall_resources\n", - "rawQuery": "select * from default.getall_resources", + "query": "SELECT * FROM default.rakkess", + "rawQuery": "SELECT * FROM default.rakkess", "refId": "A", "round": "0s", "skip_comments": true } ], - "title": "kubernetes_resources", + "title": "Rakkess Access Matrix", "transparent": true, "type": "table" }, @@ -101,7 +101,7 @@ "datasource": { "type": "vertamedia-clickhouse-datasource" }, - "description": "This panel displays all the out-off-date images from the cluster", + "description": "This panel displays all the kubernetes resources from the cluster", "fieldConfig": { "defaults": { "color": { @@ -131,11 +131,83 @@ "overrides": [] }, "gridPos": { - "h": 7, + "h": 8, "w": 24, "x": 0, "y": 8 }, + "id": 8, + "options": { + "footer": { + "fields": "", + "reducer": [ + "sum" + ], + "show": false + }, + "showHeader": true + }, + "pluginVersion": "9.3.2", + "targets": [ + { + "datasource": { + "type": "vertamedia-clickhouse-datasource" + }, + "dateTimeType": "DATETIME", + "extrapolate": true, + "format": "table", + "formattedQuery": "SELECT $timeSeries as t, count() FROM $table WHERE $timeFilter GROUP BY t ORDER BY t", + "intervalFactor": 1, + "query": "SELECT * FROM default.getall_resources", + "rawQuery": "SELECT * FROM default.getall_resources", + "refId": "A", + "round": "0s", + "skip_comments": true + } + ], + "title": "Kubernetes Resources", + "transparent": true, + "type": "table" + }, + { + "datasource": { + "type": "vertamedia-clickhouse-datasource" + }, + "description": "This panel displays the out-off-date images from the cluster.", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "custom": { + "align": "center", + "displayMode": "color-text", + "filterable": true, + "inspect": false + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 10 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 9, + "w": 24, + "x": 0, + "y": 16 + }, "id": 6, "options": { "footer": { @@ -158,14 +230,14 @@ "format": "table", "formattedQuery": "SELECT $timeSeries as t, count() FROM $table WHERE $timeFilter GROUP BY t ORDER BY t", "intervalFactor": 1, - "query": "select * from default.outdated_images\n\n", - "rawQuery": "select * from default.outdated_images", + "query": "SELECT * FROM default.outdated_images\nWHERE Versions_Behind > 0", + "rawQuery": "SELECT * FROM default.outdated_images\nWHERE Versions_Behind > 0", "refId": "A", "round": "0s", "skip_comments": true } ], - "title": "outdated_images", + "title": "Outdated Images", "transparent": true, "type": "table" }, @@ -173,7 +245,7 @@ "datasource": { "type": "vertamedia-clickhouse-datasource" }, - "description": "This panel displays all the Deleted APIs from the cluster", + "description": "This panel displays all the deleted APIs from the cluster", "fieldConfig": { "defaults": { "color": { @@ -203,10 +275,10 @@ "overrides": [] }, "gridPos": { - "h": 7, + "h": 8, "w": 24, "x": 0, - "y": 15 + "y": 25 }, "id": 4, "options": { @@ -230,8 +302,8 @@ "format": "table", "formattedQuery": "SELECT $timeSeries as t, count() FROM $table WHERE $timeFilter GROUP BY t ORDER BY t", "intervalFactor": 1, - "query": "select * from default.DeletedAPIs\n", - "rawQuery": "select * from default.DeletedAPIs", + "query": "SELECT * FROM default.DeletedAPIs", + "rawQuery": "SELECT * FROM default.DeletedAPIs", "refId": "A", "round": "0s", "skip_comments": true @@ -245,7 +317,7 @@ "datasource": { "type": "vertamedia-clickhouse-datasource" }, - "description": "This panel displays all the Deprecated APIs from the cluster", + "description": "This panel displays all the deprecatedAPIs from the cluster", "fieldConfig": { "defaults": { "color": { @@ -262,7 +334,8 @@ "mode": "absolute", "steps": [ { - "color": "green" + "color": "green", + "value": null }, { "color": "red", @@ -274,10 +347,10 @@ "overrides": [] }, "gridPos": { - "h": 8, + "h": 7, "w": 24, "x": 0, - "y": 22 + "y": 33 }, "id": 2, "options": { @@ -301,8 +374,8 @@ "format": "table", "formattedQuery": "SELECT $timeSeries as t, count() FROM $table WHERE $timeFilter GROUP BY t ORDER BY t", "intervalFactor": 1, - "query": "select * from default.DeprecatedAPIs\n", - "rawQuery": "select * from default.DeprecatedAPIs", + "query": "SELECT * FROM default.DeprecatedAPIs", + "rawQuery": "SELECT * FROM default.DeprecatedAPIs", "refId": "A", "round": "0s", "skip_comments": true @@ -325,8 +398,8 @@ }, "timepicker": {}, "timezone": "", - "title": "k8s-plugins", - "uid": "K-QBkXw4k", - "version": 18, + "title": "Kubviz Plugins", + "uid": "wyP_aLl4z", + "version": 2, "weekStart": "" } \ No newline at end of file diff --git a/clickhouse/clickhouse_client.go b/clickhouse/clickhouse_client.go index a2809d08..c981bdbe 100644 --- a/clickhouse/clickhouse_client.go +++ b/clickhouse/clickhouse_client.go @@ -54,13 +54,13 @@ func CreateSchema(connect *sql.DB) { } func CreateRakeesMetricsSchema(connect *sql.DB) { _, err := connect.Exec(` - CREATE TABLE IF NOT EXISTS rakees ( - name String, - create String, - delete String, - list String, - update String, - cluster_name String + CREATE TABLE IF NOT EXISTS rakkess ( + ClusterName String, + Name String, + Create String, + Delete String, + List String, + Update String ) engine=File(TabSeparated) `) if err != nil { @@ -71,10 +71,10 @@ func CreateRakeesMetricsSchema(connect *sql.DB) { func CreateKubePugSchema(connect *sql.DB) { _, err := connect.Exec(` CREATE TABLE IF NOT EXISTS DeprecatedAPIs ( + ClusterName String, Description String, Kind String, Deprecated UInt8, - ClusterName String, Scope String, ObjectName String ) engine=File(TabSeparated) @@ -85,12 +85,12 @@ func CreateKubePugSchema(connect *sql.DB) { _, err = connect.Exec(` CREATE TABLE IF NOT EXISTS DeletedAPIs ( + ClusterName String, Group String, Kind String, Version String, Name String, Deleted UInt8, - ClusterName String, Scope String, ObjectName String ) engine=File(TabSeparated) @@ -103,11 +103,11 @@ func CreateKubePugSchema(connect *sql.DB) { func CreateKetallSchema(connect *sql.DB) { _, err := connect.Exec(` CREATE TABLE IF NOT EXISTS getall_resources ( - resource String, - kind String, - namespace String, - age String, - cluster_name String + Cluster_Name String, + Namespace String, + Kind String, + Resource String, + Age String ) engine=File(TabSeparated) `) if err != nil { @@ -118,13 +118,13 @@ func CreateKetallSchema(connect *sql.DB) { func CreateOutdatedSchema(connect *sql.DB) { _, err := connect.Exec(` CREATE TABLE IF NOT EXISTS outdated_images ( - current_image String, - current_tag String, - latest_version String, - versions_behind Int64, - pod String, - namespace String, - cluster_name String + Cluster_Name String, + Namespace String, + Pod String, + Current_Image String, + Current_Tag String, + Latest_Version String, + Versions_Behind Int64 ) engine=File(TabSeparated) `) if err != nil { @@ -134,16 +134,16 @@ func CreateOutdatedSchema(connect *sql.DB) { func InsertRakeesMetrics(connect *sql.DB, metrics model.RakeesMetrics) { var ( tx, _ = connect.Begin() - stmt, _ = tx.Prepare("INSERT INTO rakees (name, create, delete, list, update, cluster_name) VALUES (?, ?, ?, ?, ?, ?)") + stmt, _ = tx.Prepare("INSERT INTO rakkess (ClusterName, Name, Create, Delete, List, Update) VALUES (?, ?, ?, ?, ?, ?)") ) defer stmt.Close() if _, err := stmt.Exec( + metrics.ClusterName, metrics.Name, metrics.Create, metrics.Delete, metrics.List, metrics.Update, - metrics.ClusterName, ); err != nil { log.Fatal(err) } @@ -155,15 +155,15 @@ func InsertRakeesMetrics(connect *sql.DB, metrics model.RakeesMetrics) { func InsertKetallEvent(connect *sql.DB, metrics model.Resource) { var ( tx, _ = connect.Begin() - stmt, _ = tx.Prepare("INSERT INTO getall_resources (resource, kind, namespace, age, cluster_name) VALUES (?, ?, ?, ?, ?)") + stmt, _ = tx.Prepare("INSERT INTO getall_resources (Cluster_Name, Namespace, Kind, Resource, Age) VALUES (?, ?, ?, ?, ?)") ) defer stmt.Close() if _, err := stmt.Exec( - metrics.Resource, - metrics.Kind, + metrics.ClusterName, metrics.Namespace, + metrics.Kind, + metrics.Resource, metrics.Age, - metrics.ClusterName, ); err != nil { log.Fatal(err) } @@ -175,17 +175,17 @@ func InsertKetallEvent(connect *sql.DB, metrics model.Resource) { func InsertOutdatedEvent(connect *sql.DB, metrics model.CheckResultfinal) { var ( tx, _ = connect.Begin() - stmt, _ = tx.Prepare("INSERT INTO outdated_images (current_image, current_tag, latest_version, versions_behind, pod, namespace, cluster_name) VALUES (?, ?, ?, ?, ?, ?, ?)") + stmt, _ = tx.Prepare("INSERT INTO outdated_images (Cluster_Name, Namespace, Pod, Current_Image, Current_Tag, Latest_Version, Versions_Behind) VALUES (?, ?, ?, ?, ?, ?, ?)") ) defer stmt.Close() if _, err := stmt.Exec( + metrics.ClusterName, + metrics.Namespace, + metrics.Pod, metrics.Image, metrics.Current, metrics.LatestVersion, metrics.VersionsBehind, - metrics.Pod, - metrics.Namespace, - metrics.ClusterName, ); err != nil { log.Fatal(err) } @@ -197,7 +197,7 @@ func InsertOutdatedEvent(connect *sql.DB, metrics model.CheckResultfinal) { func InsertDeprecatedAPI(connect *sql.DB, deprecatedAPI model.DeprecatedAPI) { var ( tx, _ = connect.Begin() - stmt, _ = tx.Prepare("INSERT INTO DeprecatedAPIs (Description, Kind, Deprecated, ClusterName, Scope, ObjectName) VALUES (?, ?, ?, ?, ?, ?)") + stmt, _ = tx.Prepare("INSERT INTO DeprecatedAPIs (ClusterName, Description, Kind, Deprecated, Scope, ObjectName) VALUES (?, ?, ?, ?, ?, ?)") ) defer stmt.Close() @@ -208,10 +208,10 @@ func InsertDeprecatedAPI(connect *sql.DB, deprecatedAPI model.DeprecatedAPI) { for _, item := range deprecatedAPI.Items { if _, err := stmt.Exec( + deprecatedAPI.ClusterName, deprecatedAPI.Description, deprecatedAPI.Kind, deprecated, - deprecatedAPI.ClusterName, item.Scope, item.ObjectName, ); err != nil { @@ -227,7 +227,7 @@ func InsertDeprecatedAPI(connect *sql.DB, deprecatedAPI model.DeprecatedAPI) { func InsertDeletedAPI(connect *sql.DB, deletedAPI model.DeletedAPI) { var ( tx, _ = connect.Begin() - stmt, _ = tx.Prepare("INSERT INTO DeletedAPIs (Group, Kind, Version, Name, Deleted, ClusterName, Scope, ObjectName) VALUES (?, ?, ?, ?, ?, ?, ?, ?)") + stmt, _ = tx.Prepare("INSERT INTO DeletedAPIs (ClusterName, Group, Kind, Version, Name, Deleted, Scope, ObjectName) VALUES (?, ?, ?, ?, ?, ?, ?, ?)") ) defer stmt.Close() @@ -238,12 +238,12 @@ func InsertDeletedAPI(connect *sql.DB, deletedAPI model.DeletedAPI) { for _, item := range deletedAPI.Items { if _, err := stmt.Exec( + deletedAPI.ClusterName, deletedAPI.Group, deletedAPI.Kind, deletedAPI.Version, deletedAPI.Name, deleted, - deletedAPI.ClusterName, item.Scope, item.ObjectName, ); err != nil { @@ -286,7 +286,7 @@ func InsertEvent(connect *sql.DB, metrics model.Metrics) { } func RetriveKetallEvent(connect *sql.DB) ([]model.Resource, error) { - rows, err := connect.Query("SELECT resource, kind, namespace, age, cluster_name FROM getall_resources") + rows, err := connect.Query("SELECT Cluster_Name, Namespace, Kind, Resource, Age FROM getall_resources") if err != nil { log.Printf("Error: %s", err) return nil, err @@ -295,7 +295,7 @@ func RetriveKetallEvent(connect *sql.DB) ([]model.Resource, error) { var events []model.Resource for rows.Next() { var result model.Resource - if err := rows.Scan(&result.Resource, &result.Kind, &result.Namespace, &result.Age, &result.ClusterName); err != nil { + if err := rows.Scan(&result.ClusterName, &result.Namespace, &result.Kind, &result.Resource, &result.Age); err != nil { log.Printf("Error: %s", err) return nil, err } @@ -309,7 +309,7 @@ func RetriveKetallEvent(connect *sql.DB) ([]model.Resource, error) { } func RetriveOutdatedEvent(connect *sql.DB) ([]model.CheckResultfinal, error) { - rows, err := connect.Query("SELECT current_image, current_tag, latest_version, versions_behind, pod, namespace, cluster_name FROM outdated_images") + rows, err := connect.Query("SELECT Cluster_Name, Namespace, Pod, Current_Image, Current_Tag, Latest_Version, Versions_Behind FROM outdated_images") if err != nil { log.Printf("Error: %s", err) return nil, err @@ -318,7 +318,7 @@ func RetriveOutdatedEvent(connect *sql.DB) ([]model.CheckResultfinal, error) { var events []model.CheckResultfinal for rows.Next() { var result model.CheckResultfinal - if err := rows.Scan(&result.Image, &result.Current, &result.LatestVersion, &result.VersionsBehind, &result.Pod, &result.Namespace, &result.ClusterName); err != nil { + if err := rows.Scan(&result.ClusterName, &result.Namespace, &result.Pod, &result.Image, &result.Current, &result.LatestVersion, &result.VersionsBehind); err != nil { log.Printf("Error: %s", err) return nil, err }