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