riakkv.chart.py 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. # -*- coding: utf-8 -*-
  2. # Description: riak netdata python.d module
  3. #
  4. # See also:
  5. # https://docs.riak.com/riak/kv/latest/using/reference/statistics-monitoring/index.html
  6. from json import loads
  7. from bases.FrameworkServices.UrlService import UrlService
  8. # Riak updates the metrics at the /stats endpoint every 1 second.
  9. # If we use `update_every = 1` here, that means we might get weird jitter in the graph,
  10. # so the default is set to 2 seconds to prevent it.
  11. update_every = 2
  12. # charts order (can be overridden if you want less charts, or different order)
  13. ORDER = [
  14. # Throughput metrics
  15. # https://docs.riak.com/riak/kv/latest/using/reference/statistics-monitoring/index.html#throughput-metrics
  16. # Collected in totals.
  17. "kv.node_operations", # K/V node operations.
  18. "dt.vnode_updates", # Data type vnode updates.
  19. "search.queries", # Search queries on the node.
  20. "search.documents", # Documents indexed by Search.
  21. "consistent.operations", # Consistent node operations.
  22. # Latency metrics
  23. # https://docs.riak.com/riak/kv/latest/using/reference/statistics-monitoring/index.html#throughput-metrics
  24. # Collected for the past minute in milliseconds,
  25. # returned from riak in microseconds.
  26. "kv.latency.get", # K/V GET FSM traversal latency.
  27. "kv.latency.put", # K/V PUT FSM traversal latency.
  28. "dt.latency.counter", # Update Counter Data type latency.
  29. "dt.latency.set", # Update Set Data type latency.
  30. "dt.latency.map", # Update Map Data type latency.
  31. "search.latency.query", # Search query latency.
  32. "search.latency.index", # Time it takes for search to index a new document.
  33. "consistent.latency.get", # Strong consistent read latency.
  34. "consistent.latency.put", # Strong consistent write latency.
  35. # Erlang resource usage metrics
  36. # https://docs.riak.com/riak/kv/latest/using/reference/statistics-monitoring/index.html#erlang-resource-usage-metrics
  37. # Processes collected as a gauge,
  38. # memory collected as Megabytes, returned as bytes from Riak.
  39. "vm.processes", # Number of processes currently running in the Erlang VM.
  40. "vm.memory.processes", # Total amount of memory allocated & used for Erlang processes.
  41. # General Riak Load / Health metrics
  42. # https://docs.riak.com/riak/kv/latest/using/reference/statistics-monitoring/index.html#general-riak-load-health-metrics
  43. # The following are collected by Riak over the past minute:
  44. "kv.siblings_encountered.get", # Siblings encountered during GET operations by this node.
  45. "kv.objsize.get", # Object size encountered by this node.
  46. "search.vnodeq_size", # Number of unprocessed messages in the vnode message queues (Search).
  47. # The following are calculated in total, or as gauges:
  48. "search.index_errors", # Errors of the search subsystem while indexing documents.
  49. "core.pbc", # Number of currently active protocol buffer connections.
  50. "core.repairs", # Total read repair operations coordinated by this node.
  51. "core.fsm_active", # Active finite state machines by kind.
  52. "core.fsm_rejected", # Rejected finite state machines by kind.
  53. # General Riak Search Load / Health metrics
  54. # https://docs.riak.com/riak/kv/latest/using/reference/statistics-monitoring/index.html#general-riak-search-load-health-metrics
  55. # Reported as counters.
  56. "search.errors", # Write and read errors of the Search subsystem.
  57. ]
  58. CHARTS = {
  59. # Throughput metrics
  60. "kv.node_operations": {
  61. "options": [None, "Reads & writes coordinated by this node", "operations/s", "throughput", "riak.kv.throughput",
  62. "line"],
  63. "lines": [
  64. ["node_gets_total", "gets", "incremental"],
  65. ["node_puts_total", "puts", "incremental"]
  66. ]
  67. },
  68. "dt.vnode_updates": {
  69. "options": [None, "Update operations coordinated by local vnodes by data type", "operations/s", "throughput",
  70. "riak.dt.vnode_updates", "line"],
  71. "lines": [
  72. ["vnode_counter_update_total", "counters", "incremental"],
  73. ["vnode_set_update_total", "sets", "incremental"],
  74. ["vnode_map_update_total", "maps", "incremental"],
  75. ]
  76. },
  77. "search.queries": {
  78. "options": [None, "Search queries on the node", "queries/s", "throughput", "riak.search", "line"],
  79. "lines": [
  80. ["search_query_throughput_count", "queries", "incremental"]
  81. ]
  82. },
  83. "search.documents": {
  84. "options": [None, "Documents indexed by search", "documents/s", "throughput", "riak.search.documents", "line"],
  85. "lines": [
  86. ["search_index_throughput_count", "indexed", "incremental"]
  87. ]
  88. },
  89. "consistent.operations": {
  90. "options": [None, "Consistent node operations", "operations/s", "throughput", "riak.consistent.operations",
  91. "line"],
  92. "lines": [
  93. ["consistent_gets_total", "gets", "incremental"],
  94. ["consistent_puts_total", "puts", "incremental"],
  95. ]
  96. },
  97. # Latency metrics
  98. "kv.latency.get": {
  99. "options": [None, "Time between reception of a client GET request and subsequent response to client", "ms",
  100. "latency", "riak.kv.latency.get", "line"],
  101. "lines": [
  102. ["node_get_fsm_time_mean", "mean", "absolute", 1, 1000],
  103. ["node_get_fsm_time_median", "median", "absolute", 1, 1000],
  104. ["node_get_fsm_time_95", "95", "absolute", 1, 1000],
  105. ["node_get_fsm_time_99", "99", "absolute", 1, 1000],
  106. ["node_get_fsm_time_100", "100", "absolute", 1, 1000],
  107. ]
  108. },
  109. "kv.latency.put": {
  110. "options": [None, "Time between reception of a client PUT request and subsequent response to client", "ms",
  111. "latency", "riak.kv.latency.put", "line"],
  112. "lines": [
  113. ["node_put_fsm_time_mean", "mean", "absolute", 1, 1000],
  114. ["node_put_fsm_time_median", "median", "absolute", 1, 1000],
  115. ["node_put_fsm_time_95", "95", "absolute", 1, 1000],
  116. ["node_put_fsm_time_99", "99", "absolute", 1, 1000],
  117. ["node_put_fsm_time_100", "100", "absolute", 1, 1000],
  118. ]
  119. },
  120. "dt.latency.counter": {
  121. "options": [None, "Time it takes to perform an Update Counter operation", "ms", "latency",
  122. "riak.dt.latency.counter_merge", "line"],
  123. "lines": [
  124. ["object_counter_merge_time_mean", "mean", "absolute", 1, 1000],
  125. ["object_counter_merge_time_median", "median", "absolute", 1, 1000],
  126. ["object_counter_merge_time_95", "95", "absolute", 1, 1000],
  127. ["object_counter_merge_time_99", "99", "absolute", 1, 1000],
  128. ["object_counter_merge_time_100", "100", "absolute", 1, 1000],
  129. ]
  130. },
  131. "dt.latency.set": {
  132. "options": [None, "Time it takes to perform an Update Set operation", "ms", "latency",
  133. "riak.dt.latency.set_merge", "line"],
  134. "lines": [
  135. ["object_set_merge_time_mean", "mean", "absolute", 1, 1000],
  136. ["object_set_merge_time_median", "median", "absolute", 1, 1000],
  137. ["object_set_merge_time_95", "95", "absolute", 1, 1000],
  138. ["object_set_merge_time_99", "99", "absolute", 1, 1000],
  139. ["object_set_merge_time_100", "100", "absolute", 1, 1000],
  140. ]
  141. },
  142. "dt.latency.map": {
  143. "options": [None, "Time it takes to perform an Update Map operation", "ms", "latency",
  144. "riak.dt.latency.map_merge", "line"],
  145. "lines": [
  146. ["object_map_merge_time_mean", "mean", "absolute", 1, 1000],
  147. ["object_map_merge_time_median", "median", "absolute", 1, 1000],
  148. ["object_map_merge_time_95", "95", "absolute", 1, 1000],
  149. ["object_map_merge_time_99", "99", "absolute", 1, 1000],
  150. ["object_map_merge_time_100", "100", "absolute", 1, 1000],
  151. ]
  152. },
  153. "search.latency.query": {
  154. "options": [None, "Search query latency", "ms", "latency", "riak.search.latency.query", "line"],
  155. "lines": [
  156. ["search_query_latency_median", "median", "absolute", 1, 1000],
  157. ["search_query_latency_min", "min", "absolute", 1, 1000],
  158. ["search_query_latency_95", "95", "absolute", 1, 1000],
  159. ["search_query_latency_99", "99", "absolute", 1, 1000],
  160. ["search_query_latency_999", "999", "absolute", 1, 1000],
  161. ["search_query_latency_max", "max", "absolute", 1, 1000],
  162. ]
  163. },
  164. "search.latency.index": {
  165. "options": [None, "Time it takes Search to index a new document", "ms", "latency", "riak.search.latency.index",
  166. "line"],
  167. "lines": [
  168. ["search_index_latency_median", "median", "absolute", 1, 1000],
  169. ["search_index_latency_min", "min", "absolute", 1, 1000],
  170. ["search_index_latency_95", "95", "absolute", 1, 1000],
  171. ["search_index_latency_99", "99", "absolute", 1, 1000],
  172. ["search_index_latency_999", "999", "absolute", 1, 1000],
  173. ["search_index_latency_max", "max", "absolute", 1, 1000],
  174. ]
  175. },
  176. # Riak Strong Consistency metrics
  177. "consistent.latency.get": {
  178. "options": [None, "Strongly consistent read latency", "ms", "latency", "riak.consistent.latency.get", "line"],
  179. "lines": [
  180. ["consistent_get_time_mean", "mean", "absolute", 1, 1000],
  181. ["consistent_get_time_median", "median", "absolute", 1, 1000],
  182. ["consistent_get_time_95", "95", "absolute", 1, 1000],
  183. ["consistent_get_time_99", "99", "absolute", 1, 1000],
  184. ["consistent_get_time_100", "100", "absolute", 1, 1000],
  185. ]
  186. },
  187. "consistent.latency.put": {
  188. "options": [None, "Strongly consistent write latency", "ms", "latency", "riak.consistent.latency.put", "line"],
  189. "lines": [
  190. ["consistent_put_time_mean", "mean", "absolute", 1, 1000],
  191. ["consistent_put_time_median", "median", "absolute", 1, 1000],
  192. ["consistent_put_time_95", "95", "absolute", 1, 1000],
  193. ["consistent_put_time_99", "99", "absolute", 1, 1000],
  194. ["consistent_put_time_100", "100", "absolute", 1, 1000],
  195. ]
  196. },
  197. # BEAM metrics
  198. "vm.processes": {
  199. "options": [None, "Total processes running in the Erlang VM", "total", "vm", "riak.vm", "line"],
  200. "lines": [
  201. ["sys_process_count", "processes", "absolute"],
  202. ]
  203. },
  204. "vm.memory.processes": {
  205. "options": [None, "Memory allocated & used by Erlang processes", "MB", "vm", "riak.vm.memory.processes",
  206. "line"],
  207. "lines": [
  208. ["memory_processes", "allocated", "absolute", 1, 1024 * 1024],
  209. ["memory_processes_used", "used", "absolute", 1, 1024 * 1024]
  210. ]
  211. },
  212. # General Riak Load/Health metrics
  213. "kv.siblings_encountered.get": {
  214. "options": [None, "Number of siblings encountered during GET operations by this node during the past minute",
  215. "siblings", "load", "riak.kv.siblings_encountered.get", "line"],
  216. "lines": [
  217. ["node_get_fsm_siblings_mean", "mean", "absolute"],
  218. ["node_get_fsm_siblings_median", "median", "absolute"],
  219. ["node_get_fsm_siblings_95", "95", "absolute"],
  220. ["node_get_fsm_siblings_99", "99", "absolute"],
  221. ["node_get_fsm_siblings_100", "100", "absolute"],
  222. ]
  223. },
  224. "kv.objsize.get": {
  225. "options": [None, "Object size encountered by this node during the past minute", "KB", "load",
  226. "riak.kv.objsize.get", "line"],
  227. "lines": [
  228. ["node_get_fsm_objsize_mean", "mean", "absolute", 1, 1024],
  229. ["node_get_fsm_objsize_median", "median", "absolute", 1, 1024],
  230. ["node_get_fsm_objsize_95", "95", "absolute", 1, 1024],
  231. ["node_get_fsm_objsize_99", "99", "absolute", 1, 1024],
  232. ["node_get_fsm_objsize_100", "100", "absolute", 1, 1024],
  233. ]
  234. },
  235. "search.vnodeq_size": {
  236. "options": [None,
  237. "Number of unprocessed messages in the vnode message queues of Search on this node in the past minute",
  238. "messages", "load", "riak.search.vnodeq_size", "line"],
  239. "lines": [
  240. ["riak_search_vnodeq_mean", "mean", "absolute"],
  241. ["riak_search_vnodeq_median", "median", "absolute"],
  242. ["riak_search_vnodeq_95", "95", "absolute"],
  243. ["riak_search_vnodeq_99", "99", "absolute"],
  244. ["riak_search_vnodeq_100", "100", "absolute"],
  245. ]
  246. },
  247. "search.index_errors": {
  248. "options": [None, "Number of document index errors encountered by Search", "errors", "load",
  249. "riak.search.index", "line"],
  250. "lines": [
  251. ["search_index_fail_count", "errors", "absolute"]
  252. ]
  253. },
  254. "core.pbc": {
  255. "options": [None, "Protocol buffer connections by status", "connections", "load",
  256. "riak.core.protobuf_connections", "line"],
  257. "lines": [
  258. ["pbc_active", "active", "absolute"],
  259. # ["pbc_connects", "established_pastmin", "absolute"]
  260. ]
  261. },
  262. "core.repairs": {
  263. "options": [None, "Number of repair operations this node has coordinated", "repairs", "load",
  264. "riak.core.repairs", "line"],
  265. "lines": [
  266. ["read_repairs", "read", "absolute"]
  267. ]
  268. },
  269. "core.fsm_active": {
  270. "options": [None, "Active finite state machines by kind", "fsms", "load", "riak.core.fsm_active", "line"],
  271. "lines": [
  272. ["node_get_fsm_active", "get", "absolute"],
  273. ["node_put_fsm_active", "put", "absolute"],
  274. ["index_fsm_active", "secondary index", "absolute"],
  275. ["list_fsm_active", "list keys", "absolute"]
  276. ]
  277. },
  278. "core.fsm_rejected": {
  279. # Writing "Sidejob's" here seems to cause some weird issues: it results in this chart being rendered in
  280. # its own context and additionally, moves the entire Riak graph all the way up to the top of the Netdata
  281. # dashboard for some reason.
  282. "options": [None, "Finite state machines being rejected by Sidejobs overload protection", "fsms", "load",
  283. "riak.core.fsm_rejected", "line"],
  284. "lines": [
  285. ["node_get_fsm_rejected", "get", "absolute"],
  286. ["node_put_fsm_rejected", "put", "absolute"]
  287. ]
  288. },
  289. # General Riak Search Load / Health metrics
  290. "search.errors": {
  291. "options": [None, "Number of writes to Search failed due to bad data format by reason", "writes", "load",
  292. "riak.search.index", "line"],
  293. "lines": [
  294. ["search_index_bad_entry_count", "bad_entry", "absolute"],
  295. ["search_index_extract_fail_count", "extract_fail", "absolute"],
  296. ]
  297. }
  298. }
  299. class Service(UrlService):
  300. def __init__(self, configuration=None, name=None):
  301. UrlService.__init__(self, configuration=configuration, name=name)
  302. self.order = ORDER
  303. self.definitions = CHARTS
  304. def _get_data(self):
  305. """
  306. Format data received from http request
  307. :return: dict
  308. """
  309. raw = self._get_raw_data()
  310. if not raw:
  311. return None
  312. try:
  313. return loads(raw)
  314. except (TypeError, ValueError) as err:
  315. self.error(err)
  316. return None