metadata.yaml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. plugin_name: python.d.plugin
  2. modules:
  3. - meta:
  4. plugin_name: python.d.plugin
  5. module_name: go_expvar
  6. monitored_instance:
  7. name: Go applications
  8. link: "https://pkg.go.dev/expvar"
  9. categories:
  10. - data-collection.apm
  11. icon_filename: "go.png"
  12. related_resources:
  13. integrations:
  14. list: []
  15. info_provided_to_referring_integrations:
  16. description: ""
  17. keywords:
  18. - go
  19. - expvar
  20. - application
  21. most_popular: false
  22. overview:
  23. data_collection:
  24. metrics_description: "This collector monitors Go applications that expose their metrics with the use of the `expvar` package from the Go standard library. It produces charts for Go runtime memory statistics and optionally any number of custom charts."
  25. method_description: "It connects via http to gather the metrics exposed via the `expvar` package."
  26. supported_platforms:
  27. include: []
  28. exclude: []
  29. multi_instance: true
  30. additional_permissions:
  31. description: ""
  32. default_behavior:
  33. auto_detection:
  34. description: ""
  35. limits:
  36. description: ""
  37. performance_impact:
  38. description: ""
  39. setup:
  40. prerequisites:
  41. list:
  42. - title: "Sample `expvar` usage in a Go application"
  43. description: |
  44. The `expvar` package exposes metrics over HTTP and is very easy to use.
  45. Consider this minimal sample below:
  46. ```go
  47. package main
  48. import (
  49. _ "expvar"
  50. "net/http"
  51. )
  52. func main() {
  53. http.ListenAndServe("127.0.0.1:8080", nil)
  54. }
  55. ```
  56. When imported this way, the `expvar` package registers a HTTP handler at `/debug/vars` that
  57. exposes Go runtime's memory statistics in JSON format. You can inspect the output by opening
  58. the URL in your browser (or by using `wget` or `curl`).
  59. Sample output:
  60. ```json
  61. {
  62. "cmdline": ["./expvar-demo-binary"],
  63. "memstats": {"Alloc":630856,"TotalAlloc":630856,"Sys":3346432,"Lookups":27, <omitted for brevity>}
  64. }
  65. ```
  66. You can of course expose and monitor your own variables as well.
  67. Here is a sample Go application that exposes a few custom variables:
  68. ```go
  69. package main
  70. import (
  71. "expvar"
  72. "net/http"
  73. "runtime"
  74. "time"
  75. )
  76. func main() {
  77. tick := time.NewTicker(1 * time.Second)
  78. num_go := expvar.NewInt("runtime.goroutines")
  79. counters := expvar.NewMap("counters")
  80. counters.Set("cnt1", new(expvar.Int))
  81. counters.Set("cnt2", new(expvar.Float))
  82. go http.ListenAndServe(":8080", nil)
  83. for {
  84. select {
  85. case <- tick.C:
  86. num_go.Set(int64(runtime.NumGoroutine()))
  87. counters.Add("cnt1", 1)
  88. counters.AddFloat("cnt2", 1.452)
  89. }
  90. }
  91. }
  92. ```
  93. Apart from the runtime memory stats, this application publishes two counters and the
  94. number of currently running Goroutines and updates these stats every second.
  95. configuration:
  96. file:
  97. name: python.d/go_expvar.conf
  98. options:
  99. description: |
  100. There are 2 sections:
  101. * Global variables
  102. * One or more JOBS that can define multiple different instances to monitor.
  103. The following options can be defined globally: priority, penalty, autodetection_retry, update_every, but can also be defined per JOB to override the global values.
  104. Additionally, the following collapsed table contains all the options that can be configured inside a JOB definition.
  105. Every configuration JOB starts with a `job_name` value which will appear in the dashboard, unless a `name` parameter is specified. Each JOB can be used to monitor a different Go application.
  106. folding:
  107. title: "Config options"
  108. enabled: true
  109. list:
  110. - name: update_every
  111. description: Sets the default data collection frequency.
  112. default_value: 5
  113. required: false
  114. - name: priority
  115. description: Controls the order of charts at the netdata dashboard.
  116. default_value: 60000
  117. required: false
  118. - name: autodetection_retry
  119. description: Sets the job re-check interval in seconds.
  120. default_value: 0
  121. required: false
  122. - name: penalty
  123. description: Indicates whether to apply penalty to update_every in case of failures.
  124. default_value: yes
  125. required: false
  126. - name: name
  127. description: Job name. This value will overwrite the `job_name` value. JOBS with the same name are mutually exclusive. Only one of them will be allowed running at any time. This allows autodetection to try several alternatives and pick the one that works.
  128. default_value: ""
  129. required: false
  130. - name: url
  131. description: the URL and port of the expvar endpoint. Please include the whole path of the endpoint, as the expvar handler can be installed in a non-standard location.
  132. default_value: ""
  133. required: true
  134. - name: user
  135. description: If the URL is password protected, this is the username to use.
  136. default_value: ""
  137. required: false
  138. - name: pass
  139. description: If the URL is password protected, this is the password to use.
  140. default_value: ""
  141. required: false
  142. - name: collect_memstats
  143. description: Enables charts for Go runtime's memory statistics.
  144. default_value: ""
  145. required: false
  146. - name: extra_charts
  147. description: Defines extra data/charts to monitor, please see the example below.
  148. default_value: ""
  149. required: false
  150. examples:
  151. folding:
  152. enabled: false
  153. title: "Config"
  154. list:
  155. - name: Monitor a Go app1 application
  156. description: |
  157. The example below sets a configuration for a Go application, called `app1`. Besides the `memstats`, the application also exposes two counters and the number of currently running Goroutines and updates these stats every second.
  158. The `go_expvar` collector can monitor these as well with the use of the `extra_charts` configuration variable.
  159. The `extra_charts` variable is a YaML list of Netdata chart definitions.
  160. Each chart definition has the following keys:
  161. ```
  162. id: Netdata chart ID
  163. options: a key-value mapping of chart options
  164. lines: a list of line definitions
  165. ```
  166. **Note: please do not use dots in the chart or line ID field.
  167. See [this issue](https://github.com/netdata/netdata/pull/1902#issuecomment-284494195) for explanation.**
  168. Please see these two links to the official Netdata documentation for more information about the values:
  169. - [External plugins - charts](https://github.com/netdata/netdata/blob/master/collectors/plugins.d/README.md#chart)
  170. - [Chart variables](https://github.com/netdata/netdata/blob/master/collectors/python.d.plugin/README.md#global-variables-order-and-chart)
  171. **Line definitions**
  172. Each chart can define multiple lines (dimensions).
  173. A line definition is a key-value mapping of line options.
  174. Each line can have the following options:
  175. ```
  176. # mandatory
  177. expvar_key: the name of the expvar as present in the JSON output of /debug/vars endpoint
  178. expvar_type: value type; supported are "float" or "int"
  179. id: the id of this line/dimension in Netdata
  180. # optional - Netdata defaults are used if these options are not defined
  181. name: ''
  182. algorithm: absolute
  183. multiplier: 1
  184. divisor: 100 if expvar_type == float, 1 if expvar_type == int
  185. hidden: False
  186. ```
  187. Please see the following link for more information about the options and their default values:
  188. [External plugins - dimensions](https://github.com/netdata/netdata/blob/master/collectors/plugins.d/README.md#dimension)
  189. Apart from top-level expvars, this plugin can also parse expvars stored in a multi-level map;
  190. All dicts in the resulting JSON document are then flattened to one level.
  191. Expvar names are joined together with '.' when flattening.
  192. Example:
  193. ```
  194. {
  195. "counters": {"cnt1": 1042, "cnt2": 1512.9839999999983},
  196. "runtime.goroutines": 5
  197. }
  198. ```
  199. In the above case, the exported variables will be available under `runtime.goroutines`,
  200. `counters.cnt1` and `counters.cnt2` expvar_keys. If the flattening results in a key collision,
  201. the first defined key wins and all subsequent keys with the same name are ignored.
  202. config: |
  203. app1:
  204. name : 'app1'
  205. url : 'http://127.0.0.1:8080/debug/vars'
  206. collect_memstats: true
  207. extra_charts:
  208. - id: "runtime_goroutines"
  209. options:
  210. name: num_goroutines
  211. title: "runtime: number of goroutines"
  212. units: goroutines
  213. family: runtime
  214. context: expvar.runtime.goroutines
  215. chart_type: line
  216. lines:
  217. - {expvar_key: 'runtime.goroutines', expvar_type: int, id: runtime_goroutines}
  218. - id: "foo_counters"
  219. options:
  220. name: counters
  221. title: "some random counters"
  222. units: awesomeness
  223. family: counters
  224. context: expvar.foo.counters
  225. chart_type: line
  226. lines:
  227. - {expvar_key: 'counters.cnt1', expvar_type: int, id: counters_cnt1}
  228. - {expvar_key: 'counters.cnt2', expvar_type: float, id: counters_cnt2}
  229. troubleshooting:
  230. problems:
  231. list: []
  232. alerts: []
  233. metrics:
  234. folding:
  235. title: Metrics
  236. enabled: false
  237. description: ""
  238. availability: []
  239. scopes:
  240. - name: global
  241. description: "These metrics refer to the entire monitored application."
  242. labels: []
  243. metrics:
  244. - name: expvar.memstats.heap
  245. description: "memory: size of heap memory structures"
  246. unit: "KiB"
  247. chart_type: line
  248. dimensions:
  249. - name: alloc
  250. - name: inuse
  251. - name: expvar.memstats.stack
  252. description: "memory: size of stack memory structures"
  253. unit: "KiB"
  254. chart_type: line
  255. dimensions:
  256. - name: inuse
  257. - name: expvar.memstats.mspan
  258. description: "memory: size of mspan memory structures"
  259. unit: "KiB"
  260. chart_type: line
  261. dimensions:
  262. - name: inuse
  263. - name: expvar.memstats.mcache
  264. description: "memory: size of mcache memory structures"
  265. unit: "KiB"
  266. chart_type: line
  267. dimensions:
  268. - name: inuse
  269. - name: expvar.memstats.live_objects
  270. description: "memory: number of live objects"
  271. unit: "objects"
  272. chart_type: line
  273. dimensions:
  274. - name: live
  275. - name: expvar.memstats.sys
  276. description: "memory: size of reserved virtual address space"
  277. unit: "KiB"
  278. chart_type: line
  279. dimensions:
  280. - name: sys
  281. - name: expvar.memstats.gc_pauses
  282. description: "memory: average duration of GC pauses"
  283. unit: "ns"
  284. chart_type: line
  285. dimensions:
  286. - name: avg