Comment 0 for bug 1977920

Revision history for this message
Paul Collins (pjdc) wrote : cannot modify prometheus_client.listen via extra_configs

The charm tries to allow modifying outputs.prometheus_client.listen via the extra_configs setting: https://git.launchpad.net/charm-telegraf/tree/src/reactive/telegraf.py?h=stable/21.10#n1536

However, when I tried this, using the following config:

juju config telegraf extra_options='outputs:
    prometheus_client:
      listen: 10.131.59.185:9103'

The charm crashed as follows:

2022-06-08 04:42:12 WARNING config-changed File "/var/lib/juju/agents/unit-ubuntu-torrent-telegraf-0/charm/reactive/telegraf.py", line 1630, in generate_prometheus_output_config
2022-06-08 04:42:12 WARNING config-changed elif int(listen.split(":", 1)[1]) != prometheus_output_port:
2022-06-08 04:42:12 WARNING config-changed ValueError: invalid literal for int() with base 10: '9103"'

(Note the double-quote character after the four digit characters of 9103.)

This seems to be due to get_extra_configs's "JSONification": https://git.launchpad.net/charm-telegraf/tree/src/reactive/telegraf.py?h=stable/21.10#n489

You can see below that `json.dumps` does indeed wrap the value in quotes:

>>> import json, yaml
>>> x = '''outputs:
... prometheus_client:
... listen: 10.131.59.185:9103
... '''
>>> y = yaml.full_load(x)
>>> y
{'outputs': {'prometheus_client': {'listen': '10.131.59.185:9103'}}}
>>> print(y['outputs']['prometheus_client']['listen'])
10.131.59.185:9103
>>> print(json.dumps(y['outputs']['prometheus_client']['listen']))
"10.131.59.185:9103"
>>> _

This deployment is kind of weird, hence this weird configuration, but it would useful if it worked as it would allow me to get rid of some potentially expensive iptables on a high-traffic service.