metadata.yaml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. plugin_name: python.d.plugin
  2. modules:
  3. - meta:
  4. plugin_name: python.d.plugin
  5. module_name: pandas
  6. monitored_instance:
  7. name: Pandas
  8. link: https://pandas.pydata.org/
  9. categories:
  10. - data-collection.generic-data-collection
  11. icon_filename: pandas.png
  12. related_resources:
  13. integrations:
  14. list: []
  15. info_provided_to_referring_integrations:
  16. description: ""
  17. keywords:
  18. - pandas
  19. - python
  20. most_popular: false
  21. overview:
  22. data_collection:
  23. metrics_description: |
  24. [Pandas](https://pandas.pydata.org/) is a de-facto standard in reading and processing most types of structured data in Python.
  25. If you have metrics appearing in a CSV, JSON, XML, HTML, or [other supported format](https://pandas.pydata.org/docs/user_guide/io.html),
  26. either locally or via some HTTP endpoint, you can easily ingest and present those metrics in Netdata, by leveraging the Pandas collector.
  27. This collector can be used to collect pretty much anything that can be read by Pandas, and then processed by Pandas.
  28. method_description: |
  29. The collector uses [pandas](https://pandas.pydata.org/) to pull data and do pandas-based preprocessing, before feeding to Netdata.
  30. supported_platforms:
  31. include: []
  32. exclude: []
  33. multi_instance: true
  34. additional_permissions:
  35. description: ""
  36. default_behavior:
  37. auto_detection:
  38. description: ""
  39. limits:
  40. description: ""
  41. performance_impact:
  42. description: ""
  43. setup:
  44. prerequisites:
  45. list:
  46. - title: Python Requirements
  47. description: |
  48. This collector depends on some Python (Python 3 only) packages that can usually be installed via `pip` or `pip3`.
  49. ```bash
  50. sudo pip install pandas requests
  51. ```
  52. Note: If you would like to use [`pandas.read_sql`](https://pandas.pydata.org/docs/reference/api/pandas.read_sql.html) to query a database, you will need to install the below packages as well.
  53. ```bash
  54. sudo pip install 'sqlalchemy<2.0' psycopg2-binary
  55. ```
  56. configuration:
  57. file:
  58. name: python.d/pandas.conf
  59. description: ""
  60. options:
  61. description: |
  62. There are 2 sections:
  63. * Global variables
  64. * One or more JOBS that can define multiple different instances to monitor.
  65. 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.
  66. Additionally, the following collapsed table contains all the options that can be configured inside a JOB definition.
  67. Every configuration JOB starts with a `job_name` value which will appear in the dashboard, unless a `name` parameter is specified.
  68. folding:
  69. title: Config options
  70. enabled: true
  71. list:
  72. - name: chart_configs
  73. description: an array of chart configuration dictionaries
  74. default_value: "[]"
  75. required: true
  76. - name: chart_configs.name
  77. description: name of the chart to be displayed in the dashboard.
  78. default_value: None
  79. required: true
  80. - name: chart_configs.title
  81. description: title of the chart to be displayed in the dashboard.
  82. default_value: None
  83. required: true
  84. - name: chart_configs.family
  85. description: "[family](https://github.com/netdata/netdata/blob/master/docs/cloud/visualize/interact-new-charts.md#families) of the chart to be displayed in the dashboard."
  86. default_value: None
  87. required: true
  88. - name: chart_configs.context
  89. description: "[context](https://github.com/netdata/netdata/blob/master/docs/cloud/visualize/interact-new-charts.md#contexts) of the chart to be displayed in the dashboard."
  90. default_value: None
  91. required: true
  92. - name: chart_configs.type
  93. description: the type of the chart to be displayed in the dashboard.
  94. default_value: None
  95. required: true
  96. - name: chart_configs.units
  97. description: the units of the chart to be displayed in the dashboard.
  98. default_value: None
  99. required: true
  100. - name: chart_configs.df_steps
  101. description: a series of pandas operations (one per line) that each returns a dataframe.
  102. default_value: None
  103. required: true
  104. - name: update_every
  105. description: Sets the default data collection frequency.
  106. default_value: 5
  107. required: false
  108. - name: priority
  109. description: Controls the order of charts at the netdata dashboard.
  110. default_value: 60000
  111. required: false
  112. - name: autodetection_retry
  113. description: Sets the job re-check interval in seconds.
  114. default_value: 0
  115. required: false
  116. - name: penalty
  117. description: Indicates whether to apply penalty to update_every in case of failures.
  118. default_value: yes
  119. required: false
  120. - name: name
  121. 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.
  122. default_value: ""
  123. required: false
  124. examples:
  125. folding:
  126. enabled: true
  127. title: Config
  128. list:
  129. - name: Temperature API Example
  130. folding:
  131. enabled: true
  132. description: example pulling some hourly temperature data, a chart for today forecast (mean,min,max) and another chart for current.
  133. config: |
  134. temperature:
  135. name: "temperature"
  136. update_every: 5
  137. chart_configs:
  138. - name: "temperature_forecast_by_city"
  139. title: "Temperature By City - Today Forecast"
  140. family: "temperature.today"
  141. context: "pandas.temperature"
  142. type: "line"
  143. units: "Celsius"
  144. df_steps: >
  145. pd.DataFrame.from_dict(
  146. {city: requests.get(f'https://api.open-meteo.com/v1/forecast?latitude={lat}&longitude={lng}&hourly=temperature_2m').json()['hourly']['temperature_2m']
  147. for (city,lat,lng)
  148. in [
  149. ('dublin', 53.3441, -6.2675),
  150. ('athens', 37.9792, 23.7166),
  151. ('london', 51.5002, -0.1262),
  152. ('berlin', 52.5235, 13.4115),
  153. ('paris', 48.8567, 2.3510),
  154. ('madrid', 40.4167, -3.7033),
  155. ('new_york', 40.71, -74.01),
  156. ('los_angeles', 34.05, -118.24),
  157. ]
  158. }
  159. );
  160. df.describe(); # get aggregate stats for each city;
  161. df.transpose()[['mean', 'max', 'min']].reset_index(); # just take mean, min, max;
  162. df.rename(columns={'index':'city'}); # some column renaming;
  163. df.pivot(columns='city').mean().to_frame().reset_index(); # force to be one row per city;
  164. df.rename(columns={0:'degrees'}); # some column renaming;
  165. pd.concat([df, df['city']+'_'+df['level_0']], axis=1); # add new column combining city and summary measurement label;
  166. df.rename(columns={0:'measurement'}); # some column renaming;
  167. df[['measurement', 'degrees']].set_index('measurement'); # just take two columns we want;
  168. df.sort_index(); # sort by city name;
  169. df.transpose(); # transpose so its just one wide row;
  170. - name: "temperature_current_by_city"
  171. title: "Temperature By City - Current"
  172. family: "temperature.current"
  173. context: "pandas.temperature"
  174. type: "line"
  175. units: "Celsius"
  176. df_steps: >
  177. pd.DataFrame.from_dict(
  178. {city: requests.get(f'https://api.open-meteo.com/v1/forecast?latitude={lat}&longitude={lng}&current_weather=true').json()['current_weather']
  179. for (city,lat,lng)
  180. in [
  181. ('dublin', 53.3441, -6.2675),
  182. ('athens', 37.9792, 23.7166),
  183. ('london', 51.5002, -0.1262),
  184. ('berlin', 52.5235, 13.4115),
  185. ('paris', 48.8567, 2.3510),
  186. ('madrid', 40.4167, -3.7033),
  187. ('new_york', 40.71, -74.01),
  188. ('los_angeles', 34.05, -118.24),
  189. ]
  190. }
  191. );
  192. df.transpose();
  193. df[['temperature']];
  194. df.transpose();
  195. - name: API CSV Example
  196. folding:
  197. enabled: true
  198. description: example showing a read_csv from a url and some light pandas data wrangling.
  199. config: |
  200. example_csv:
  201. name: "example_csv"
  202. update_every: 2
  203. chart_configs:
  204. - name: "london_system_cpu"
  205. title: "London System CPU - Ratios"
  206. family: "london_system_cpu"
  207. context: "pandas"
  208. type: "line"
  209. units: "n"
  210. df_steps: >
  211. pd.read_csv('https://london.my-netdata.io/api/v1/data?chart=system.cpu&format=csv&after=-60', storage_options={'User-Agent': 'netdata'});
  212. df.drop('time', axis=1);
  213. df.mean().to_frame().transpose();
  214. df.apply(lambda row: (row.user / row.system), axis = 1).to_frame();
  215. df.rename(columns={0:'average_user_system_ratio'});
  216. df*100;
  217. - name: API JSON Example
  218. folding:
  219. enabled: true
  220. description: example showing a read_json from a url and some light pandas data wrangling.
  221. config: |
  222. example_json:
  223. name: "example_json"
  224. update_every: 2
  225. chart_configs:
  226. - name: "london_system_net"
  227. title: "London System Net - Total Bandwidth"
  228. family: "london_system_net"
  229. context: "pandas"
  230. type: "area"
  231. units: "kilobits/s"
  232. df_steps: >
  233. pd.DataFrame(requests.get('https://london.my-netdata.io/api/v1/data?chart=system.net&format=json&after=-1').json()['data'], columns=requests.get('https://london.my-netdata.io/api/v1/data?chart=system.net&format=json&after=-1').json()['labels']);
  234. df.drop('time', axis=1);
  235. abs(df);
  236. df.sum(axis=1).to_frame();
  237. df.rename(columns={0:'total_bandwidth'});
  238. - name: XML Example
  239. folding:
  240. enabled: true
  241. description: example showing a read_xml from a url and some light pandas data wrangling.
  242. config: |
  243. example_xml:
  244. name: "example_xml"
  245. update_every: 2
  246. line_sep: "|"
  247. chart_configs:
  248. - name: "temperature_forcast"
  249. title: "Temperature Forecast"
  250. family: "temp"
  251. context: "pandas.temp"
  252. type: "line"
  253. units: "celsius"
  254. df_steps: >
  255. pd.read_xml('http://metwdb-openaccess.ichec.ie/metno-wdb2ts/locationforecast?lat=54.7210798611;long=-8.7237392806', xpath='./product/time[1]/location/temperature', parser='etree')|
  256. df.rename(columns={'value': 'dublin'})|
  257. df[['dublin']]|
  258. - name: SQL Example
  259. folding:
  260. enabled: true
  261. description: example showing a read_sql from a postgres database using sqlalchemy.
  262. config: |
  263. sql:
  264. name: "sql"
  265. update_every: 5
  266. chart_configs:
  267. - name: "sql"
  268. title: "SQL Example"
  269. family: "sql.example"
  270. context: "example"
  271. type: "line"
  272. units: "percent"
  273. df_steps: >
  274. pd.read_sql_query(
  275. sql='\
  276. select \
  277. random()*100 as metric_1, \
  278. random()*100 as metric_2 \
  279. ',
  280. con=create_engine('postgresql://localhost/postgres?user=netdata&password=netdata')
  281. );
  282. troubleshooting:
  283. problems:
  284. list: []
  285. alerts: []
  286. metrics:
  287. folding:
  288. title: Metrics
  289. enabled: false
  290. description: |
  291. This collector is expecting one row in the final pandas DataFrame. It is that first row that will be taken
  292. as the most recent values for each dimension on each chart using (`df.to_dict(orient='records')[0]`).
  293. See [pd.to_dict()](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.to_dict.html)."
  294. availability: []
  295. scopes:
  296. - name: global
  297. description: |
  298. These metrics refer to the entire monitored application.
  299. labels: []
  300. metrics: []