0
0
Fork 0
mirror of https://github.com/netdata/netdata.git synced 2025-04-06 06:25:32 +00:00

Fix handling of troubleshooting section in integrations. ()

* Fix handling of troubleshooting section in integrations.

* Fix plugin_name key path.
This commit is contained in:
Austin S. Hemmelgarn 2023-08-02 08:32:17 -04:00 committed by GitHub
parent 256f22ff09
commit f1a28f5137
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 102 additions and 59 deletions

View file

@ -56,11 +56,13 @@ COLLECTOR_RENDER_KEYS = [
EXPORTER_RENDER_KEYS = [ EXPORTER_RENDER_KEYS = [
'overview', 'overview',
'setup', 'setup',
'troubleshooting',
] ]
NOTIFICATION_RENDER_KEYS = [ NOTIFICATION_RENDER_KEYS = [
'overview', 'overview',
'setup', 'setup',
'troubleshooting',
] ]
GITHUB_ACTIONS = os.environ.get('GITHUB_ACTIONS', False) GITHUB_ACTIONS = os.environ.get('GITHUB_ACTIONS', False)
@ -473,12 +475,15 @@ def render_collectors(categories, collectors, ids):
} }
for key in COLLECTOR_RENDER_KEYS: for key in COLLECTOR_RENDER_KEYS:
template = get_jinja_env().get_template(f'{ key }.md') if key in item.keys():
data = template.render(entry=item, related=related) template = get_jinja_env().get_template(f'{ key }.md')
data = template.render(entry=item, related=related)
if 'variables' in item['meta']['monitored_instance']: if 'variables' in item['meta']['monitored_instance']:
template = get_jinja_env().from_string(data) template = get_jinja_env().from_string(data)
data = template.render(variables=item['meta']['monitored_instance']['variables']) data = template.render(variables=item['meta']['monitored_instance']['variables'])
else:
data = ''
item[key] = data item[key] = data
@ -540,12 +545,15 @@ def render_exporters(categories, exporters, ids):
for item in exporters: for item in exporters:
for key in EXPORTER_RENDER_KEYS: for key in EXPORTER_RENDER_KEYS:
template = get_jinja_env().get_template(f'{ key }.md') if key in item.keys():
data = template.render(entry=item) template = get_jinja_env().get_template(f'{ key }.md')
data = template.render(entry=item)
if 'variables' in item['meta']: if 'variables' in item['meta']:
template = get_jinja_env().from_string(data) template = get_jinja_env().from_string(data)
data = template.render(variables=item['meta']['variables']) data = template.render(variables=item['meta']['variables'])
else:
data = ''
item[key] = data item[key] = data
@ -569,12 +577,15 @@ def render_notifications(categories, notifications, ids):
for item in notifications: for item in notifications:
for key in NOTIFICATION_RENDER_KEYS: for key in NOTIFICATION_RENDER_KEYS:
template = get_jinja_env().get_template(f'{ key }.md') if key in item.keys():
data = template.render(entry=item) template = get_jinja_env().get_template(f'{ key }.md')
data = template.render(entry=item)
if 'variables' in item['meta']: if 'variables' in item['meta']:
template = get_jinja_env().from_string(data) template = get_jinja_env().from_string(data)
data = template.render(variables=item['meta']['variables']) data = template.render(variables=item['meta']['variables'])
else:
data = ''
item[key] = data item[key] = data

View file

@ -222,43 +222,7 @@
"$ref": "./shared.json#/$defs/full_setup" "$ref": "./shared.json#/$defs/full_setup"
}, },
"troubleshooting": { "troubleshooting": {
"type": "object", "$ref": "./shared.json#/$defs/troubleshooting"
"description": "Information needed to troubleshoot issues with this collector.",
"properties": {
"problems": {
"type": "object",
"description": "Common problems that users face again and again... and their solutions.",
"properties": {
"list": {
"type": "array",
"description": "List of common problems.",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "Problem name."
},
"description": {
"type": "string",
"description": "Explanation of the problem and its solution."
}
}
},
"required": [
"name",
"description"
]
}
},
"required": [
"list"
]
}
},
"required": [
"problems"
]
}, },
"alerts": { "alerts": {
"type": "array", "type": "array",

View file

@ -46,6 +46,9 @@
}, },
"setup": { "setup": {
"$ref": "./shared.json#/$defs/full_setup" "$ref": "./shared.json#/$defs/full_setup"
},
"troubleshooting": {
"$ref": "./shared.json#/$defs/troubleshooting"
} }
}, },
"required": [ "required": [

View file

@ -70,6 +70,9 @@
"$ref": "./shared.json#/$defs/full_setup" "$ref": "./shared.json#/$defs/full_setup"
} }
] ]
},
"troubleshooting": {
"$ref": "./shared.json#/$defs/troubleshooting"
} }
}, },
"required": [ "required": [

View file

@ -249,6 +249,45 @@
"configuration" "configuration"
] ]
}, },
"troubleshooting": {
"type": "object",
"description": "Information needed to troubleshoot issues with this collector.",
"properties": {
"problems": {
"type": "object",
"description": "Common problems that users face again and again... and their solutions.",
"properties": {
"list": {
"type": "array",
"description": "List of common problems.",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "Problem name."
},
"description": {
"type": "string",
"description": "Explanation of the problem and its solution."
}
}
},
"required": [
"name",
"description"
]
}
},
"required": [
"list"
]
}
},
"required": [
"problems"
]
},
"_folding": { "_folding": {
"type": "object", "type": "object",
"description": "Content folding settings.", "description": "Content folding settings.",

View file

@ -1,8 +1,7 @@
[% if entry.troubleshooting.list or entry.integration_type == 'collector' or entry.integration_type == 'notification' %] [% if entry.integration_type == 'collector' %]
[% if entry.meta.plugin_name == 'go.d.plugin' %]
## Troubleshooting ## Troubleshooting
[% if entry.integration_type == 'collector' %]
[% if entry.plugin_name == 'go.d.plugin' %]
### Debug Mode ### Debug Mode
To troubleshoot issues with the `[[ entry.module_name ]]` collector, run the `go.d.plugin` with the debug option enabled. The output 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.
```bash ```bash
./go.d.plugin -d -m [[ entry.module_name ]] ./go.d.plugin -d -m [[ entry.module_name ]]
``` ```
[% elif entry.plugin_name == 'python.d.plugin' %]
[% elif entry.meta.plugin_name == 'python.d.plugin' %]
## Troubleshooting
### Debug Mode ### Debug Mode
To troubleshoot issues with the `[[ entry.module_name ]]` collector, run the `python.d.plugin` with the debug option enabled. The output 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.
```bash ```bash
./python.d.plugin [[ entry.module_name ]] debug trace ./python.d.plugin [[ entry.module_name ]] debug trace
``` ```
[% elif entry.plugin_name == 'charts.d.plugin' %]
[% elif entry.meta.plugin_name == 'charts.d.plugin' %]
## Troubleshooting
### Debug Mode ### Debug Mode
To troubleshoot issues with the `[[ entry.module_name ]]` collector, run the `charts.d.plugin` with the debug option enabled. The output 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.
```bash ```bash
./charts.d.plugin debug 1 [[ entry.module_name ]] ./charts.d.plugin debug 1 [[ entry.module_name ]]
``` ```
[% else %]
[% if entry.troubleshooting.problems.list %]
## Troubleshooting
[% endif %]
[% endif %] [% endif %]
[% elif entry.integration_type == 'notification' %] [% elif entry.integration_type == 'notification' %]
[% if not 'cloud-notifications' in entry._src_path %] [% if 'cloud-notifications' in entry._src_path %]
[% if entry.troubleshooting.problems.list %]
## Troubleshooting
[% endif %]
[% else %]
## Troubleshooting
### Test Notification ### Test Notification
You can run the following command by hand, to test alerts configuration: You can run the following command by hand, to test alerts configuration:
@ -96,9 +114,14 @@ export NETDATA_ALARM_NOTIFY_DEBUG=1
``` ```
Note that this will test _all_ alert mechanisms for the selected role. Note that this will test _all_ alert mechanisms for the selected role.
[% elif entry.integration_type == 'exporter' %]
[% if entry.troubleshooting.problems.list %]
## Troubleshooting
[% endif %] [% endif %]
[% endif %] [% endif %]
[% for item in entry.troubleshooting.list %] [% for item in entry.troubleshooting.problems.list %]
### [[ item.name ]] ### [[ item.name ]]
[[ description ]] [[ description ]]