Fix handling of troubleshooting section in integrations. (#15700)
* Fix handling of troubleshooting section in integrations. * Fix plugin_name key path.
Austin S. Hemmelgarn committed
Aug 2, 2023 at 08:32 UTC
f1a28f5137b4c76d9b5405c2a12f7164895f7efe
6 files changed
+103
-60
integrations/gen_integrations.py
+27
-16
@@ -56,11 +56,13 @@ COLLECTOR_RENDER_KEYS = [
56
EXPORTER_RENDER_KEYS = [
57
'overview',
58
'setup',
59
+ 'troubleshooting',
60
]
61
62
NOTIFICATION_RENDER_KEYS = [
63
'overview',
64
'setup',
65
+ 'troubleshooting',
66
]
67
68
GITHUB_ACTIONS = os.environ.get('GITHUB_ACTIONS', False)
@@ -473,12 +475,15 @@ def render_collectors(categories, collectors, ids):
475
}
476
477
for key in COLLECTOR_RENDER_KEYS:
476
- template = get_jinja_env().get_template(f'{ key }.md')
477
- data = template.render(entry=item, related=related)
478
+ if key in item.keys():
479
+ template = get_jinja_env().get_template(f'{ key }.md')
480
+ data = template.render(entry=item, related=related)
481
479
- if 'variables' in item['meta']['monitored_instance']:
480
- template = get_jinja_env().from_string(data)
481
- data = template.render(variables=item['meta']['monitored_instance']['variables'])
482
+ if 'variables' in item['meta']['monitored_instance']:
483
+ template = get_jinja_env().from_string(data)
484
+ data = template.render(variables=item['meta']['monitored_instance']['variables'])
485
+ else:
486
+ data = ''
487
488
item[key] = data
489
@@ -540,12 +545,15 @@ def render_exporters(categories, exporters, ids):
545
546
for item in exporters:
547
for key in EXPORTER_RENDER_KEYS:
543
- template = get_jinja_env().get_template(f'{ key }.md')
544
- data = template.render(entry=item)
548
+ if key in item.keys():
549
+ template = get_jinja_env().get_template(f'{ key }.md')
550
+ data = template.render(entry=item)
551
546
- if 'variables' in item['meta']:
547
- template = get_jinja_env().from_string(data)
548
- data = template.render(variables=item['meta']['variables'])
552
+ if 'variables' in item['meta']:
553
+ template = get_jinja_env().from_string(data)
554
+ data = template.render(variables=item['meta']['variables'])
555
+ else:
556
+ data = ''
557
558
item[key] = data
559
@@ -569,12 +577,15 @@ def render_notifications(categories, notifications, ids):
577
578
for item in notifications:
579
for key in NOTIFICATION_RENDER_KEYS:
572
- template = get_jinja_env().get_template(f'{ key }.md')
573
- data = template.render(entry=item)
574
-
575
- if 'variables' in item['meta']:
576
- template = get_jinja_env().from_string(data)
577
- data = template.render(variables=item['meta']['variables'])
580
+ if key in item.keys():
581
+ template = get_jinja_env().get_template(f'{ key }.md')
582
+ data = template.render(entry=item)
583
+
584
+ if 'variables' in item['meta']:
585
+ template = get_jinja_env().from_string(data)
586
+ data = template.render(variables=item['meta']['variables'])
587
+ else:
588
+ data = ''
589
590
item[key] = data
591
integrations/schemas/collector.json
+1
-37
@@ -222,43 +222,7 @@
222
"$ref": "./shared.json#/$defs/full_setup"
223
},
224
"troubleshooting": {
225
- "type": "object",
226
- "description": "Information needed to troubleshoot issues with this collector.",
227
- "properties": {
228
- "problems": {
229
- "type": "object",
230
- "description": "Common problems that users face again and again... and their solutions.",
231
- "properties": {
232
- "list": {
233
- "type": "array",
234
- "description": "List of common problems.",
235
- "items": {
236
- "type": "object",
237
- "properties": {
238
- "name": {
239
- "type": "string",
240
- "description": "Problem name."
241
- },
242
- "description": {
243
- "type": "string",
244
- "description": "Explanation of the problem and its solution."
245
- }
246
- }
247
- },
248
- "required": [
249
- "name",
250
- "description"
251
- ]
252
- }
253
- },
254
- "required": [
255
- "list"
256
- ]
257
- }
258
- },
259
- "required": [
260
- "problems"
261
- ]
225
+ "$ref": "./shared.json#/$defs/troubleshooting"
226
},
227
"alerts": {
228
"type": "array",
integrations/schemas/exporter.json
+3
@@ -46,6 +46,9 @@
46
},
47
"setup": {
48
"$ref": "./shared.json#/$defs/full_setup"
49
+ },
50
+ "troubleshooting": {
51
+ "$ref": "./shared.json#/$defs/troubleshooting"
52
}
53
},
54
"required": [
integrations/schemas/notification.json
+3
@@ -70,6 +70,9 @@
70
"$ref": "./shared.json#/$defs/full_setup"
71
}
72
]
73
+ },
74
+ "troubleshooting": {
75
+ "$ref": "./shared.json#/$defs/troubleshooting"
76
}
77
},
78
"required": [
integrations/schemas/shared.json
+39
@@ -249,6 +249,45 @@
249
"configuration"
250
]
251
},
252
+ "troubleshooting": {
253
+ "type": "object",
254
+ "description": "Information needed to troubleshoot issues with this collector.",
255
+ "properties": {
256
+ "problems": {
257
+ "type": "object",
258
+ "description": "Common problems that users face again and again... and their solutions.",
259
+ "properties": {
260
+ "list": {
261
+ "type": "array",
262
+ "description": "List of common problems.",
263
+ "items": {
264
+ "type": "object",
265
+ "properties": {
266
+ "name": {
267
+ "type": "string",
268
+ "description": "Problem name."
269
+ },
270
+ "description": {
271
+ "type": "string",
272
+ "description": "Explanation of the problem and its solution."
273
+ }
274
+ }
275
+ },
276
+ "required": [
277
+ "name",
278
+ "description"
279
+ ]
280
+ }
281
+ },
282
+ "required": [
283
+ "list"
284
+ ]
285
+ }
286
+ },
287
+ "required": [
288
+ "problems"
289
+ ]
290
+ },
291
"_folding": {
292
"type": "object",
293
"description": "Content folding settings.",
integrations/templates/troubleshooting.md
+30
-7
@@ -1,8 +1,7 @@
1
-[% if entry.troubleshooting.list or entry.integration_type == 'collector' or entry.integration_type == 'notification' %]
1
+[% if entry.integration_type == 'collector' %]
2
+[% if entry.meta.plugin_name == 'go.d.plugin' %]
3
## Troubleshooting
4
4
-[% if entry.integration_type == 'collector' %]
5
-[% if entry.plugin_name == 'go.d.plugin' %]
5
### Debug Mode
6
7
To troubleshoot issues with the `[[ entry.module_name ]]` collector, run the `go.d.plugin` with the debug option enabled. The output
@@ -26,7 +25,10 @@ should give you clues as to why the collector isn't working.
25
```bash
26
./go.d.plugin -d -m [[ entry.module_name ]]
27
```
29
-[% elif entry.plugin_name == 'python.d.plugin' %]
28
+
29
+[% elif entry.meta.plugin_name == 'python.d.plugin' %]
30
+## Troubleshooting
31
+
32
### Debug Mode
33
34
To troubleshoot issues with the `[[ entry.module_name ]]` collector, run the `python.d.plugin` with the debug option enabled. The output
@@ -50,7 +52,10 @@ should give you clues as to why the collector isn't working.
52
```bash
53
./python.d.plugin [[ entry.module_name ]] debug trace
54
```
53
-[% elif entry.plugin_name == 'charts.d.plugin' %]
55
+
56
+[% elif entry.meta.plugin_name == 'charts.d.plugin' %]
57
+## Troubleshooting
58
+
59
### Debug Mode
60
61
To troubleshoot issues with the `[[ entry.module_name ]]` collector, run the `charts.d.plugin` with the debug option enabled. The output
@@ -74,9 +79,22 @@ should give you clues as to why the collector isn't working.
79
```bash
80
./charts.d.plugin debug 1 [[ entry.module_name ]]
81
```
82
+
83
+[% else %]
84
+[% if entry.troubleshooting.problems.list %]
85
+## Troubleshooting
86
+
87
+[% endif %]
88
[% endif %]
89
[% elif entry.integration_type == 'notification' %]
79
-[% if not 'cloud-notifications' in entry._src_path %]
90
+[% if 'cloud-notifications' in entry._src_path %]
91
+[% if entry.troubleshooting.problems.list %]
92
+## Troubleshooting
93
+
94
+[% endif %]
95
+[% else %]
96
+## Troubleshooting
97
+
98
### Test Notification
99
100
You can run the following command by hand, to test alerts configuration:
@@ -96,9 +114,14 @@ export NETDATA_ALARM_NOTIFY_DEBUG=1
114
```
115
116
Note that this will test _all_ alert mechanisms for the selected role.
117
+
118
+[% elif entry.integration_type == 'exporter' %]
119
+[% if entry.troubleshooting.problems.list %]
120
+## Troubleshooting
121
+
122
[% endif %]
123
[% endif %]
101
-[% for item in entry.troubleshooting.list %]
124
+[% for item in entry.troubleshooting.problems.list %]
125
### [[ item.name ]]
126
127
[[ description ]]