diff --git a/integrations/gen_integrations.py b/integrations/gen_integrations.py index 35c19365c8..ca81a04f4e 100755 --- a/integrations/gen_integrations.py +++ b/integrations/gen_integrations.py @@ -140,9 +140,19 @@ def get_jinja_env(): lstrip_blocks=True, ) + _jinja_env.globals.update(strfy=strfy) + return _jinja_env +def strfy(value): + if not isinstance(value, str): + return value + + return ' '.join([v.strip() for v in value.strip().split("\n") if v]) + + + def get_category_sets(categories): default = set() valid = set() diff --git a/integrations/templates/alerts.md b/integrations/templates/alerts.md index ca8bd66e6e..56f08d4c55 100644 --- a/integrations/templates/alerts.md +++ b/integrations/templates/alerts.md @@ -7,7 +7,7 @@ The following alerts are available: | Alert name | On metric | Description | |:------------|:----------|:------------| [% for alert in entry.alerts %] -| [ [[ alert.name ]] ]([[ alert.link ]]) | [[ alert.metric ]] | [[ alert.info ]] | +| [ [[ strfy(alert.name) ]] ]([[ strfy(alert.link) ]]) | [[ strfy(alert.metric) ]] | [[ strfy(alert.info) ]] | [% endfor %] [% else %] There are no alerts configured by default for this integration. diff --git a/integrations/templates/metrics.md b/integrations/templates/metrics.md index 95fa7504be..d8df98779b 100644 --- a/integrations/templates/metrics.md +++ b/integrations/templates/metrics.md @@ -21,7 +21,7 @@ Labels: | Label | Description | |:-----------|:----------------| [% for label in scope.labels %] -| [[ label.name ]] | [[ label.description ]] | +| [[ strfy(label.name) ]] | [[ strfy(label.description) ]] | [% endfor %] [% else %] This scope has no labels. @@ -34,7 +34,7 @@ Metrics: |:------|:----------|:----|[% for a in entry.metrics.availability %]:---:|[% endfor %] [% for metric in scope.metrics %] -| [[ metric.name ]] | [% for d in metric.dimensions %][[ d.name ]][% if not loop.last %], [% endif %][% endfor %] | [[ metric.unit ]] |[% for a in entry.metrics.availability %] [% if not metric.availability|length or a in metric.availability %]•[% else %] [% endif %] |[% endfor %] +| [[ strfy(metric.name) ]] | [% for d in metric.dimensions %][[ strfy(d.name) ]][% if not loop.last %], [% endif %][% endfor %] | [[ strfy(metric.unit) ]] |[% for a in entry.metrics.availability %] [% if not metric.availability|length or a in metric.availability %]•[% else %] [% endif %] |[% endfor %] [% endfor %] diff --git a/integrations/templates/setup.md b/integrations/templates/setup.md index 101f5bcbc8..0a202fecb0 100644 --- a/integrations/templates/setup.md +++ b/integrations/templates/setup.md @@ -65,7 +65,7 @@ There is no configuration file. | Name | Description | Default | Required | |:----|:-----------|:-------|:--------:| [% for item in entry.setup.configuration.options.list %] -| [[ item.name ]] | [[ item.description ]] | [[ item.default ]] | [[ item.required ]] | +| [[ strfy(item.name) ]] | [[ strfy(item.description) ]] | [[ strfy(item.default) ]] | [[ strfy(item.required) ]] | [% endfor %] [% for item in entry.setup.configuration.options.list %]