metadata.yaml 14 KB

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