getMetrics-2.lua 441 B

12345678910111213141516171819
  1. --[[
  2. Get metrics
  3. Input:
  4. KEYS[1] 'metrics' key
  5. KEYS[2] 'metrics data' key
  6. ARGV[1] start index
  7. ARGV[2] end index
  8. ]]
  9. local rcall = redis.call;
  10. local metricsKey = KEYS[1]
  11. local dataKey = KEYS[2]
  12. local metrics = rcall("HMGET", metricsKey, "count", "prevTS", "prevCount")
  13. local data = rcall("LRANGE", dataKey, tonumber(ARGV[1]), tonumber(ARGV[2]))
  14. local numPoints = rcall("LLEN", dataKey)
  15. return {metrics, data, numPoints}