Skip to content

HyperCloud Prometheus exporter

hc-exporter is a python package which can scrape monitoring data from HyperCloud and run a Prometheus exporter for the data ingested into a Prometheus server.

The functionality is split into separate modules, so new modules could be written in the future to support other monitoring systems.


hc_scraper

Gathers monitoring data from HyperCloud, using pyone to interact with the XML-RPC API.

Sums up total metrics for the Cluster using the metrics from Hosts & VMs as the API doesn't provide this information directly.

Usage

Create a scraper using the HyperCloudScraper class, passing a config map, then call the scrape() method

Check the user's privileges

The credentials provided here should be an existing user with access to see everything in HyperCloud.

Metrics that this user doesn't have access to will not be collected, so the summed totals will be incorrect.

from hc_exporter.hc_scraper import *

my_hypercloud_config = {
    'ONE_XMLRPC' : 'https://<hypercloud_ip_address>:2634/RPC2',
    'ONE_AUTH' : '<username>:<password>',
    'HTTPS_VERIFY' : True, # Optional. Set False to disable HTTPS verification.
}

my_scraper = HyperCloudScraper(my_hypercloud_config)

my_scraped_data = my_scraper.scrape()

# .scrape() returns its data in a dictionary, structured as follows:00
my_scraped_data = {               
    'vm': []        # List of VMs as HyperCloudVM objects
    'host': []      # List of Hosts as HyperCloudHost objects
    'cluster': []   # List of Clusters as HyperCloudCluster objects
}

hc_prometheus_exporter

Creates a scraper and runs a Prometheus exporter for the data ingested into a Prometheus server.

Usage

Create an exporter using the HyperCloudPrometheusExporter class, passing a config map, then call the main() method to start the exporter.

Check the user's privileges

The credentials provided in the ONE_AUTH variable should be a user with access to see all VMs.

Metrics that this user doesn't have access to will not be collected, so the summed totals will be incorrect.

from hc_exporter.hc_prometheus_exporter import *

my_scraper_config = {
    'ONE_XMLRPC' : 'https://<hypercloud_ip_address>:2634/RPC2',
    'ONE_AUTH' : '<username>:<password>',
    'HTTPS_VERIFY' : True, # Optional. Set False to disable HTTPS verification.
    'POLL_FREQUENCY' : 30, # Optional. Set how frequently the exporter will poll HyperCloud. Defaults to 30 seconds.
    'EXPORTER_PORT' : 9000, # Optional. Set the port the exporter will be served on. Defaults to 9000.
}

my_exporter = HyperCloudPrometheusExporter(my_scraper_config)
my_exporter.main()

This will start the exporter, listening on 0.0.0.0:9000 by default.