mirror of
https://github.com/netdata/netdata.git
synced 2025-04-12 16:58:10 +00:00
Remove the overview section from cloud notif. integrations (#18754)
Co-authored-by: ilyam8 <ilya@netdata.cloud>
This commit is contained in:
parent
fc38335b40
commit
0ab7826301
7 changed files with 338 additions and 153 deletions
integrations
|
@ -11,9 +11,6 @@
|
||||||
- mobile-app
|
- mobile-app
|
||||||
- phone
|
- phone
|
||||||
- personal-notifications
|
- personal-notifications
|
||||||
overview:
|
|
||||||
notification_description: "You can configure notification delivery to the Netdata Mobile Application from the Netdata Cloud UI."
|
|
||||||
notification_limitations: ""
|
|
||||||
setup:
|
setup:
|
||||||
description: |
|
description: |
|
||||||
### Prerequisites
|
### Prerequisites
|
||||||
|
@ -44,9 +41,6 @@
|
||||||
keywords:
|
keywords:
|
||||||
- discord
|
- discord
|
||||||
- community
|
- community
|
||||||
overview:
|
|
||||||
notification_description: "You can configure notification delivery to your Discord server from the Netdata Cloud UI."
|
|
||||||
notification_limitations: ""
|
|
||||||
setup:
|
setup:
|
||||||
description: |
|
description: |
|
||||||
### Prerequisites
|
### Prerequisites
|
||||||
|
@ -85,9 +79,6 @@
|
||||||
icon_filename: "pagerduty.png"
|
icon_filename: "pagerduty.png"
|
||||||
keywords:
|
keywords:
|
||||||
- pagerduty
|
- pagerduty
|
||||||
overview:
|
|
||||||
notification_description: "You can configure notification delivery to PagerDuty from the Netdata Cloud UI."
|
|
||||||
notification_limitations: ""
|
|
||||||
setup:
|
setup:
|
||||||
description: |
|
description: |
|
||||||
### Prerequisites
|
### Prerequisites
|
||||||
|
@ -127,9 +118,6 @@
|
||||||
icon_filename: "slack.png"
|
icon_filename: "slack.png"
|
||||||
keywords:
|
keywords:
|
||||||
- slack
|
- slack
|
||||||
overview:
|
|
||||||
notification_description: "You can configure notification delivery to Slack from the Netdata Cloud UI."
|
|
||||||
notification_limitations: ""
|
|
||||||
setup:
|
setup:
|
||||||
description: |
|
description: |
|
||||||
### Prerequisites
|
### Prerequisites
|
||||||
|
@ -175,9 +163,6 @@
|
||||||
keywords:
|
keywords:
|
||||||
- opsgenie
|
- opsgenie
|
||||||
- atlassian
|
- atlassian
|
||||||
overview:
|
|
||||||
notification_description: "You can configure notification delivery to Opsgenie from the Netdata Cloud UI."
|
|
||||||
notification_limitations: ""
|
|
||||||
setup:
|
setup:
|
||||||
description: |
|
description: |
|
||||||
### Prerequisites
|
### Prerequisites
|
||||||
|
@ -215,9 +200,6 @@
|
||||||
icon_filename: "mattermost.png"
|
icon_filename: "mattermost.png"
|
||||||
keywords:
|
keywords:
|
||||||
- mattermost
|
- mattermost
|
||||||
overview:
|
|
||||||
notification_description: "You can configure notification delivery to Mattermost from the Netdata Cloud UI."
|
|
||||||
notification_limitations: ""
|
|
||||||
setup:
|
setup:
|
||||||
description: |
|
description: |
|
||||||
### Prerequisites
|
### Prerequisites
|
||||||
|
@ -260,9 +242,6 @@
|
||||||
icon_filename: "rocketchat.png"
|
icon_filename: "rocketchat.png"
|
||||||
keywords:
|
keywords:
|
||||||
- rocketchat
|
- rocketchat
|
||||||
overview:
|
|
||||||
notification_description: "You can configure notification delivery to RocketChat from the Netdata Cloud UI."
|
|
||||||
notification_limitations: ""
|
|
||||||
setup:
|
setup:
|
||||||
description: |
|
description: |
|
||||||
### Prerequisites
|
### Prerequisites
|
||||||
|
@ -306,9 +285,6 @@
|
||||||
icon_filename: "awssns.png"
|
icon_filename: "awssns.png"
|
||||||
keywords:
|
keywords:
|
||||||
- awssns
|
- awssns
|
||||||
overview:
|
|
||||||
notification_description: "You can configure notification delivery to AWS SNS from the Netdata Cloud UI."
|
|
||||||
notification_limitations: ""
|
|
||||||
setup:
|
setup:
|
||||||
description: |
|
description: |
|
||||||
### Prerequisites
|
### Prerequisites
|
||||||
|
@ -351,9 +327,6 @@
|
||||||
keywords:
|
keywords:
|
||||||
- microsoft
|
- microsoft
|
||||||
- teams
|
- teams
|
||||||
overview:
|
|
||||||
notification_description: "You can configure notification delivery to a Microsoft Teams channel from the Netdata Cloud UI."
|
|
||||||
notification_limitations: ""
|
|
||||||
setup:
|
setup:
|
||||||
description: |
|
description: |
|
||||||
### Prerequisites
|
### Prerequisites
|
||||||
|
@ -396,9 +369,6 @@
|
||||||
icon_filename: "telegram.svg"
|
icon_filename: "telegram.svg"
|
||||||
keywords:
|
keywords:
|
||||||
- Telegram
|
- Telegram
|
||||||
overview:
|
|
||||||
notification_description: "You can configure notification delivery to Telegram from the Netdata Cloud UI."
|
|
||||||
notification_limitations: ""
|
|
||||||
setup:
|
setup:
|
||||||
description: |
|
description: |
|
||||||
### Prerequisites
|
### Prerequisites
|
||||||
|
@ -441,9 +411,6 @@
|
||||||
icon_filename: "splunk-black.svg"
|
icon_filename: "splunk-black.svg"
|
||||||
keywords:
|
keywords:
|
||||||
- Splunk
|
- Splunk
|
||||||
overview:
|
|
||||||
notification_description: "You can configure notification delivery to Splunk from the Netdata Cloud UI."
|
|
||||||
notification_limitations: ""
|
|
||||||
setup:
|
setup:
|
||||||
description: |
|
description: |
|
||||||
### Prerequisites
|
### Prerequisites
|
||||||
|
@ -479,9 +446,6 @@
|
||||||
- VictorOps
|
- VictorOps
|
||||||
- Splunk
|
- Splunk
|
||||||
- On-Call
|
- On-Call
|
||||||
overview:
|
|
||||||
notification_description: "You can configure notification delivery to Splunk On-Call/VictorOps from the Netdata Cloud UI."
|
|
||||||
notification_limitations: ""
|
|
||||||
setup:
|
setup:
|
||||||
description: |
|
description: |
|
||||||
### Prerequisites
|
### Prerequisites
|
||||||
|
@ -515,9 +479,6 @@
|
||||||
keywords:
|
keywords:
|
||||||
- generic webhooks
|
- generic webhooks
|
||||||
- webhooks
|
- webhooks
|
||||||
overview:
|
|
||||||
notification_description: "You can configure notification delivery to a webhook using a predefined schema from the Netdata Cloud UI."
|
|
||||||
notification_limitations: ""
|
|
||||||
setup:
|
setup:
|
||||||
description: |
|
description: |
|
||||||
### Prerequisites
|
### Prerequisites
|
||||||
|
@ -765,9 +726,6 @@
|
||||||
icon_filename: "ilert.svg"
|
icon_filename: "ilert.svg"
|
||||||
keywords:
|
keywords:
|
||||||
- ilert
|
- ilert
|
||||||
overview:
|
|
||||||
notification_description: "You can configure notification delivery to ilert from the Netdata Cloud UI."
|
|
||||||
notification_limitations: ""
|
|
||||||
setup:
|
setup:
|
||||||
description: |
|
description: |
|
||||||
### Prerequisites
|
### Prerequisites
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import json
|
import json
|
||||||
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import re
|
|
||||||
|
|
||||||
# Dictionary responsible for making the symbolic links at the end of the script's run.
|
# Dictionary responsible for making the symbolic links at the end of the script's run.
|
||||||
symlink_dict = {}
|
symlink_dict = {}
|
||||||
|
@ -29,6 +29,7 @@ def cleanup():
|
||||||
if "integrations" in str(element) and not "metadata.yaml" in str(element):
|
if "integrations" in str(element) and not "metadata.yaml" in str(element):
|
||||||
shutil.rmtree(element)
|
shutil.rmtree(element)
|
||||||
|
|
||||||
|
|
||||||
def generate_category_from_name(category_fragment, category_array):
|
def generate_category_from_name(category_fragment, category_array):
|
||||||
"""
|
"""
|
||||||
Takes a category ID in splitted form ("." as delimiter) and the array of the categories, and returns the proper category name that Learn expects.
|
Takes a category ID in splitted form ("." as delimiter) and the array of the categories, and returns the proper category name that Learn expects.
|
||||||
|
@ -79,10 +80,10 @@ def add_custom_edit_url(markdown_string, meta_yaml_link, sidebar_label_string, m
|
||||||
if mode == 'default':
|
if mode == 'default':
|
||||||
path_to_md_file = f'{meta_yaml_link.replace("/metadata.yaml", "")}/integrations/{clean_string(sidebar_label_string)}'
|
path_to_md_file = f'{meta_yaml_link.replace("/metadata.yaml", "")}/integrations/{clean_string(sidebar_label_string)}'
|
||||||
|
|
||||||
elif mode == 'cloud-notifications':
|
elif mode == 'cloud-notification':
|
||||||
path_to_md_file = meta_yaml_link.replace("metadata.yaml", f'integrations/{clean_string(sidebar_label_string)}')
|
path_to_md_file = meta_yaml_link.replace("metadata.yaml", f'integrations/{clean_string(sidebar_label_string)}')
|
||||||
|
|
||||||
elif mode == 'agent-notifications':
|
elif mode == 'agent-notification':
|
||||||
path_to_md_file = meta_yaml_link.replace("metadata.yaml", "README")
|
path_to_md_file = meta_yaml_link.replace("metadata.yaml", "README")
|
||||||
|
|
||||||
elif mode == 'cloud-authentication':
|
elif mode == 'cloud-authentication':
|
||||||
|
@ -122,23 +123,29 @@ def read_integrations_js(path_to_file):
|
||||||
print("Exception", e)
|
print("Exception", e)
|
||||||
|
|
||||||
|
|
||||||
def create_overview(integration, filename):
|
def create_overview(integration, filename, overview_key_name="overview"):
|
||||||
|
# empty overview_key_name to have only image on overview
|
||||||
|
if not overview_key_name:
|
||||||
|
return f"""# {integration['meta']['name']}
|
||||||
|
|
||||||
split = re.split(r'(#.*\n)', integration['overview'], 1)
|
<img src="https://netdata.cloud/img/{filename}" width="150"/>
|
||||||
|
"""
|
||||||
|
|
||||||
|
split = re.split(r'(#.*\n)', integration[overview_key_name], 1)
|
||||||
|
|
||||||
first_overview_part = split[1]
|
first_overview_part = split[1]
|
||||||
rest_overview_part = split[2]
|
rest_overview_part = split[2]
|
||||||
|
|
||||||
if len(filename) > 0:
|
if not filename:
|
||||||
|
return f"""{first_overview_part}{rest_overview_part}
|
||||||
|
"""
|
||||||
|
|
||||||
return f"""{first_overview_part}
|
return f"""{first_overview_part}
|
||||||
|
|
||||||
<img src="https://netdata.cloud/img/{filename}" width="150"/>
|
<img src="https://netdata.cloud/img/{filename}" width="150"/>
|
||||||
|
|
||||||
{rest_overview_part}
|
{rest_overview_part}
|
||||||
"""
|
"""
|
||||||
else:
|
|
||||||
return f"""{first_overview_part}{rest_overview_part}
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
def build_readme_from_integration(integration, mode=''):
|
def build_readme_from_integration(integration, mode=''):
|
||||||
|
@ -150,7 +157,8 @@ def build_readme_from_integration(integration, mode=''):
|
||||||
meta_yaml = integration['edit_link'].replace("blob", "edit")
|
meta_yaml = integration['edit_link'].replace("blob", "edit")
|
||||||
sidebar_label = integration['meta']['monitored_instance']['name']
|
sidebar_label = integration['meta']['monitored_instance']['name']
|
||||||
learn_rel_path = generate_category_from_name(
|
learn_rel_path = generate_category_from_name(
|
||||||
integration['meta']['monitored_instance']['categories'][0].split("."), categories).replace("Data Collection", "Collecting Metrics")
|
integration['meta']['monitored_instance']['categories'][0].split("."), categories).replace(
|
||||||
|
"Data Collection", "Collecting Metrics")
|
||||||
most_popular = integration['meta']['most_popular']
|
most_popular = integration['meta']['most_popular']
|
||||||
|
|
||||||
# build the markdown string
|
# build the markdown string
|
||||||
|
@ -221,7 +229,7 @@ endmeta-->
|
||||||
print("Exception in exporter md construction", e, integration['id'])
|
print("Exception in exporter md construction", e, integration['id'])
|
||||||
|
|
||||||
# NOTIFICATIONS
|
# NOTIFICATIONS
|
||||||
elif mode == 'notification':
|
elif mode == 'agent-notification':
|
||||||
try:
|
try:
|
||||||
# initiate the variables for the notification method
|
# initiate the variables for the notification method
|
||||||
meta_yaml = integration['edit_link'].replace("blob", "edit")
|
meta_yaml = integration['edit_link'].replace("blob", "edit")
|
||||||
|
@ -238,7 +246,39 @@ learn_rel_path: "{learn_rel_path.replace("notifications", "Alerts & Notification
|
||||||
message: "DO NOT EDIT THIS FILE DIRECTLY, IT IS GENERATED BY THE NOTIFICATION'S metadata.yaml FILE"
|
message: "DO NOT EDIT THIS FILE DIRECTLY, IT IS GENERATED BY THE NOTIFICATION'S metadata.yaml FILE"
|
||||||
endmeta-->
|
endmeta-->
|
||||||
|
|
||||||
{create_overview(integration, integration['meta']['icon_filename'])}"""
|
{create_overview(integration, integration['meta']['icon_filename'], "overview")}"""
|
||||||
|
|
||||||
|
if integration['setup']:
|
||||||
|
md += f"""
|
||||||
|
{integration['setup']}
|
||||||
|
"""
|
||||||
|
|
||||||
|
if integration['troubleshooting']:
|
||||||
|
md += f"""
|
||||||
|
{integration['troubleshooting']}
|
||||||
|
"""
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
print("Exception in notification md construction", e, integration['id'])
|
||||||
|
|
||||||
|
elif mode == 'cloud-notification':
|
||||||
|
try:
|
||||||
|
# initiate the variables for the notification method
|
||||||
|
meta_yaml = integration['edit_link'].replace("blob", "edit")
|
||||||
|
sidebar_label = integration['meta']['name']
|
||||||
|
learn_rel_path = generate_category_from_name(integration['meta']['categories'][0].split("."), categories)
|
||||||
|
|
||||||
|
# build the markdown string
|
||||||
|
md = \
|
||||||
|
f"""<!--startmeta
|
||||||
|
meta_yaml: "{meta_yaml}"
|
||||||
|
sidebar_label: "{sidebar_label}"
|
||||||
|
learn_status: "Published"
|
||||||
|
learn_rel_path: "{learn_rel_path.replace("notifications", "Alerts & Notifications/Notifications")}"
|
||||||
|
message: "DO NOT EDIT THIS FILE DIRECTLY, IT IS GENERATED BY THE NOTIFICATION'S metadata.yaml FILE"
|
||||||
|
endmeta-->
|
||||||
|
|
||||||
|
{create_overview(integration, integration['meta']['icon_filename'], "")}"""
|
||||||
|
|
||||||
if integration['setup']:
|
if integration['setup']:
|
||||||
md += f"""
|
md += f"""
|
||||||
|
@ -339,9 +379,8 @@ def write_to_file(path, md, meta_yaml, sidebar_label, community, mode='default')
|
||||||
except KeyError:
|
except KeyError:
|
||||||
# We don't need to print something here.
|
# We don't need to print something here.
|
||||||
pass
|
pass
|
||||||
elif mode == 'notification':
|
elif mode == 'cloud-notification':
|
||||||
|
|
||||||
if "cloud-notifications" in path:
|
|
||||||
# for cloud notifications we generate them near their metadata.yaml
|
# for cloud notifications we generate them near their metadata.yaml
|
||||||
name = clean_string(integration['meta']['name'])
|
name = clean_string(integration['meta']['name'])
|
||||||
|
|
||||||
|
@ -351,13 +390,22 @@ def write_to_file(path, md, meta_yaml, sidebar_label, community, mode='default')
|
||||||
# proper_edit_name = meta_yaml.replace(
|
# proper_edit_name = meta_yaml.replace(
|
||||||
# "metadata.yaml", f'integrations/{clean_string(sidebar_label)}.md\"')
|
# "metadata.yaml", f'integrations/{clean_string(sidebar_label)}.md\"')
|
||||||
|
|
||||||
md = add_custom_edit_url(md, meta_yaml, sidebar_label, mode='cloud-notifications')
|
md = add_custom_edit_url(md, meta_yaml, sidebar_label, mode='cloud-notification')
|
||||||
|
|
||||||
finalpath = f'{path}/integrations/{name}.md'
|
finalpath = f'{path}/integrations/{name}.md'
|
||||||
else:
|
|
||||||
|
try:
|
||||||
|
clean_and_write(
|
||||||
|
md,
|
||||||
|
Path(finalpath)
|
||||||
|
)
|
||||||
|
except FileNotFoundError as e:
|
||||||
|
print("Exception in writing to file", e)
|
||||||
|
elif mode == 'agent-notification':
|
||||||
# add custom_edit_url as the md file, so we can have uniqueness in the ingest script
|
# add custom_edit_url as the md file, so we can have uniqueness in the ingest script
|
||||||
# afterwards the ingest will replace this metadata with meta_yaml
|
# afterwards the ingest will replace this metadata with meta_yaml
|
||||||
md = add_custom_edit_url(md, meta_yaml, sidebar_label, mode='agent-notifications')
|
|
||||||
|
md = add_custom_edit_url(md, meta_yaml, sidebar_label, mode='agent-notification')
|
||||||
|
|
||||||
finalpath = f'{path}/README.md'
|
finalpath = f'{path}/README.md'
|
||||||
|
|
||||||
|
@ -422,7 +470,6 @@ cleanup()
|
||||||
|
|
||||||
categories, integrations = read_integrations_js('integrations/integrations.js')
|
categories, integrations = read_integrations_js('integrations/integrations.js')
|
||||||
|
|
||||||
|
|
||||||
# Iterate through every integration
|
# Iterate through every integration
|
||||||
for integration in integrations:
|
for integration in integrations:
|
||||||
|
|
||||||
|
@ -442,13 +489,19 @@ for integration in integrations:
|
||||||
path = build_path(meta_yaml)
|
path = build_path(meta_yaml)
|
||||||
write_to_file(path, md, meta_yaml, sidebar_label, community)
|
write_to_file(path, md, meta_yaml, sidebar_label, community)
|
||||||
|
|
||||||
# kind of specific if clause, so we can avoid running excessive code in the go repo
|
elif integration['integration_type'] == "agent_notification":
|
||||||
elif integration['integration_type'] == "notification":
|
|
||||||
|
|
||||||
meta_yaml, sidebar_label, learn_rel_path, md, community = build_readme_from_integration(
|
meta_yaml, sidebar_label, learn_rel_path, md, community = build_readme_from_integration(
|
||||||
integration, mode='notification')
|
integration, mode='agent-notification')
|
||||||
path = build_path(meta_yaml)
|
path = build_path(meta_yaml)
|
||||||
write_to_file(path, md, meta_yaml, sidebar_label, community, mode='notification')
|
write_to_file(path, md, meta_yaml, sidebar_label, community, mode='agent-notification')
|
||||||
|
|
||||||
|
elif integration['integration_type'] == "cloud_notification":
|
||||||
|
|
||||||
|
meta_yaml, sidebar_label, learn_rel_path, md, community = build_readme_from_integration(
|
||||||
|
integration, mode='cloud-notification')
|
||||||
|
path = build_path(meta_yaml)
|
||||||
|
write_to_file(path, md, meta_yaml, sidebar_label, community, mode='cloud-notification')
|
||||||
|
|
||||||
elif integration['integration_type'] == "authentication":
|
elif integration['integration_type'] == "authentication":
|
||||||
|
|
||||||
|
@ -457,5 +510,4 @@ for integration in integrations:
|
||||||
path = build_path(meta_yaml)
|
path = build_path(meta_yaml)
|
||||||
write_to_file(path, md, meta_yaml, sidebar_label, community, mode='authentication')
|
write_to_file(path, md, meta_yaml, sidebar_label, community, mode='authentication')
|
||||||
|
|
||||||
|
|
||||||
make_symlinks(symlink_dict)
|
make_symlinks(symlink_dict)
|
||||||
|
|
|
@ -4,7 +4,6 @@ import json
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
@ -40,8 +39,11 @@ EXPORTER_SOURCES = [
|
||||||
(AGENT_REPO, REPO_PATH / 'src' / 'exporting', True),
|
(AGENT_REPO, REPO_PATH / 'src' / 'exporting', True),
|
||||||
]
|
]
|
||||||
|
|
||||||
NOTIFICATION_SOURCES = [
|
AGENT_NOTIFICATION_SOURCES = [
|
||||||
(AGENT_REPO, REPO_PATH / 'src' / 'health' / 'notifications', True),
|
(AGENT_REPO, REPO_PATH / 'src' / 'health' / 'notifications', True),
|
||||||
|
]
|
||||||
|
|
||||||
|
CLOUD_NOTIFICATION_SOURCES = [
|
||||||
(AGENT_REPO, INTEGRATIONS_PATH / 'cloud-notifications' / 'metadata.yaml', False),
|
(AGENT_REPO, INTEGRATIONS_PATH / 'cloud-notifications' / 'metadata.yaml', False),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -64,12 +66,17 @@ EXPORTER_RENDER_KEYS = [
|
||||||
'troubleshooting',
|
'troubleshooting',
|
||||||
]
|
]
|
||||||
|
|
||||||
NOTIFICATION_RENDER_KEYS = [
|
AGENT_NOTIFICATION_RENDER_KEYS = [
|
||||||
'overview',
|
'overview',
|
||||||
'setup',
|
'setup',
|
||||||
'troubleshooting',
|
'troubleshooting',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
CLOUD_NOTIFICATION_RENDER_KEYS = [
|
||||||
|
'setup',
|
||||||
|
'troubleshooting',
|
||||||
|
]
|
||||||
|
|
||||||
AUTHENTICATION_RENDER_KEYS = [
|
AUTHENTICATION_RENDER_KEYS = [
|
||||||
'overview',
|
'overview',
|
||||||
'setup',
|
'setup',
|
||||||
|
@ -122,8 +129,13 @@ EXPORTER_VALIDATOR = Draft7Validator(
|
||||||
registry=registry,
|
registry=registry,
|
||||||
)
|
)
|
||||||
|
|
||||||
NOTIFICATION_VALIDATOR = Draft7Validator(
|
AGENT_NOTIFICATION_VALIDATOR = Draft7Validator(
|
||||||
{'$ref': './notification.json#'},
|
{'$ref': './agent_notification.json#'},
|
||||||
|
registry=registry,
|
||||||
|
)
|
||||||
|
|
||||||
|
CLOUD_NOTIFICATION_VALIDATOR = Draft7Validator(
|
||||||
|
{'$ref': './cloud_notification.json#'},
|
||||||
registry=registry,
|
registry=registry,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -354,7 +366,7 @@ def load_exporters():
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
def _load_notification_file(file, repo):
|
def _load_agent_notification_file(file, repo):
|
||||||
debug(f'Loading {file}.')
|
debug(f'Loading {file}.')
|
||||||
data = load_yaml(file)
|
data = load_yaml(file)
|
||||||
|
|
||||||
|
@ -362,13 +374,13 @@ def _load_notification_file(file, repo):
|
||||||
return []
|
return []
|
||||||
|
|
||||||
try:
|
try:
|
||||||
NOTIFICATION_VALIDATOR.validate(data)
|
AGENT_NOTIFICATION_VALIDATOR.validate(data)
|
||||||
except ValidationError:
|
except ValidationError:
|
||||||
warn(f'Failed to validate {file} against the schema.', file)
|
warn(f'Failed to validate {file} against the schema.', file)
|
||||||
return []
|
return []
|
||||||
|
|
||||||
if 'id' in data:
|
if 'id' in data:
|
||||||
data['integration_type'] = 'notification'
|
data['integration_type'] = 'agent_notification'
|
||||||
data['_src_path'] = file
|
data['_src_path'] = file
|
||||||
data['_repo'] = repo
|
data['_repo'] = repo
|
||||||
data['_index'] = 0
|
data['_index'] = 0
|
||||||
|
@ -378,7 +390,7 @@ def _load_notification_file(file, repo):
|
||||||
ret = []
|
ret = []
|
||||||
|
|
||||||
for idx, item in enumerate(data):
|
for idx, item in enumerate(data):
|
||||||
item['integration_type'] = 'notification'
|
item['integration_type'] = 'agent_notification'
|
||||||
item['_src_path'] = file
|
item['_src_path'] = file
|
||||||
item['_repo'] = repo
|
item['_repo'] = repo
|
||||||
item['_index'] = idx
|
item['_index'] = idx
|
||||||
|
@ -387,18 +399,65 @@ def _load_notification_file(file, repo):
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
def load_notifications():
|
def _load_cloud_notification_file(file, repo):
|
||||||
|
debug(f'Loading {file}.')
|
||||||
|
data = load_yaml(file)
|
||||||
|
|
||||||
|
if not data:
|
||||||
|
return []
|
||||||
|
|
||||||
|
try:
|
||||||
|
CLOUD_NOTIFICATION_VALIDATOR.validate(data)
|
||||||
|
except ValidationError:
|
||||||
|
warn(f'Failed to validate {file} against the schema.', file)
|
||||||
|
return []
|
||||||
|
|
||||||
|
if 'id' in data:
|
||||||
|
data['integration_type'] = 'cloud_notification'
|
||||||
|
data['_src_path'] = file
|
||||||
|
data['_repo'] = repo
|
||||||
|
data['_index'] = 0
|
||||||
|
|
||||||
|
return [data]
|
||||||
|
else:
|
||||||
ret = []
|
ret = []
|
||||||
|
|
||||||
for repo, path, match in NOTIFICATION_SOURCES:
|
for idx, item in enumerate(data):
|
||||||
if match and path.exists() and path.is_dir():
|
item['integration_type'] = 'cloud_notification'
|
||||||
for file in path.glob(METADATA_PATTERN):
|
item['_src_path'] = file
|
||||||
ret.extend(_load_notification_file(file, repo))
|
item['_repo'] = repo
|
||||||
elif not match and path.exists() and path.is_file():
|
item['_index'] = idx
|
||||||
ret.extend(_load_notification_file(path, repo))
|
ret.append(item)
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
|
def load_agent_notifications():
|
||||||
|
ret = []
|
||||||
|
|
||||||
|
for repo, path, match in AGENT_NOTIFICATION_SOURCES:
|
||||||
|
if match and path.exists() and path.is_dir():
|
||||||
|
for file in path.glob(METADATA_PATTERN):
|
||||||
|
ret.extend(_load_agent_notification_file(file, repo))
|
||||||
|
elif not match and path.exists() and path.is_file():
|
||||||
|
ret.extend(_load_agent_notification_file(path, repo))
|
||||||
|
|
||||||
|
return ret
|
||||||
|
|
||||||
|
|
||||||
|
def load_cloud_notifications():
|
||||||
|
ret = []
|
||||||
|
|
||||||
|
for repo, path, match in CLOUD_NOTIFICATION_SOURCES:
|
||||||
|
if match and path.exists() and path.is_dir():
|
||||||
|
for file in path.glob(METADATA_PATTERN):
|
||||||
|
ret.extend(_load_cloud_notification_file(file, repo))
|
||||||
|
elif not match and path.exists() and path.is_file():
|
||||||
|
ret.extend(_load_cloud_notification_file(path, repo))
|
||||||
|
|
||||||
|
return ret
|
||||||
|
|
||||||
|
|
||||||
def _load_authentication_file(file, repo):
|
def _load_authentication_file(file, repo):
|
||||||
debug(f'Loading {file}.')
|
debug(f'Loading {file}.')
|
||||||
data = load_yaml(file)
|
data = load_yaml(file)
|
||||||
|
@ -474,7 +533,9 @@ def dedupe_integrations(integrations, ids):
|
||||||
for i in integrations:
|
for i in integrations:
|
||||||
if ids.get(i['id'], False):
|
if ids.get(i['id'], False):
|
||||||
first_path, first_index = ids[i['id']]
|
first_path, first_index = ids[i['id']]
|
||||||
warn(f'Duplicate integration ID found at { i["_src_path"] } index { i["_index"] } (original definition at { first_path } index { first_index }), ignoring that integration.', i['_src_path'])
|
warn(
|
||||||
|
f'Duplicate integration ID found at {i["_src_path"]} index {i["_index"]} (original definition at {first_path} index {first_index}), ignoring that integration.',
|
||||||
|
i['_src_path'])
|
||||||
else:
|
else:
|
||||||
tmp_integrations.append(i)
|
tmp_integrations.append(i)
|
||||||
ids[i['id']] = (i['_src_path'], i['_index'])
|
ids[i['id']] = (i['_src_path'], i['_index'])
|
||||||
|
@ -538,7 +599,9 @@ def render_collectors(categories, collectors, ids):
|
||||||
item['meta']['monitored_instance']['categories'] = list(default_cats)
|
item['meta']['monitored_instance']['categories'] = list(default_cats)
|
||||||
warn(f'{item["id"]} does not list any caregories, adding it to: {default_cats}', item["_src_path"])
|
warn(f'{item["id"]} does not list any caregories, adding it to: {default_cats}', item["_src_path"])
|
||||||
else:
|
else:
|
||||||
item['meta']['monitored_instance']['categories'] = [x for x in item['meta']['monitored_instance']['categories'] if x in list(actual_cats)]
|
item['meta']['monitored_instance']['categories'] = [x for x in
|
||||||
|
item['meta']['monitored_instance']['categories'] if
|
||||||
|
x in list(actual_cats)]
|
||||||
|
|
||||||
for scope in item['metrics']['scopes']:
|
for scope in item['metrics']['scopes']:
|
||||||
if scope['name'] == 'global':
|
if scope['name'] == 'global':
|
||||||
|
@ -670,7 +733,7 @@ def render_exporters(categories, exporters, ids):
|
||||||
return exporters, clean_exporters, ids
|
return exporters, clean_exporters, ids
|
||||||
|
|
||||||
|
|
||||||
def render_notifications(categories, notifications, ids):
|
def render_agent_notifications(categories, notifications, ids):
|
||||||
debug('Sorting notifications.')
|
debug('Sorting notifications.')
|
||||||
|
|
||||||
sort_integrations(notifications)
|
sort_integrations(notifications)
|
||||||
|
@ -686,7 +749,50 @@ def render_notifications(categories, notifications, ids):
|
||||||
|
|
||||||
clean_item = deepcopy(item)
|
clean_item = deepcopy(item)
|
||||||
|
|
||||||
for key in NOTIFICATION_RENDER_KEYS:
|
for key in AGENT_NOTIFICATION_RENDER_KEYS:
|
||||||
|
if key in item.keys():
|
||||||
|
template = get_jinja_env().get_template(f'{key}.md')
|
||||||
|
data = template.render(entry=item, clean=False)
|
||||||
|
|
||||||
|
clean_data = template.render(entry=item, clean=True)
|
||||||
|
|
||||||
|
if 'variables' in item['meta']:
|
||||||
|
template = get_jinja_env().from_string(data)
|
||||||
|
data = template.render(variables=item['meta']['variables'], clean=False)
|
||||||
|
template = get_jinja_env().from_string(clean_data)
|
||||||
|
clean_data = template.render(variables=item['meta']['variables'], clean=True)
|
||||||
|
else:
|
||||||
|
data = ''
|
||||||
|
clean_data = ''
|
||||||
|
|
||||||
|
item[key] = data
|
||||||
|
clean_item[key] = clean_data
|
||||||
|
|
||||||
|
for k in ['_src_path', '_repo', '_index']:
|
||||||
|
del item[k], clean_item[k]
|
||||||
|
|
||||||
|
clean_notifications.append(clean_item)
|
||||||
|
|
||||||
|
return notifications, clean_notifications, ids
|
||||||
|
|
||||||
|
|
||||||
|
def render_cloud_notifications(categories, notifications, ids):
|
||||||
|
debug('Sorting notifications.')
|
||||||
|
|
||||||
|
sort_integrations(notifications)
|
||||||
|
|
||||||
|
debug('Checking notification ids.')
|
||||||
|
|
||||||
|
notifications, ids = dedupe_integrations(notifications, ids)
|
||||||
|
|
||||||
|
clean_notifications = []
|
||||||
|
|
||||||
|
for item in notifications:
|
||||||
|
item['edit_link'] = make_edit_link(item)
|
||||||
|
|
||||||
|
clean_item = deepcopy(item)
|
||||||
|
|
||||||
|
for key in CLOUD_NOTIFICATION_RENDER_KEYS:
|
||||||
if key in item.keys():
|
if key in item.keys():
|
||||||
template = get_jinja_env().get_template(f'{key}.md')
|
template = get_jinja_env().get_template(f'{key}.md')
|
||||||
data = template.render(entry=item, clean=False)
|
data = template.render(entry=item, clean=False)
|
||||||
|
@ -777,20 +883,23 @@ def main():
|
||||||
collectors = load_collectors()
|
collectors = load_collectors()
|
||||||
deploy = load_deploy()
|
deploy = load_deploy()
|
||||||
exporters = load_exporters()
|
exporters = load_exporters()
|
||||||
notifications = load_notifications()
|
agent_notifications = load_agent_notifications()
|
||||||
|
cloud_notifications = load_cloud_notifications()
|
||||||
authentications = load_authentications()
|
authentications = load_authentications()
|
||||||
|
|
||||||
collectors, clean_collectors, ids = render_collectors(categories, collectors, dict())
|
collectors, clean_collectors, ids = render_collectors(categories, collectors, dict())
|
||||||
deploy, clean_deploy, ids = render_deploy(distros, categories, deploy, ids)
|
deploy, clean_deploy, ids = render_deploy(distros, categories, deploy, ids)
|
||||||
exporters, clean_exporters, ids = render_exporters(categories, exporters, ids)
|
exporters, clean_exporters, ids = render_exporters(categories, exporters, ids)
|
||||||
notifications, clean_notifications, ids = render_notifications(categories, notifications, ids)
|
agent_notifications, clean_agent_notifications, ids = render_agent_notifications(categories, agent_notifications,
|
||||||
|
ids)
|
||||||
|
cloud_notifications, clean_cloud_notifications, ids = render_cloud_notifications(categories, cloud_notifications,
|
||||||
|
ids)
|
||||||
authentications, clean_authentications, ids = render_authentications(categories, authentications, ids)
|
authentications, clean_authentications, ids = render_authentications(categories, authentications, ids)
|
||||||
|
|
||||||
|
integrations = collectors + deploy + exporters + agent_notifications + cloud_notifications + authentications
|
||||||
integrations = collectors + deploy + exporters + notifications + authentications
|
|
||||||
render_integrations(categories, integrations)
|
render_integrations(categories, integrations)
|
||||||
|
|
||||||
clean_integrations = clean_collectors + clean_deploy + clean_exporters + clean_notifications + clean_authentications
|
clean_integrations = clean_collectors + clean_deploy + clean_exporters + clean_agent_notifications + clean_cloud_notifications + clean_authentications
|
||||||
render_json(categories, clean_integrations)
|
render_json(categories, clean_integrations)
|
||||||
|
|
||||||
|
|
||||||
|
|
68
integrations/schemas/cloud_notification.json
Normal file
68
integrations/schemas/cloud_notification.json
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
{
|
||||||
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||||
|
"title": "Netdata notification mechanism metadata.",
|
||||||
|
"oneOf": [
|
||||||
|
{
|
||||||
|
"$ref": "#/$defs/entry"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "array",
|
||||||
|
"minLength": 1,
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/$defs/entry"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"$defs": {
|
||||||
|
"entry": {
|
||||||
|
"type": "object",
|
||||||
|
"description": "Data for a single notification method.",
|
||||||
|
"properties": {
|
||||||
|
"id": {
|
||||||
|
"$ref": "./shared.json#/$defs/id"
|
||||||
|
},
|
||||||
|
"meta": {
|
||||||
|
"$ref": "./shared.json#/$defs/instance"
|
||||||
|
},
|
||||||
|
"keywords": {
|
||||||
|
"$ref": "./shared.json#/$defs/keywords"
|
||||||
|
},
|
||||||
|
"global_setup": {
|
||||||
|
"type": "object",
|
||||||
|
"description": "Flags that show which global setup sections are relevant for this notification method.",
|
||||||
|
"properties": {
|
||||||
|
"severity_filtering": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"http_proxy": {
|
||||||
|
"type": "boolean"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"severity_filtering",
|
||||||
|
"http_proxy"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"setup": {
|
||||||
|
"oneOf": [
|
||||||
|
{
|
||||||
|
"$ref": "./shared.json#/$defs/short_setup"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"$ref": "./shared.json#/$defs/full_setup"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"troubleshooting": {
|
||||||
|
"$ref": "./shared.json#/$defs/troubleshooting"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"id",
|
||||||
|
"meta",
|
||||||
|
"keywords",
|
||||||
|
"setup"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,7 +2,7 @@
|
||||||
[% include 'overview/collector.md' %]
|
[% include 'overview/collector.md' %]
|
||||||
[% elif entry.integration_type == 'exporter' %]
|
[% elif entry.integration_type == 'exporter' %]
|
||||||
[% include 'overview/exporter.md' %]
|
[% include 'overview/exporter.md' %]
|
||||||
[% elif entry.integration_type == 'notification' %]
|
[% elif entry.integration_type == 'agent_notification' %]
|
||||||
[% include 'overview/notification.md' %]
|
[% include 'overview/notification.md' %]
|
||||||
[% elif entry.integration_type == 'authentication' %]
|
[% elif entry.integration_type == 'authentication' %]
|
||||||
[% include 'overview/authentication.md' %]
|
[% include 'overview/authentication.md' %]
|
||||||
|
|
|
@ -85,13 +85,12 @@ docker logs netdata 2>&1 | grep [[ entry.meta.module_name ]]
|
||||||
|
|
||||||
[% endif %]
|
[% endif %]
|
||||||
[% endif %]
|
[% endif %]
|
||||||
[% elif entry.integration_type == 'notification' %]
|
[% elif entry.integration_type == 'cloud_notification' %]
|
||||||
[% if 'cloud-notifications' in entry._src_path|string %]
|
|
||||||
[% if entry.troubleshooting.problems.list %]
|
[% if entry.troubleshooting.problems.list %]
|
||||||
## Troubleshooting
|
## Troubleshooting
|
||||||
|
|
||||||
[% endif %]
|
[% endif %]
|
||||||
[% else %]
|
[% elif entry.integration_type == 'agent_notification' %]
|
||||||
## Troubleshooting
|
## Troubleshooting
|
||||||
|
|
||||||
### Test Notification
|
### Test Notification
|
||||||
|
@ -114,7 +113,6 @@ 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.
|
||||||
|
|
||||||
[% endif %]
|
|
||||||
[% elif entry.integration_type == 'exporter' %]
|
[% elif entry.integration_type == 'exporter' %]
|
||||||
[% if entry.troubleshooting.problems.list %]
|
[% if entry.troubleshooting.problems.list %]
|
||||||
## Troubleshooting
|
## Troubleshooting
|
||||||
|
|
Loading…
Add table
Reference in a new issue