running via the CLI or the service results in the following exception:
snap run cloudstats -d --run-reporter
2021-01-13 07:21:43,422 DEBUG - Parsed config: /var/snap/cloudstats/common
2021-01-13 07:21:43,422 DEBUG - Running reporter
2021-01-13 07:21:43,422 DEBUG - Querying Prometheus: count(sum by (hypervisor_hostname) (hypervisor_vcpus_total))
Traceback (most recent call last):
File "/snap/cloudstats/x2/bin/cloudstats", line 33, in
sys.exit(load_entry_point('cloudstats==0.1', 'console_scripts', 'cloudstats')())
File "/snap/cloudstats/x2/lib/python3.6/site-packages/cloudstats/cli.py", line 80, in main
obj.run()
File "/snap/cloudstats/x2/lib/python3.6/site-packages/cloudstats/reporter.py", line 85, in run
self.trigger()
File "/snap/cloudstats/x2/lib/python3.6/site-packages/cloudstats/reporter.py", line 76, in trigger
data = self.collect_prometheus_data()
File "/snap/cloudstats/x2/lib/python3.6/site-packages/cloudstats/reporter.py", line 60, in collect_prometheus_data
stats = self.prometheus.get_all_stats()
File "/snap/cloudstats/x2/lib/python3.6/site-packages/cloudstats/prometheus.py", line 167, in get_all_stats
result = self._get_stat(collector, stat)
File "/snap/cloudstats/x2/lib/python3.6/site-packages/cloudstats/prometheus.py", line 154, in _get_stat
element, value = self.query_prometheus_single(query)
File "/snap/cloudstats/x2/lib/python3.6/site-packages/cloudstats/prometheus.py", line 88, in query_prometheus_single
results = self._query_prometheus(query)
File "/snap/cloudstats/x2/lib/python3.6/site-packages/cloudstats/prometheus.py", line 46, in _query_prometheus
results = response.json()["data"]["result"]
File "/snap/cloudstats/x2/lib/python3.6/site-packages/requests/models.py", line 898, in json
return complexjson.loads(self.text, **kwargs)
File "/snap/cloudstats/x2/usr/lib/python3.6/json/init.py", line 354, in loads
return _default_decoder.decode(s)
File "/snap/cloudstats/x2/usr/lib/python3.6/json/decoder.py", line 342, in decode
raise JSONDecodeError("Extra data", s, end)
json.decoder.JSONDecodeError: Extra data: line 1 column 5 (char 4)
It would also help logging a descriptive error in case the application is getting malformed/invalid json from prometheus.
cloudstats-reporter fails with JSONDecodeError exception while trying to parse prometheus output
Charm version: cs:~llama-charmers-next/cloudstats-2 Snap version: 1.1 2020-10-26 (installed as resource due to connectivity issues, snap download cloudstats / juju attach-resource cloudstats cloudstats=cloudstats_3.snap)
Relations: $ juju status --relations cloudstats|grep cloudstats: cloudstats:juju-info filebeat:beats-host juju-info subordinate
cloudstats:juju-info landscape-client:container juju-info subordinate
cloudstats:juju-info nrpe-container:general-info juju-info subordinate
cloudstats:prometheus-scrape-target prometheus:scrape prometheus regular
keystone:identity-admin cloudstats:openstack-admin keystone-admin regular
prometheus:website cloudstats:prometheus-client http regular
telegraf:prometheus-client cloudstats:prometheus-client http regular
running via the CLI or the service results in the following exception:
snap run cloudstats -d --run-reporter
2021-01-13 07:21:43,422 DEBUG - Parsed config: /var/snap/cloudstats/common 2021-01-13 07:21:43,422 DEBUG - Running reporter 2021-01-13 07:21:43,422 DEBUG - Querying Prometheus: count(sum by (hypervisor_hostname) (hypervisor_vcpus_total)) Traceback (most recent call last): File "/snap/cloudstats/x2/bin/cloudstats", line 33, in
sys.exit(load_entry_point('cloudstats==0.1', 'console_scripts', 'cloudstats')())
File "/snap/cloudstats/x2/lib/python3.6/site-packages/cloudstats/cli.py", line 80, in main
obj.run()
File "/snap/cloudstats/x2/lib/python3.6/site-packages/cloudstats/reporter.py", line 85, in run
self.trigger()
File "/snap/cloudstats/x2/lib/python3.6/site-packages/cloudstats/reporter.py", line 76, in trigger
data = self.collect_prometheus_data()
File "/snap/cloudstats/x2/lib/python3.6/site-packages/cloudstats/reporter.py", line 60, in collect_prometheus_data
stats = self.prometheus.get_all_stats()
File "/snap/cloudstats/x2/lib/python3.6/site-packages/cloudstats/prometheus.py", line 167, in get_all_stats
result = self._get_stat(collector, stat)
File "/snap/cloudstats/x2/lib/python3.6/site-packages/cloudstats/prometheus.py", line 154, in _get_stat
element, value = self.query_prometheus_single(query)
File "/snap/cloudstats/x2/lib/python3.6/site-packages/cloudstats/prometheus.py", line 88, in query_prometheus_single
results = self._query_prometheus(query)
File "/snap/cloudstats/x2/lib/python3.6/site-packages/cloudstats/prometheus.py", line 46, in _query_prometheus
results = response.json()["data"]["result"]
File "/snap/cloudstats/x2/lib/python3.6/site-packages/requests/models.py", line 898, in json
return complexjson.loads(self.text, **kwargs)
File "/snap/cloudstats/x2/usr/lib/python3.6/json/init.py", line 354, in loads
return _default_decoder.decode(s)
File "/snap/cloudstats/x2/usr/lib/python3.6/json/decoder.py", line 342, in decode
raise JSONDecodeError("Extra data", s, end)
json.decoder.JSONDecodeError: Extra data: line 1 column 5 (char 4)
It would also help logging a descriptive error in case the application is getting malformed/invalid json from prometheus.
Imported from Launchpad using lp2gh.
date created: 2021-01-13T07:25:14Z
owner: jfguedez
assignee: None
the launchpad url