riakkv.chart.py 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  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", "line"],
  62. "lines": [
  63. ["node_gets_total", "gets", "incremental"],
  64. ["node_puts_total", "puts", "incremental"]
  65. ]
  66. },
  67. "dt.vnode_updates": {
  68. "options": [None, "Update operations coordinated by local vnodes by data type", "operations/s", "throughput", "riak.dt.vnode_updates", "line"],
  69. "lines": [
  70. ["vnode_counter_update_total", "counters", "incremental"],
  71. ["vnode_set_update_total", "sets", "incremental"],
  72. ["vnode_map_update_total", "maps", "incremental"],
  73. ]
  74. },
  75. "search.queries": {
  76. "options": [None, "Search queries on the node", "queries/s", "throughput", "riak.search", "line"],
  77. "lines": [
  78. ["search_query_throughput_count", "queries", "incremental"]
  79. ]
  80. },
  81. "search.documents": {
  82. "options": [None, "Documents indexed by search", "documents/s", "throughput", "riak.search.documents", "line"],
  83. "lines": [
  84. ["search_index_throughput_count", "indexed", "incremental"]
  85. ]
  86. },
  87. "consistent.operations": {
  88. "options": [None, "Consistent node operations", "operations/s", "throughput", "riak.consistent.operations", "line"],
  89. "lines": [
  90. ["consistent_gets_total", "gets", "incremental"],
  91. ["consistent_puts_total", "puts", "incremental"],
  92. ]
  93. },
  94. # Latency metrics
  95. "kv.latency.get": {
  96. "options": [None, "Time between reception of a client GET request and subsequent response to client", "ms", "latency", "riak.kv.latency.get", "line"],
  97. "lines": [
  98. ["node_get_fsm_time_mean", "mean", "absolute", 1, 1000],
  99. ["node_get_fsm_time_median", "median", "absolute", 1, 1000],
  100. ["node_get_fsm_time_95", "95", "absolute", 1, 1000],
  101. ["node_get_fsm_time_99", "99", "absolute", 1, 1000],
  102. ["node_get_fsm_time_100", "100", "absolute", 1, 1000],
  103. ]
  104. },
  105. "kv.latency.put": {
  106. "options": [None, "Time between reception of a client PUT request and subsequent response to client", "ms", "latency", "riak.kv.latency.put", "line"],
  107. "lines": [
  108. ["node_put_fsm_time_mean", "mean", "absolute", 1, 1000],
  109. ["node_put_fsm_time_median", "median", "absolute", 1, 1000],
  110. ["node_put_fsm_time_95", "95", "absolute", 1, 1000],
  111. ["node_put_fsm_time_99", "99", "absolute", 1, 1000],
  112. ["node_put_fsm_time_100", "100", "absolute", 1, 1000],
  113. ]
  114. },
  115. "dt.latency.counter": {
  116. "options": [None, "Time it takes to perform an Update Counter operation", "ms", "latency", "riak.dt.latency.counter_merge", "line"],
  117. "lines": [
  118. ["object_counter_merge_time_mean", "mean", "absolute", 1, 1000],
  119. ["object_counter_merge_time_median", "median", "absolute", 1, 1000],
  120. ["object_counter_merge_time_95", "95", "absolute", 1, 1000],
  121. ["object_counter_merge_time_99", "99", "absolute", 1, 1000],
  122. ["object_counter_merge_time_100", "100", "absolute", 1, 1000],
  123. ]
  124. },
  125. "dt.latency.set": {
  126. "options": [None, "Time it takes to perform an Update Set operation", "ms", "latency", "riak.dt.latency.set_merge", "line"],
  127. "lines": [
  128. ["object_set_merge_time_mean", "mean", "absolute", 1, 1000],
  129. ["object_set_merge_time_median", "median", "absolute", 1, 1000],
  130. ["object_set_merge_time_95", "95", "absolute", 1, 1000],
  131. ["object_set_merge_time_99", "99", "absolute", 1, 1000],
  132. ["object_set_merge_time_100", "100", "absolute", 1, 1000],
  133. ]
  134. },
  135. "dt.latency.map": {
  136. "options": [None, "Time it takes to perform an Update Map operation", "ms", "latency", "riak.dt.latency.map_merge", "line"],
  137. "lines": [
  138. ["object_map_merge_time_mean", "mean", "absolute", 1, 1000],
  139. ["object_map_merge_time_median", "median", "absolute", 1, 1000],
  140. ["object_map_merge_time_95", "95", "absolute", 1, 1000],
  141. ["object_map_merge_time_99", "99", "absolute", 1, 1000],
  142. ["object_map_merge_time_100", "100", "absolute", 1, 1000],
  143. ]
  144. },
  145. "search.latency.query": {
  146. "options": [None, "Search query latency", "ms", "latency", "riak.search.latency.query", "line"],
  147. "lines": [
  148. ["search_query_latency_median", "median", "absolute", 1, 1000],
  149. ["search_query_latency_min", "min", "absolute", 1, 1000],
  150. ["search_query_latency_95", "95", "absolute", 1, 1000],
  151. ["search_query_latency_99", "99", "absolute", 1, 1000],
  152. ["search_query_latency_999", "999", "absolute", 1, 1000],
  153. ["search_query_latency_max", "max", "absolute", 1, 1000],
  154. ]
  155. },
  156. "search.latency.index": {
  157. "options": [None, "Time it takes Search to index a new document", "ms", "latency", "riak.search.latency.index", "line"],
  158. "lines": [
  159. ["search_index_latency_median", "median", "absolute", 1, 1000],
  160. ["search_index_latency_min", "min", "absolute", 1, 1000],
  161. ["search_index_latency_95", "95", "absolute", 1, 1000],
  162. ["search_index_latency_99", "99", "absolute", 1, 1000],
  163. ["search_index_latency_999", "999", "absolute", 1, 1000],
  164. ["search_index_latency_max", "max", "absolute", 1, 1000],
  165. ]
  166. },
  167. # Riak Strong Consistency metrics
  168. "consistent.latency.get": {
  169. "options": [None, "Strongly consistent read latency", "ms", "latency", "riak.consistent.latency.get", "line"],
  170. "lines": [
  171. ["consistent_get_time_mean", "mean", "absolute", 1, 1000],
  172. ["consistent_get_time_median", "median", "absolute", 1, 1000],
  173. ["consistent_get_time_95", "95", "absolute", 1, 1000],
  174. ["consistent_get_time_99", "99", "absolute", 1, 1000],
  175. ["consistent_get_time_100", "100", "absolute", 1, 1000],
  176. ]
  177. },
  178. "consistent.latency.put": {
  179. "options": [None, "Strongly consistent write latency", "ms", "latency", "riak.consistent.latency.put", "line"],
  180. "lines": [
  181. ["consistent_put_time_mean", "mean", "absolute", 1, 1000],
  182. ["consistent_put_time_median", "median", "absolute", 1, 1000],
  183. ["consistent_put_time_95", "95", "absolute", 1, 1000],
  184. ["consistent_put_time_99", "99", "absolute", 1, 1000],
  185. ["consistent_put_time_100", "100", "absolute", 1, 1000],
  186. ]
  187. },
  188. # BEAM metrics
  189. "vm.processes": {
  190. "options": [None, "Total processes running in the Erlang VM", "total", "vm", "riak.vm", "line"],
  191. "lines": [
  192. ["sys_process_count", "processes", "absolute"],
  193. ]
  194. },
  195. "vm.memory.processes": {
  196. "options": [None, "Memory allocated & used by Erlang processes", "MB", "vm", "riak.vm.memory.processes", "line"],
  197. "lines": [
  198. ["memory_processes", "allocated", "absolute", 1, 1024 * 1024],
  199. ["memory_processes_used", "used", "absolute", 1, 1024 * 1024]
  200. ]
  201. },
  202. # General Riak Load/Health metrics
  203. "kv.siblings_encountered.get": {
  204. "options": [None, "Number of siblings encountered during GET operations by this node during the past minute", "siblings", "load", "riak.kv.siblings_encountered.get", "line"],
  205. "lines": [
  206. ["node_get_fsm_siblings_mean", "mean", "absolute"],
  207. ["node_get_fsm_siblings_median", "median", "absolute"],
  208. ["node_get_fsm_siblings_95", "95", "absolute"],
  209. ["node_get_fsm_siblings_99", "99", "absolute"],
  210. ["node_get_fsm_siblings_100", "100", "absolute"],
  211. ]
  212. },
  213. "kv.objsize.get": {
  214. "options": [None, "Object size encountered by this node during the past minute", "KB", "load", "riak.kv.objsize.get", "line"],
  215. "lines": [
  216. ["node_get_fsm_objsize_mean", "mean", "absolute", 1, 1024],
  217. ["node_get_fsm_objsize_median", "median", "absolute", 1, 1024],
  218. ["node_get_fsm_objsize_95", "95", "absolute", 1, 1024],
  219. ["node_get_fsm_objsize_99", "99", "absolute", 1, 1024],
  220. ["node_get_fsm_objsize_100", "100", "absolute", 1, 1024],
  221. ]
  222. },
  223. "search.vnodeq_size": {
  224. "options": [None, "Number of unprocessed messages in the vnode message queues of Search on this node in the past minute", "messages", "load", "riak.search.vnodeq_size", "line"],
  225. "lines": [
  226. ["riak_search_vnodeq_mean", "mean", "absolute"],
  227. ["riak_search_vnodeq_median", "median", "absolute"],
  228. ["riak_search_vnodeq_95", "95", "absolute"],
  229. ["riak_search_vnodeq_99", "99", "absolute"],
  230. ["riak_search_vnodeq_100", "100", "absolute"],
  231. ]
  232. },
  233. "search.index_errors": {
  234. "options": [None, "Number of document index errors encountered by Search", "errors", "load", "riak.search.index", "line"],
  235. "lines": [
  236. ["search_index_fail_count", "errors", "absolute"]
  237. ]
  238. },
  239. "core.pbc": {
  240. "options": [None, "Protocol buffer connections by status", "connections", "load", "riak.core.protobuf_connections", "line"],
  241. "lines": [
  242. ["pbc_active", "active", "absolute"],
  243. # ["pbc_connects", "established_pastmin", "absolute"]
  244. ]
  245. },
  246. "core.repairs": {
  247. "options": [None, "Number of repair operations this node has coordinated", "repairs", "load", "riak.core.repairs", "line"],
  248. "lines": [
  249. ["read_repairs", "read", "absolute"]
  250. ]
  251. },
  252. "core.fsm_active": {
  253. "options": [None, "Active finite state machines by kind", "fsms", "load", "riak.core.fsm_active", "line"],
  254. "lines": [
  255. ["node_get_fsm_active", "get", "absolute"],
  256. ["node_put_fsm_active", "put", "absolute"],
  257. ["index_fsm_active", "secondary index", "absolute"],
  258. ["list_fsm_active", "list keys", "absolute"]
  259. ]
  260. },
  261. "core.fsm_rejected": {
  262. # Writing "Sidejob's" here seems to cause some weird issues: it results in this chart being rendered in
  263. # its own context and additionally, moves the entire Riak graph all the way up to the top of the Netdata
  264. # dashboard for some reason.
  265. "options": [None, "Finite state machines being rejected by Sidejobs overload protection", "fsms", "load", "riak.core.fsm_rejected", "line"],
  266. "lines": [
  267. ["node_get_fsm_rejected", "get", "absolute"],
  268. ["node_put_fsm_rejected", "put", "absolute"]
  269. ]
  270. },
  271. # General Riak Search Load / Health metrics
  272. "search.errors": {
  273. "options": [None, "Number of writes to Search failed due to bad data format by reason", "writes", "load", "riak.search.index", "line"],
  274. "lines": [
  275. ["search_index_bad_entry_count", "bad_entry", "absolute"],
  276. ["search_index_extract_fail_count", "extract_fail", "absolute"],
  277. ]
  278. }
  279. }
  280. class Service(UrlService):
  281. def __init__(self, configuration=None, name=None):
  282. UrlService.__init__(self, configuration=configuration, name=name)
  283. self.order = ORDER
  284. self.definitions = CHARTS
  285. def _get_data(self):
  286. """
  287. Format data received from http request
  288. :return: dict
  289. """
  290. raw = self._get_raw_data()
  291. if not raw:
  292. return None
  293. try:
  294. return loads(raw)
  295. except (TypeError, ValueError) as err:
  296. self.error(err)
  297. return None