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