0
0
Fork 0
mirror of https://github.com/netdata/netdata.git synced 2025-04-09 15:47:53 +00:00

Introduce stringify function for integrations ()

This commit is contained in:
Fotis Voutsas 2023-10-06 11:09:46 +03:00 committed by GitHub
parent 3581d73519
commit f69ad3fbcc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 4 deletions

View file

@ -140,9 +140,19 @@ def get_jinja_env():
lstrip_blocks=True, lstrip_blocks=True,
) )
_jinja_env.globals.update(strfy=strfy)
return _jinja_env 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): def get_category_sets(categories):
default = set() default = set()
valid = set() valid = set()

View file

@ -7,7 +7,7 @@ The following alerts are available:
| Alert name | On metric | Description | | Alert name | On metric | Description |
|:------------|:----------|:------------| |:------------|:----------|:------------|
[% for alert in entry.alerts %] [% 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 %] [% endfor %]
[% else %] [% else %]
There are no alerts configured by default for this integration. There are no alerts configured by default for this integration.

View file

@ -21,7 +21,7 @@ Labels:
| Label | Description | | Label | Description |
|:-----------|:----------------| |:-----------|:----------------|
[% for label in scope.labels %] [% for label in scope.labels %]
| [[ label.name ]] | [[ label.description ]] | | [[ strfy(label.name) ]] | [[ strfy(label.description) ]] |
[% endfor %] [% endfor %]
[% else %] [% else %]
This scope has no labels. This scope has no labels.
@ -34,7 +34,7 @@ Metrics:
|:------|:----------|:----|[% for a in entry.metrics.availability %]:---:|[% endfor %] |:------|:----------|:----|[% for a in entry.metrics.availability %]:---:|[% endfor %]
[% for metric in scope.metrics %] [% 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 %] [% endfor %]

View file

@ -65,7 +65,7 @@ There is no configuration file.
| Name | Description | Default | Required | | Name | Description | Default | Required |
|:----|:-----------|:-------|:--------:| |:----|:-----------|:-------|:--------:|
[% for item in entry.setup.configuration.options.list %] [% 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 %] [% endfor %]
[% for item in entry.setup.configuration.options.list %] [% for item in entry.setup.configuration.options.list %]