canonical / prometheus-openstack-exporter

OpenStack exporter for the prometheus monitoring system
GNU General Public License v3.0
128 stars 113 forks source link

ImportError: No Module named swift.common.utils #69

Closed jeevadotnet closed 5 years ago

jeevadotnet commented 5 years ago

Hi

Getting the following issue (downloaded 6 Feb 2019) if anyone can assist please:

ubuntu@server01:/opt/prometheus-openstack-exporter$ sudo systemctl status prometheus-openstack-exporter.service
prometheus-openstack-exporter.service - prometheus-openstack-exporter
   Loaded: loaded (/etc/systemd/system/prometheus-openstack-exporter.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Wed 2019-02-06 12:32:15 UTC; 4s ago
  Process: 11416 ExecStart=/bin/sh -c . /etc/prometheus-openstack-exporter/admin.novarc; exec /opt/prometheus-openstack-exporter/prometheus-openstack-exporter $CONFIG_FILE (co
 Main PID: 11416 (code=exited, status=1/FAILURE)

Feb 06 12:32:14 server01 systemd[1]: Started prometheus-openstack-exporter.
Feb 06 12:32:15 server01 sh[11416]: Traceback (most recent call last):
Feb 06 12:32:15 server01 sh[11416]:   File "/opt/prometheus-openstack-exporter/prometheus-openstack-exporter", line 48, in <module>
Feb 06 12:32:15 server01 sh[11416]:     import swift.common.utils
Feb 06 12:32:15 server01 sh[11416]: ImportError: No module named swift.common.utils
Feb 06 12:32:15 server01 systemd[1]: prometheus-openstack-exporter.service: Main process exited, code=exited, status=1/FAILURE
Feb 06 12:32:15  server01 systemd[1]: prometheus-openstack-exporter.service: Unit entered failed state.
Feb 06 12:32:15 server01 systemd[1]: prometheus-openstack-exporter.service: Failed with result 'exit-code'.

ImportError: No module named swift.common.utils is the issue

$ sudo cat /etc/prometheus-openstack-exporter/prometheus-openstack-exporter.yaml

# Copyright (C) 2016-2019 Canonical, Ltd.
#

listen_port: 9183
cache_refresh_interval: 300  # In seconds
cache_file: /var/cache/prometheus-openstack-exporter/mycloud
cloud: mycloud
openstack_allocation_ratio_vcpu: 2.5
openstack_allocation_ratio_ram: 1.1
openstack_allocation_ratio_disk: 1.0

# Configure the enabled collectors here.  Note that the Swift account
# collector in particular has special requirements.
enabled_collectors:
  - cinder
  - neutron
  - nova
#  - swift
#  - swift-account-usage

# To export hypervisor_schedulable_instances metric set desired instance size
schedulable_instance_size:
    ram_mbs: 4096
    vcpu: 2
    disk_gbs: 20

# Uncomment if the cloud doesn't provide cinder / nova volumes:
use_nova_volumes: False

$ sudo nano /etc/init/prometheus-openstack-exporter.conf

# Configuration is read from /etc/default/prometheus-openstack-exporter
# Copyright (C) 2016 Canonical, Ltd.

description "Prometheus Openstack Exporter"
author  "Jacek Nykis <jacek.nykis@canonical.com>"

# The following variable must be set:
# NOVARC - full path to the novarc file
#
# Optionall variables:
# CONFIG_FILE - path to configuration file

start on runlevel [2345]
stop on runlevel [!2345]
respawn

script
    . /etc/default/prometheus-openstack-exporter
    . $NOVARC
    exec /usr/local/bin/prometheus-openstack-exporter $CONFIG_FILE
#    exec /opt/prometheus-openstack-exporter/prometheus-openstack-exporter $CONFIG_FILE
end script

$ sudo nano /etc/systemd/system/prometheus-openstack-exporter.service

Description=prometheus-openstack-exporter
After=network.target

[Service]
EnvironmentFile=/etc/default/prometheus-openstack-exporter
#EnvironmentFile=/etc/prometheus-openstack-exporter/admin.novarc
ExecStart=/bin/sh -c '. /etc/prometheus-openstack-exporter/admin.novarc; exec /opt/prometheus-openstack-exporter/prometheus-openstack-exporter $CONFIG_FILE'
KillMode=process

[Install]
WantedBy=multi-user.target
jayme commented 5 years ago

I had this same issue today, pip install swift resolved it.

jeevadotnet commented 5 years ago

Thank you it got me a step further.

I installed it but first required some more pre-requisites to get it working.