Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to collect metric for exporter: nova #268

Open
qq346434990 opened this issue Jan 10, 2023 · 5 comments
Open

Failed to collect metric for exporter: nova #268

qq346434990 opened this issue Jan 10, 2023 · 5 comments

Comments

@qq346434990
Copy link

CentOS8 - Openstack yoga - nova

I have encountered a problem that is difficult to solve, I asked for help:
openstack-exporter: 1.6.0
problem: ERRO[0021] Failed to collect metric for exporter: nova, error: failed to collect metric: running_vms, error: CPUInfo has unexpected type: source="exporter.go:122"

@srkaviani
Copy link

I have this problem too. (msg="Failed to collect metric for exporter: nova, error: failed to collect metric: running_vms, error: CPUInfo has unexpected type: " source="exporter.go:123") after update to wallaby.

@Oxyash
Copy link

Oxyash commented Feb 16, 2023

same problem on Zed
level=error msg="Failed to collect metric for exporter: nova, error: failed to collect metric: running_vms, error: CPUInfo has unexpected type: " source="exporter .go:123"

@adamoswick
Copy link

This seems to be a result of changes in the Nova API after version 2.87. The gophercloud code tries to fetch the cpu_info output from the os-hypervisor/detail API route. However, this doesn't exist anymore so the type is None causing an error from the SDK.

This causes the SDK to error and ultimately the Nova collector in openstack-exporter also errors meaning the metrics here fail. We've worked around this by setting prometheus_openstack_exporter_compute_api_version = 2.87 in Kolla Ansible (which sets OS_COMPUTE_API_VERSION=2.87 in the environment for openstack-exporter).

The 2.87 version of the Nova API still contains the cpu_info output meaning the error doesn't get thrown. Ideally, the Nova API changes following 2.87 need to be supported by the gophercloud SDK.

@srkaviani
Copy link

@adamoswick
Thanks. This was very helpful.

@samuelallan72
Copy link
Contributor

samuelallan72 commented Apr 3, 2024

On latest main I get this similar error output:

ts=2024-04-03T23:09:00.715Z caller=exporter.go:126 level=error err="Failed to collect metric for exporter" exporter=nova error="failed to collect metric: running_vms, error: CPUInfo has unexpected type: <nil>"

Confirming that setting OS_COMPUTE_API_VERSION=2.87 in the environment fixes the issue.


Also note that when this error happens, it also causes metrics to not be written for all the other metrics in the ListHypervisors function:

ch <- prometheus.MustNewConstMetric(exporter.Metrics["running_vms"].Metric,
prometheus.GaugeValue, float64(hypervisor.RunningVMs), hypervisor.HypervisorHostname, availabilityZone, aggregatesLabel(hypervisor.Service.Host, hostToAggrMap))
ch <- prometheus.MustNewConstMetric(exporter.Metrics["current_workload"].Metric,
prometheus.GaugeValue, float64(hypervisor.CurrentWorkload), hypervisor.HypervisorHostname, availabilityZone, aggregatesLabel(hypervisor.Service.Host, hostToAggrMap))
ch <- prometheus.MustNewConstMetric(exporter.Metrics["vcpus_available"].Metric,
prometheus.GaugeValue, float64(hypervisor.VCPUs), hypervisor.HypervisorHostname, availabilityZone, aggregatesLabel(hypervisor.Service.Host, hostToAggrMap))
ch <- prometheus.MustNewConstMetric(exporter.Metrics["vcpus_used"].Metric,
prometheus.GaugeValue, float64(hypervisor.VCPUsUsed), hypervisor.HypervisorHostname, availabilityZone, aggregatesLabel(hypervisor.Service.Host, hostToAggrMap))
ch <- prometheus.MustNewConstMetric(exporter.Metrics["memory_available_bytes"].Metric,
prometheus.GaugeValue, float64(hypervisor.MemoryMB*MEGABYTE), hypervisor.HypervisorHostname, availabilityZone, aggregatesLabel(hypervisor.Service.Host, hostToAggrMap))
ch <- prometheus.MustNewConstMetric(exporter.Metrics["memory_used_bytes"].Metric,
prometheus.GaugeValue, float64(hypervisor.MemoryMBUsed*MEGABYTE), hypervisor.HypervisorHostname, availabilityZone, aggregatesLabel(hypervisor.Service.Host, hostToAggrMap))
ch <- prometheus.MustNewConstMetric(exporter.Metrics["local_storage_available_bytes"].Metric,
prometheus.GaugeValue, float64(hypervisor.LocalGB*GIGABYTE), hypervisor.HypervisorHostname, availabilityZone, aggregatesLabel(hypervisor.Service.Host, hostToAggrMap))
ch <- prometheus.MustNewConstMetric(exporter.Metrics["local_storage_used_bytes"].Metric,
prometheus.GaugeValue, float64(hypervisor.LocalGBUsed*GIGABYTE), hypervisor.HypervisorHostname, availabilityZone, aggregatesLabel(hypervisor.Service.Host, hostToAggrMap))
ch <- prometheus.MustNewConstMetric(exporter.Metrics["free_disk_bytes"].Metric,
prometheus.GaugeValue, float64(hypervisor.FreeDiskGB*GIGABYTE), hypervisor.HypervisorHostname, availabilityZone, aggregatesLabel(hypervisor.Service.Host, hostToAggrMap))

samuelallan72 added a commit to canonical/openstack-exporter-operator that referenced this issue Apr 4, 2024
Previously this error was seen in the logs:

  ts=2024-04-03T23:09:00.715Z caller=exporter.go:126 level=error err="Failed to collect metric for exporter" exporter=nova error="failed to collect metric: running_vms, error: CPUInfo has unexpected type: <nil>"

Causing `openstack_nova_running_vms` and a selection of other hypervisor related metrics to be missing from the output.

This applies the workaround noted in openstack-exporter/openstack-exporter#268
samuelallan72 added a commit to canonical/openstack-exporter-operator that referenced this issue Apr 5, 2024
Previously this error was seen in the logs:

  ts=2024-04-03T23:09:00.715Z caller=exporter.go:126 level=error err="Failed to collect metric for exporter" exporter=nova error="failed to collect metric: running_vms, error: CPUInfo has unexpected type: <nil>"

Causing `openstack_nova_running_vms` and a selection of other hypervisor related metrics to be missing from the output.

This applies the workaround noted in openstack-exporter/openstack-exporter#268
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants