diff --git a/core/redis-smart-cache-jdbc/src/main/java/com/redis/smartcache/core/Query.java b/core/redis-smart-cache-jdbc/src/main/java/com/redis/smartcache/core/Query.java index 6227257..169dc61 100644 --- a/core/redis-smart-cache-jdbc/src/main/java/com/redis/smartcache/core/Query.java +++ b/core/redis-smart-cache-jdbc/src/main/java/com/redis/smartcache/core/Query.java @@ -1,7 +1,5 @@ package com.redis.smartcache.core; -import io.micrometer.core.instrument.Counter; -import io.micrometer.core.instrument.Timer; import io.trino.sql.tree.Statement; public class Query { @@ -12,49 +10,12 @@ public class Query { private final String id; private final String sql; private final Statement statement; - private final Timer timer; - private final Timer backendTimer; - private final Timer cacheGetTimer; - private final Timer cachePutTimer; - private final Counter cacheHitCounter; - private final Counter cacheMissCounter; private long ttl = TTL_NO_CACHING; - public Query(String id, String sql, Statement statement, Timer timer, Timer backendTimer, Timer cacheGetTimer, - Timer cachePutTimer, Counter cacheHitCounter, Counter cacheMissCounter) { + public Query(String id, String sql, Statement statement) { this.id = id; this.sql = sql; this.statement = statement; - this.timer = timer; - this.backendTimer = backendTimer; - this.cacheGetTimer = cacheGetTimer; - this.cachePutTimer = cachePutTimer; - this.cacheHitCounter = cacheHitCounter; - this.cacheMissCounter = cacheMissCounter; - } - - public Counter getCacheHitCounter() { - return cacheHitCounter; - } - - public Counter getCacheMissCounter() { - return cacheMissCounter; - } - - public Timer getTimer() { - return timer; - } - - public Timer getBackendTimer() { - return backendTimer; - } - - public Timer getCacheGetTimer() { - return cacheGetTimer; - } - - public Timer getCachePutTimer() { - return cachePutTimer; } public boolean hasStatement() { diff --git a/core/redis-smart-cache-jdbc/src/main/java/com/redis/smartcache/jdbc/SmartConnection.java b/core/redis-smart-cache-jdbc/src/main/java/com/redis/smartcache/jdbc/SmartConnection.java index 398af52..821221c 100644 --- a/core/redis-smart-cache-jdbc/src/main/java/com/redis/smartcache/jdbc/SmartConnection.java +++ b/core/redis-smart-cache-jdbc/src/main/java/com/redis/smartcache/jdbc/SmartConnection.java @@ -31,6 +31,7 @@ import io.micrometer.core.instrument.Counter; import io.micrometer.core.instrument.MeterRegistry; +import io.micrometer.core.instrument.Tags; import io.micrometer.core.instrument.Timer; import io.trino.sql.parser.ParsingException; import io.trino.sql.parser.ParsingOptions; @@ -360,17 +361,58 @@ public Query getQuery(String sql) { if (queryCache.containsKey(id)) { return queryCache.get(id); } - return new Query(id, sql, parse(sql), timer(METER_QUERY, id), timer(METER_BACKEND, id), - timer(METER_CACHE_GET, id), timer(METER_CACHE_PUT, id), - counter(METER_CACHE_GET, id, TAG_RESULT, TAG_HIT), counter(METER_CACHE_GET, id, TAG_RESULT, TAG_MISS)); + Query query = new Query(id, sql, parse(sql)); + createTimer(METER_QUERY, query); + createTimer(METER_BACKEND, query); + createTimer(METER_CACHE_GET, query); + createTimer(METER_CACHE_PUT, query); + createCounter(METER_CACHE_GET, query, TAG_RESULT, TAG_HIT); + createCounter(METER_CACHE_GET, query, TAG_RESULT, TAG_MISS); + return query; + } + + public Timer getQueryTimer(Query query) { + return getTimer(METER_QUERY, query); + } + + public Timer getBackendTimer(Query query) { + return getTimer(METER_BACKEND, query); + } + + public Timer getCacheGetTimer(Query query) { + return getTimer(METER_CACHE_GET, query); + } + + public Timer getCachePutTimer(Query query) { + return getTimer(METER_CACHE_PUT, query); + } + + public Counter getCacheHitCounter(Query query) { + return getCounter(METER_CACHE_GET, query, TAG_RESULT, TAG_HIT); + } + + public Counter getCacheMissCounter(Query query) { + return getCounter(METER_CACHE_GET, query, TAG_RESULT, TAG_MISS); + } + + private Counter getCounter(String name, Query query, String... tags) { + return meterRegistry.get(name).tags(tags(query)).tags(tags).counter(); + } + + private Timer getTimer(String name, Query query) { + return meterRegistry.get(name).tags(tags(query)).timer(); + } + + private Timer createTimer(String name, Query query) { + return Timer.builder(name).tags(tags(query)).publishPercentiles(0.9, 0.99).register(meterRegistry); } - private Timer timer(String name, String queryId) { - return Timer.builder(name).tag(TAG_QUERY, queryId).publishPercentiles(0.9, 0.99).register(meterRegistry); + private Tags tags(Query query) { + return Tags.of(TAG_QUERY, query.getId()); } - private Counter counter(String name, String queryId, String... tags) { - return Counter.builder(name).tag(TAG_QUERY, queryId).tags(tags).register(meterRegistry); + private Counter createCounter(String name, Query query, String... tags) { + return Counter.builder(name).tags(tags(query)).tags(tags).register(meterRegistry); } private io.trino.sql.tree.Statement parse(String sql) { diff --git a/core/redis-smart-cache-jdbc/src/main/java/com/redis/smartcache/jdbc/SmartStatement.java b/core/redis-smart-cache-jdbc/src/main/java/com/redis/smartcache/jdbc/SmartStatement.java index 8b70da1..cd9d1e6 100644 --- a/core/redis-smart-cache-jdbc/src/main/java/com/redis/smartcache/jdbc/SmartStatement.java +++ b/core/redis-smart-cache-jdbc/src/main/java/com/redis/smartcache/jdbc/SmartStatement.java @@ -48,12 +48,12 @@ protected String id(Query query) { protected boolean execute(String sql, Callable executable) throws SQLException { Query query = connection.fireRules(sql); try { - return query.getTimer().recordCallable(() -> { + return connection.getQueryTimer(query).recordCallable(() -> { queryExecution = getCachedExecution(query); if (queryExecution.hasResultSet()) { return true; } - return query.getBackendTimer().recordCallable(executable); + return connection.getBackendTimer(query).recordCallable(executable); }); } catch (SQLException e) { throw e; @@ -65,12 +65,12 @@ protected boolean execute(String sql, Callable executable) throws SQLEx protected ResultSet executeQuery(String sql, Callable callable) throws SQLException { Query query = connection.fireRules(sql); try { - return query.getTimer().recordCallable(() -> { + return connection.getQueryTimer(query).recordCallable(() -> { QueryExecution execution = getCachedExecution(query); if (execution.hasResultSet()) { return execution.getResultSet(); } - return cacheResultSet(execution.getQuery(), query.getBackendTimer().recordCallable(callable)); + return cacheResultSet(execution.getQuery(), connection.getBackendTimer(query).recordCallable(callable)); }); } catch (SQLException e) { throw e; @@ -90,7 +90,7 @@ private ResultSet cacheResultSet(Query query, ResultSet resultSet) throws SQLExc CachedRowSet cachedRowSet = connection.createCachedRowSet(); cachedRowSet.populate(resultSet); cachedRowSet.beforeFirst(); - query.getCachePutTimer() + connection.getCachePutTimer(query) .record(() -> connection.getResultSetCache().put(id(query), query.getTtl(), cachedRowSet)); cachedRowSet.beforeFirst(); return cachedRowSet; @@ -128,12 +128,12 @@ public ResultSet getResultSet() { private QueryExecution getCachedExecution(Query query) throws Exception { if (query.isCaching()) { - ResultSet resultSet = query.getCacheGetTimer() + ResultSet resultSet = connection.getCacheGetTimer(query) .recordCallable(() -> connection.getResultSetCache().get(id(query))); if (resultSet == null) { - query.getCacheMissCounter().increment(); + connection.getCacheMissCounter(query).increment(); } else { - query.getCacheHitCounter().increment(); + connection.getCacheHitCounter(query).increment(); } return new QueryExecution(query, resultSet); } diff --git a/core/redis-smart-cache-jdbc/src/test/java/com/redis/smartcache/RulesTests.java b/core/redis-smart-cache-jdbc/src/test/java/com/redis/smartcache/RulesTests.java index eada703..39dbe56 100644 --- a/core/redis-smart-cache-jdbc/src/test/java/com/redis/smartcache/RulesTests.java +++ b/core/redis-smart-cache-jdbc/src/test/java/com/redis/smartcache/RulesTests.java @@ -77,8 +77,7 @@ void testRegex() { } private Query query(String sql) { - return new Query(SmartConnection.crc32(sql), sql, PARSER.createStatement(sql, PARSING_OPTIONS), null, null, - null, null, null, null); + return new Query(SmartConnection.crc32(sql), sql, PARSER.createStatement(sql, PARSING_OPTIONS)); } } diff --git a/demo/redis-smart-cache-demo/grafana/dashboard.json b/demo/redis-smart-cache-demo/grafana/dashboard.json index 00822c4..4d0053e 100644 --- a/demo/redis-smart-cache-demo/grafana/dashboard.json +++ b/demo/redis-smart-cache-demo/grafana/dashboard.json @@ -23,6 +23,12 @@ "name": "Redis", "version": "2.1.1" }, + { + "type": "panel", + "id": "redis-latency-panel", + "name": "Redis Latency", + "version": "" + }, { "type": "panel", "id": "stat", @@ -66,19 +72,6 @@ "links": [], "liveNow": false, "panels": [ - { - "collapsed": false, - "gridPos": { - "h": 1, - "w": 24, - "x": 0, - "y": 0 - }, - "id": 23, - "panels": [], - "title": "Query Latency", - "type": "row" - }, { "datasource": { "type": "redis-datasource", @@ -126,24 +119,24 @@ "mode": "absolute", "steps": [ { - "color": "green", + "color": "red", "value": null }, - { - "color": "yellow", - "value": 10 - }, { "color": "orange", "value": 100 }, { - "color": "red", + "color": "#EAB839", "value": 1000 + }, + { + "color": "green", + "value": 3000 } ] }, - "unit": "ms" + "unit": "ops" }, "overrides": [] }, @@ -151,7 +144,7 @@ "h": 6, "w": 12, "x": 0, - "y": 1 + "y": 0 }, "id": 6, "options": { @@ -168,20 +161,21 @@ }, "targets": [ { - "aggregation": "avg", + "aggregation": "sum", "bucket": 1000, "command": "ts.mrange", "datasource": { "type": "redis-datasource", "uid": "${DS_REDIS}" }, - "filter": "name=query stat=mean", + "filter": "name=query stat=count", "keyName": "smartcache:metrics:query:mean", "query": "", "refId": "A", "type": "timeSeries" } ], + "title": "Query Throughput", "type": "timeseries" }, { @@ -221,7 +215,7 @@ "h": 6, "w": 6, "x": 12, - "y": 1 + "y": 0 }, "id": 2, "options": { @@ -298,7 +292,7 @@ "h": 6, "w": 6, "x": 18, - "y": 1 + "y": 0 }, "id": 15, "options": { @@ -334,24 +328,12 @@ ], "type": "stat" }, - { - "collapsed": false, - "gridPos": { - "h": 1, - "w": 24, - "x": 0, - "y": 7 - }, - "id": 27, - "panels": [], - "title": "Cache Throughput", - "type": "row" - }, { "datasource": { "type": "redis-datasource", "uid": "${DS_REDIS}" }, + "description": "", "fieldConfig": { "defaults": { "color": { @@ -387,7 +369,7 @@ "mode": "off" } }, - "displayName": "Throughput", + "displayName": "Query Latency", "mappings": [], "thresholds": { "mode": "absolute", @@ -406,9 +388,9 @@ "h": 6, "w": 12, "x": 0, - "y": 8 + "y": 6 }, - "id": 4, + "id": 43, "options": { "legend": { "calcs": [], @@ -431,12 +413,13 @@ "uid": "${DS_REDIS}" }, "filter": "name=cache.get stat=count", - "keyName": "smartcache:metrics:cache:get:count", + "keyName": "smartcache:metrics:query:mean", "query": "", "refId": "A", "type": "timeSeries" } ], + "title": "Cache Throughput", "type": "timeseries" }, { @@ -444,24 +427,35 @@ "type": "redis-datasource", "uid": "${DS_REDIS}" }, - "description": "", "fieldConfig": { "defaults": { "color": { "mode": "thresholds" }, - "displayName": "Cache Hit", + "displayName": "Cache Get Mean Latency", "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { - "color": "blue", + "color": "green", "value": null + }, + { + "color": "yellow", + "value": 3 + }, + { + "color": "orange", + "value": 5 + }, + { + "color": "red", + "value": 10 } ] }, - "unit": "ops" + "unit": "ms" }, "overrides": [] }, @@ -469,9 +463,9 @@ "h": 6, "w": 6, "x": 12, - "y": 8 + "y": 6 }, - "id": 8, + "id": 11, "options": { "colorMode": "background", "graphMode": "area", @@ -484,7 +478,7 @@ "fields": "", "values": false }, - "textMode": "auto" + "textMode": "value_and_name" }, "pluginVersion": "9.3.2", "targets": [ @@ -496,8 +490,8 @@ "type": "redis-datasource", "uid": "${DS_REDIS}" }, - "filter": "name=cache.get result=hit", - "keyName": "smartcache:metrics:cache:get:result:hit", + "filter": "name=cache.get stat=mean", + "keyName": "smartcache:metrics:cache:get:mean", "query": "", "refId": "A", "type": "timeSeries" @@ -510,36 +504,35 @@ "type": "redis-datasource", "uid": "${DS_REDIS}" }, - "description": "", "fieldConfig": { "defaults": { "color": { "mode": "thresholds" }, - "displayName": "Cache Miss", + "displayName": "Cache Get P99 Latency", "mappings": [], "thresholds": { - "mode": "percentage", + "mode": "absolute", "steps": [ { "color": "green", "value": null }, { - "color": "#EAB839", - "value": 1 + "color": "yellow", + "value": 10 }, { "color": "orange", - "value": 10 + "value": 100 }, { "color": "red", - "value": 20 + "value": 1000 } ] }, - "unit": "ops" + "unit": "ms" }, "overrides": [] }, @@ -547,9 +540,9 @@ "h": 6, "w": 6, "x": 18, - "y": 8 + "y": 6 }, - "id": 9, + "id": 16, "options": { "colorMode": "background", "graphMode": "area", @@ -562,7 +555,7 @@ "fields": "", "values": false }, - "textMode": "auto" + "textMode": "value_and_name" }, "pluginVersion": "9.3.2", "targets": [ @@ -574,8 +567,8 @@ "type": "redis-datasource", "uid": "${DS_REDIS}" }, - "filter": "name=cache.get result=miss", - "keyName": "smartcache:metrics:cache:get:result:miss", + "filter": "name=cache.get quantile=0.99", + "keyName": "smartcache:metrics:cache:get:quantile:0.99", "query": "", "refId": "A", "type": "timeSeries" @@ -584,17 +577,24 @@ "type": "stat" }, { - "collapsed": false, + "datasource": { + "type": "redis-datasource", + "uid": "${DS_REDIS}" + }, "gridPos": { - "h": 1, - "w": 24, + "h": 15, + "w": 12, "x": 0, - "y": 14 + "y": 12 + }, + "id": 38, + "options": { + "hideZero": true, + "interval": 1000, + "maxItemsPerSeries": 300, + "viewMode": "Table" }, - "id": 35, - "panels": [], - "title": "Backend Throughput", - "type": "row" + "type": "redis-latency-panel" }, { "datasource": { @@ -606,121 +606,117 @@ "color": { "mode": "thresholds" }, - "custom": { - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 50, - "gradientMode": "scheme", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "auto", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "displayName": "Backend Throughput", + "displayName": "Backend Mean Latency", "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { - "color": "blue", + "color": "green", "value": null + }, + { + "color": "yellow", + "value": 500 + }, + { + "color": "#EAB839", + "value": 1000 + }, + { + "color": "red", + "value": 10000 } ] }, - "unit": "ops" + "unit": "ms" }, "overrides": [] }, "gridPos": { - "h": 6, - "w": 12, - "x": 0, - "y": 15 + "h": 5, + "w": 6, + "x": 12, + "y": 12 }, - "id": 36, + "id": 32, "options": { - "legend": { - "calcs": [], - "displayMode": "list", - "placement": "bottom", - "showLegend": false + "colorMode": "background", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false }, - "tooltip": { - "mode": "single", - "sort": "none" - } + "textMode": "value_and_name" }, + "pluginVersion": "9.3.2", "targets": [ { - "aggregation": "sum", + "aggregation": "avg", "bucket": 1000, "command": "ts.mrange", "datasource": { "type": "redis-datasource", "uid": "${DS_REDIS}" }, - "filter": "name=backend stat=count", - "keyName": "smartcache:metrics:db:count", + "filter": "name=backend stat=mean", + "keyName": "smartcache:metrics:db:mean", "query": "", "refId": "A", "type": "timeSeries" } ], - "type": "timeseries" + "type": "stat" }, { "datasource": { "type": "redis-datasource", "uid": "${DS_REDIS}" }, - "description": "", "fieldConfig": { "defaults": { "color": { "mode": "thresholds" }, - "displayName": "Backend Throughput", + "displayName": "Backend P99 Latency", "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { - "color": "blue", + "color": "green", "value": null + }, + { + "color": "#EAB839", + "value": 500 + }, + { + "color": "orange", + "value": 1000 + }, + { + "color": "red", + "value": 10000 } ] }, - "unit": "ops" + "unit": "ms" }, "overrides": [] }, "gridPos": { - "h": 6, + "h": 5, "w": 6, - "x": 12, - "y": 15 + "x": 18, + "y": 12 }, - "id": 37, + "id": 33, "options": { "colorMode": "background", "graphMode": "area", @@ -745,8 +741,8 @@ "type": "redis-datasource", "uid": "${DS_REDIS}" }, - "filter": "name=backend stat=count", - "keyName": "smartcache:metrics:db:count", + "filter": "name=backend quantile=0.99", + "keyName": "smartcache:metrics:db:quantile:0.99", "query": "", "refId": "A", "type": "timeSeries" @@ -759,34 +755,45 @@ "type": "redis-datasource", "uid": "${DS_REDIS}" }, - "description": "", "fieldConfig": { "defaults": { "color": { "mode": "thresholds" }, - "displayName": "Query Throughput", + "displayName": "Cache Put Mean Latency", "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { - "color": "blue", + "color": "green", "value": null + }, + { + "color": "yellow", + "value": 3 + }, + { + "color": "orange", + "value": 5 + }, + { + "color": "red", + "value": 10 } ] }, - "unit": "ops" + "unit": "ms" }, "overrides": [] }, "gridPos": { - "h": 6, + "h": 5, "w": 6, - "x": 18, - "y": 15 + "x": 12, + "y": 17 }, - "id": 38, + "id": 14, "options": { "colorMode": "background", "graphMode": "area", @@ -811,8 +818,8 @@ "type": "redis-datasource", "uid": "${DS_REDIS}" }, - "filter": "name=query stat=count", - "keyName": "smartcache:metrics:query:count", + "filter": "name=cache.put stat=mean", + "keyName": "smartcache:metrics:cache:put:mean", "query": "", "refId": "A", "type": "timeSeries" @@ -821,514 +828,49 @@ "type": "stat" }, { - "collapsed": true, - "gridPos": { - "h": 1, - "w": 24, - "x": 0, - "y": 21 + "datasource": { + "type": "redis-datasource", + "uid": "${DS_REDIS}" }, - "id": 31, - "panels": [ - { - "datasource": { - "type": "redis-datasource", - "uid": "${DS_REDIS}" + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" }, - "description": "", - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" + "displayName": "Cache Put P99 Latency", + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null }, - "custom": { - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 50, - "gradientMode": "scheme", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "auto", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "off" - } + { + "color": "yellow", + "value": 1 }, - "displayName": "Backend Latency", - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green" - }, - { - "color": "yellow", - "value": 500 - }, - { - "color": "red", - "value": 10000 - }, - { - "color": "orange", - "value": 10000 - } - ] + { + "color": "orange", + "value": 3 }, - "unit": "ms" - }, - "overrides": [] - }, - "gridPos": { - "h": 6, - "w": 12, - "x": 0, - "y": 22 - }, - "id": 29, - "options": { - "legend": { - "calcs": [], - "displayMode": "list", - "placement": "bottom", - "showLegend": false - }, - "tooltip": { - "mode": "single", - "sort": "none" - } + { + "color": "red", + "value": 10 + } + ] }, - "targets": [ - { - "aggregation": "avg", - "bucket": 1000, - "command": "ts.mrange", - "datasource": { - "type": "redis-datasource", - "uid": "${DS_REDIS}" - }, - "filter": "name=backend stat=mean", - "keyName": "smartcache:metrics:db:mean", - "query": "", - "refId": "A", - "type": "timeSeries" - } - ], - "type": "timeseries" - }, - { - "datasource": { - "type": "redis-datasource", - "uid": "${DS_REDIS}" - }, - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "displayName": "Backend Mean Latency", - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green" - }, - { - "color": "yellow", - "value": 500 - }, - { - "color": "#EAB839", - "value": 1000 - }, - { - "color": "red", - "value": 10000 - } - ] - }, - "unit": "ms" - }, - "overrides": [] - }, - "gridPos": { - "h": 6, - "w": 6, - "x": 12, - "y": 22 - }, - "id": 32, - "options": { - "colorMode": "background", - "graphMode": "area", - "justifyMode": "auto", - "orientation": "auto", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "values": false - }, - "textMode": "value_and_name" - }, - "pluginVersion": "9.3.2", - "targets": [ - { - "aggregation": "avg", - "bucket": 1000, - "command": "ts.mrange", - "datasource": { - "type": "redis-datasource", - "uid": "${DS_REDIS}" - }, - "filter": "name=backend stat=mean", - "keyName": "smartcache:metrics:db:mean", - "query": "", - "refId": "A", - "type": "timeSeries" - } - ], - "type": "stat" - }, - { - "datasource": { - "type": "redis-datasource", - "uid": "${DS_REDIS}" - }, - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "displayName": "Backend P99 Latency", - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green" - }, - { - "color": "#EAB839", - "value": 500 - }, - { - "color": "orange", - "value": 1000 - }, - { - "color": "red", - "value": 10000 - } - ] - }, - "unit": "ms" - }, - "overrides": [] - }, - "gridPos": { - "h": 6, - "w": 6, - "x": 18, - "y": 22 - }, - "id": 33, - "options": { - "colorMode": "background", - "graphMode": "area", - "justifyMode": "auto", - "orientation": "auto", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "values": false - }, - "textMode": "auto" - }, - "pluginVersion": "9.3.2", - "targets": [ - { - "aggregation": "avg", - "bucket": 1000, - "command": "ts.mrange", - "datasource": { - "type": "redis-datasource", - "uid": "${DS_REDIS}" - }, - "filter": "name=backend quantile=0.99", - "keyName": "smartcache:metrics:db:quantile:0.99", - "query": "", - "refId": "A", - "type": "timeSeries" - } - ], - "type": "stat" - } - ], - "title": "Backend Latency", - "type": "row" - }, - { - "collapsed": false, - "gridPos": { - "h": 1, - "w": 24, - "x": 0, - "y": 22 - }, - "id": 21, - "panels": [], - "title": "Cache Get Latency", - "type": "row" - }, - { - "datasource": { - "type": "redis-datasource", - "uid": "${DS_REDIS}" - }, - "description": "", - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "custom": { - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 50, - "gradientMode": "scheme", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "auto", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "displayName": "Cache Get Latency", - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "yellow", - "value": 5 - }, - { - "color": "orange", - "value": 10 - }, - { - "color": "red", - "value": 100 - } - ] - }, - "unit": "ms" - }, - "overrides": [] - }, - "gridPos": { - "h": 6, - "w": 12, - "x": 0, - "y": 23 - }, - "id": 28, - "options": { - "legend": { - "calcs": [], - "displayMode": "list", - "placement": "bottom", - "showLegend": false - }, - "tooltip": { - "mode": "single", - "sort": "none" - } - }, - "targets": [ - { - "aggregation": "avg", - "bucket": 1000, - "command": "ts.mrange", - "datasource": { - "type": "redis-datasource", - "uid": "${DS_REDIS}" - }, - "filter": "name=cache.get stat=mean", - "keyName": "smartcache:metrics:cache:get:mean", - "query": "", - "refId": "A", - "type": "timeSeries" - } - ], - "type": "timeseries" - }, - { - "datasource": { - "type": "redis-datasource", - "uid": "${DS_REDIS}" - }, - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "displayName": "Cache Get Mean Latency", - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "yellow", - "value": 1 - }, - { - "color": "orange", - "value": 3 - }, - { - "color": "red", - "value": 10 - } - ] - }, - "unit": "ms" - }, - "overrides": [] - }, - "gridPos": { - "h": 6, - "w": 6, - "x": 12, - "y": 23 - }, - "id": 11, - "options": { - "colorMode": "background", - "graphMode": "area", - "justifyMode": "auto", - "orientation": "auto", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "values": false - }, - "textMode": "value_and_name" - }, - "pluginVersion": "9.3.2", - "targets": [ - { - "aggregation": "avg", - "bucket": 1000, - "command": "ts.mrange", - "datasource": { - "type": "redis-datasource", - "uid": "${DS_REDIS}" - }, - "filter": "name=cache.get stat=mean", - "keyName": "smartcache:metrics:cache:get:mean", - "query": "", - "refId": "A", - "type": "timeSeries" - } - ], - "type": "stat" - }, - { - "datasource": { - "type": "redis-datasource", - "uid": "${DS_REDIS}" - }, - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "displayName": "Cache Get P99 Latency", - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "yellow", - "value": 10 - }, - { - "color": "orange", - "value": 100 - }, - { - "color": "red", - "value": 1000 - } - ] - }, - "unit": "ms" + "unit": "ms" }, "overrides": [] }, "gridPos": { - "h": 6, + "h": 5, "w": 6, "x": 18, - "y": 23 + "y": 17 }, - "id": 16, + "id": 17, "options": { "colorMode": "background", "graphMode": "area", @@ -1341,7 +883,7 @@ "fields": "", "values": false }, - "textMode": "value_and_name" + "textMode": "auto" }, "pluginVersion": "9.3.2", "targets": [ @@ -1354,7 +896,7 @@ "uid": "${DS_REDIS}" }, "filter": "name=cache.get quantile=0.99", - "keyName": "smartcache:metrics:cache:get:quantile:0.99", + "keyName": "smartcache:metrics:cache:put:quantile:0.99", "query": "", "refId": "A", "type": "timeSeries" @@ -1362,70 +904,25 @@ ], "type": "stat" }, - { - "collapsed": false, - "gridPos": { - "h": 1, - "w": 24, - "x": 0, - "y": 29 - }, - "id": 25, - "panels": [], - "title": "Cache Put Latency", - "type": "row" - }, { "datasource": { "type": "redis-datasource", "uid": "${DS_REDIS}" }, + "description": "", "fieldConfig": { "defaults": { "color": { "mode": "thresholds" }, - "custom": { - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 50, - "gradientMode": "scheme", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "auto", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "off" - } - }, + "displayName": "Cache Hit", "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { - "color": "red", + "color": "blue", "value": null - }, - { - "color": "green", - "value": 100 } ] }, @@ -1434,86 +931,12 @@ "overrides": [] }, "gridPos": { - "h": 6, - "w": 12, - "x": 0, - "y": 30 - }, - "id": 18, - "options": { - "legend": { - "calcs": [], - "displayMode": "list", - "placement": "bottom", - "showLegend": false - }, - "tooltip": { - "mode": "single", - "sort": "none" - } - }, - "targets": [ - { - "aggregation": "sum", - "bucket": 1000, - "command": "ts.mrange", - "datasource": { - "type": "redis-datasource", - "uid": "${DS_REDIS}" - }, - "filter": "name=cache.put stat=mean", - "keyName": "smartcache:metrics:cache:put:count", - "query": "", - "refId": "A", - "type": "timeSeries" - } - ], - "type": "timeseries" - }, - { - "datasource": { - "type": "redis-datasource", - "uid": "${DS_REDIS}" - }, - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "displayName": "Cache Put Mean Latency", - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "yellow", - "value": 1 - }, - { - "color": "orange", - "value": 3 - }, - { - "color": "red", - "value": 10 - } - ] - }, - "unit": "ms" - }, - "overrides": [] - }, - "gridPos": { - "h": 6, + "h": 5, "w": 6, "x": 12, - "y": 30 + "y": 22 }, - "id": 14, + "id": 8, "options": { "colorMode": "background", "graphMode": "area", @@ -1538,8 +961,8 @@ "type": "redis-datasource", "uid": "${DS_REDIS}" }, - "filter": "name=cache.put stat=mean", - "keyName": "smartcache:metrics:cache:put:mean", + "filter": "name=cache.get result=hit", + "keyName": "smartcache:metrics:cache:get:result:hit", "query": "", "refId": "A", "type": "timeSeries" @@ -1552,45 +975,46 @@ "type": "redis-datasource", "uid": "${DS_REDIS}" }, + "description": "", "fieldConfig": { "defaults": { "color": { "mode": "thresholds" }, - "displayName": "Cache Put P99", + "displayName": "Cache Miss", "mappings": [], "thresholds": { - "mode": "absolute", + "mode": "percentage", "steps": [ { "color": "green", "value": null }, { - "color": "yellow", + "color": "#EAB839", "value": 1 }, { "color": "orange", - "value": 3 + "value": 10 }, { "color": "red", - "value": 10 + "value": 20 } ] }, - "unit": "ms" + "unit": "ops" }, "overrides": [] }, "gridPos": { - "h": 6, + "h": 5, "w": 6, "x": 18, - "y": 30 + "y": 22 }, - "id": 17, + "id": 9, "options": { "colorMode": "background", "graphMode": "area", @@ -1615,8 +1039,8 @@ "type": "redis-datasource", "uid": "${DS_REDIS}" }, - "filter": "name=cache.get quantile=0.99", - "keyName": "smartcache:metrics:cache:put:quantile:0.99", + "filter": "name=cache.get result=miss", + "keyName": "smartcache:metrics:cache:get:result:miss", "query": "", "refId": "A", "type": "timeSeries" @@ -1640,6 +1064,6 @@ "timezone": "", "title": "Redis Smart Cache", "uid": "7B6csWTVk", - "version": 3, + "version": 1, "weekStart": "" } \ No newline at end of file