1. API

1.1. DesignSpark.Cloud.Metrics

DesignSpark Cloud metrics interface

class DesignSpark.Cloud.Metrics.Metric(backendType='prometheus', instance=None, key=None, url=None)

This class handles interfacing with the DesignSpark Cloud.

Parameters
  • backendType (string, optional) – A string containing “prometheus”. Defaults to “prometheus”.

  • instance (string) – DSM Instance number

  • key (string) – DSM authentication key

  • url (string) – DSM URL

Note

Prometheus is currently the only supported backend. Additional backends will be available in future.

getReadURI()

Helper function that returns a connection URL to DSM.

Returns

A string configured with DesignSpark Cloud connection details

Return type

string

write(data)

Writes a single data point to the specfied cloud.

Parameters

data (dict) – A dictionary containing the metric data to be published. Labels are optional and multiple can be supplied, name and value keys are mandatory.

The metric value should only be a float or integer, other types will be casted using float() which may fail.

{
    "name": "metric name",
    "value": 123,
    "label1": "a label",
    "label2": "another label"
}
Returns

True on successful publish, a list containing False, status code and reason on unsuccessful publish.

Return type

boolean, list