diff --git a/docs/en/changes/changes.md b/docs/en/changes/changes.md index d2458d721f25..fd9ac4e9dde3 100644 --- a/docs/en/changes/changes.md +++ b/docs/en/changes/changes.md @@ -97,6 +97,7 @@ * LAL: the v2 compiler runs a rule as Groovy LAL did, or fails its compilation naming what it does not support, where it dropped or rewrote parts (an `abort {}` in an extractor's `if`, a nested `if` in a sink, method chains after `tag()` and the other functions, casts, the order of samplers); lal.md lists the differences from Groovy LAL that v2 keeps. `as Boolean` converts a boolean, the text `true` or `false` in any case, and a number or a text holding one by zero (0 false, any other true), and fails the log on any other value (`"yes"`). A standard field statement (`service`, `instance`, `endpoint`, `traceId`, `segmentId`, `spanId`, `timestamp`) also sets what later reads of the log and the traffic it builds see: `lal/nginx.yaml`'s error-log metric takes the parsed time, `lal/miniprogram.yaml` builds instance and endpoint traffic and `lal/ios-metrickit.yaml` instance traffic, the slow-SQL rules' service traffic uses `parsed.service`, and the network-profiling rules of `lal/k8s-service.yaml`, `lal/mesh-dp.yaml` and `lal/envoy-als.yaml` write no sampled trace for a log without its `client_process` or `server_process`; `lal/ios-metrickit.yaml` aborts, as written, a log whose `name` tag does not start with `metrickit.diagnostic.`. * OAL: a script that compiled into something other than what it says now does what it says or fails the compilation with its source location: statements after a stray token or an unterminated comment were dropped, surplus or missing function arguments were ignored or reached another overload, string, escape, `100L`, `1_000` and `in [...]` literals were misread, a comparison across types, a `like` without `%`, an out-of-range number and a double passed to a long parameter matched or computed wrongly, and `percentile2(0)` and `histogram(0, ...)` failed every event. A generated class the JVM verifier rejects fails the compilation instead of the boot, and a from() attribute no function reads or a `disable(...)` naming no stream, or one already defined outside `disable.oal`, is logged as a warning; see oal.md. * TAL: a rule runs as written or fails its compilation naming what is wrong, where parts of it were dropped, replaced or read as something else (a repeated `metrics {}` clause or tag key, an unknown type after `as`, a misspelled layer, a method on a literal, a `log` argument beyond its placeholders), and two rules of one name, or two candidate files for one listed name, fail the boot. Values evaluate as LAL's: a cast that does not convert fails the span, conditions use Groovy truth, a whole-number quotient stays exact until its destination converts it (the shipped nanosecond-to-millisecond conversions are unchanged), and a leading-0 integer is octal; see tal.md. The shipped `otlp-general` `attr(...) as Double >= 400` fails a span whose status code is text that is no number, and a padded native `transmission.latency` tag reads where the Java analyzer failed the segment. +* Fix the Redis instance `meter_redis_instance_average_time_spent_by_command` showing 0 or 1 instead of the average time of a command. The rule divided the two lifetime counters `redis_commands_duration_seconds_total` and `redis_commands_total` first and took the rate of that ratio, which is how fast the lifetime average drifts. It now divides the rate of the command time by the rate of the command count, and reports `0` for a command that did not run in the window. The metric is now in microseconds, not seconds: a meter value is stored as a whole number, so an average below 1 second was stored as 1. Values stored before the upgrade keep the old numbers. #### UI diff --git a/docs/en/setup/backend/backend-redis-monitoring.md b/docs/en/setup/backend/backend-redis-monitoring.md index 4c0307d96161..a26ef02da775 100644 --- a/docs/en/setup/backend/backend-redis-monitoring.md +++ b/docs/en/setup/backend/backend-redis-monitoring.md @@ -24,7 +24,7 @@ Each Redis server is cataloged as an `Instance` in OAP. | Blocked Clients | | meter_redis_blocked_clients | The number of blocked clients. | redis-exporter | | Memory Max Bytes | MB | meter_redis_memory_max_bytes | The max bytes of memory. | redis-exporter | | Hits Rate | % | meter_redis_hit_rate | Hit rate of redis when used as a cache. | redis-exporter | -| Average Time Spend By Command | second | meter_redis_average_time_spent_by_command | Average time to execute various types of commands. | redis-exporter | +| Average Time Spend By Command | microsecond | meter_redis_instance_average_time_spent_by_command | Average time to execute various types of commands. | redis-exporter | | Total Commands Trend | | meter_redis_total_commands_rate | The Trend of total commands. | redis-exporter | | DB keys | | meter_redis_evicted_keys_total
meter_redis_expired_keys_total
meter_redis_db_keys | The number of Expired / Evicted / total keys. | redis-exporter | | Net Input/Output Bytes | KB | meter_redis_net_input_bytes
meter_redis_net_output_bytes | Total bytes of input / output of redis net. | redis-exporter | diff --git a/oap-server/analyzer/meter-analyzer-scripts-test/src/test/resources/scripts/mal/test-otel-rules/redis/redis-instance.data.yaml b/oap-server/analyzer/meter-analyzer-scripts-test/src/test/resources/scripts/mal/test-otel-rules/redis/redis-instance.data.yaml index 36415dd6d6bc..7dff82b86a61 100644 --- a/oap-server/analyzer/meter-analyzer-scripts-test/src/test/resources/scripts/mal/test-otel-rules/redis/redis-instance.data.yaml +++ b/oap-server/analyzer/meter-analyzer-scripts-test/src/test/resources/scripts/mal/test-otel-rules/redis/redis-instance.data.yaml @@ -74,7 +74,7 @@ input: host_name: test-host cmd: get service_instance_id: test-instance - value: 100.0 + value: 0.02 expected: meter_redis_instance_uptime: entities: @@ -198,7 +198,7 @@ expected: host_name: 'redis::test-host' cmd: get service_instance_id: test-instance - value: 0.0 + value: 200.0 meter_redis_instance_commands_duration_seconds_total_rate: entities: - scope: SERVICE_INSTANCE @@ -210,4 +210,4 @@ expected: host_name: 'redis::test-host' cmd: get service_instance_id: test-instance - value: 25.0 + value: 0.005 diff --git a/oap-server/server-starter/src/main/resources/otel-rules/redis/redis-instance.yaml b/oap-server/server-starter/src/main/resources/otel-rules/redis/redis-instance.yaml index f2aa2e03f71e..83101aaef78b 100644 --- a/oap-server/server-starter/src/main/resources/otel-rules/redis/redis-instance.yaml +++ b/oap-server/server-starter/src/main/resources/otel-rules/redis/redis-instance.yaml @@ -64,6 +64,6 @@ metricsRules: exp: redis_blocked_clients - name: instance_average_time_spent_by_command - exp: (redis_commands_duration_seconds_total.sum(['host_name','cmd','service_instance_id']) / redis_commands_total.sum(['host_name','cmd','service_instance_id'])).rate('PT1M') + exp: redis_commands_duration_seconds_total.sum(['host_name','cmd','service_instance_id']).rate('PT1M').safeDiv(redis_commands_total.sum(['host_name','cmd','service_instance_id']).rate('PT1M')) * 1000000 - name: instance_commands_duration_seconds_total_rate exp: redis_commands_duration_seconds_total.sum(['host_name','cmd','service_instance_id']).rate('PT1M') \ No newline at end of file