Data Access

Graphite

class pandas_metricsreader.GraphiteReader(url, tls_verify='/etc/ssl/certs/', session=None, timeout=30.0)[source]

Creates a GraphiteDataReader object, which you can use to read different metrics in a pandas DataFrame

Parameters:
  • url (str) – the base url to the Graphite host
  • tls_verify (str or bool, optional) – enable or disable certificate validation. You can als specify the path to a certificate or a directory, which must have been processed using the c_rehash utily supplied with OppenSSL. The default is the standard linux certificate trust store (/etc/ssl/certs)
  • session (requests.Session, optional) – a requests.Session object (default None)
  • timeout (float or tuple, optional) – the connect and read timeouts (see the requests documentation under Timeouts for details)
read(targets, start=None, end=None, create_multiindex=True, remove_redundant_indices=True)[source]

read the data from Graphite

Parameters:
  • targets (str or list[str] or dict) – the metrics you want to look up
  • start (str, optional) – the starting date timestamp. All Graphite datestrings are allowed (see Graphite documentation under from-until for details)
  • end (str, optional) – the ending date timestamp, same as start date
  • create_multiindex (bool, optional) – split the metrics names and create a hierarchical Index.
  • remove_redundant_indices (bool, optional) – Remove all redundant rows from the hierarchical Index. This does only have an affect, if you have more then one metric and if create_multiindex is set to True.
Returns:

a pandas DataFrame with the requested Data from Graphite

walk(top=None, start=None, end=None)[source]

Generate the target names in the Graphite target tree by walking the tree down. This creates a os.walk() like generator for the Graphite metrics.

Parameters:
  • top (str, optional) – the target, where the walk starts (without a trailing asterisk)
  • start (str, optional) –

    the starting date timestamp. All Graphite datestrings are allowed (see Graphite documentation under from-until for details)

  • end (str, optional) – the ending date timestamp, same as start date
Returns:

a generator object, which yields a 3-tuple (targetname, non-leafs, leafs) for each metric.

targetname is the current walk position in the target tree. non-leafs are all child targets of targetname, which do not contain any data. leafs are all child targets of targetname, which do hold data. Hence you can use the read() method to read data from all leafs.

PNP4nagios

class pandas_metricsreader.PNP4NagiosReader(baseurl, tls_verify='/etc/ssl/certs/', session=None, timeout=30)[source]

Creates a PNP4NagiosReader object, which you can use to read metrics in a pandas DataFrame

Parameters:
  • baseurl (str) – the base url to the PNP4Nagios host
  • tls_verify (str or bool, optional) – enable or disable certificate validation. You can als specify the path to a certificate or a directory, which must have been processed using the c_rehash utily supplied with OppenSSL. The default is the standard linux certificate trust store (/etc/ssl/certs)
  • session (requests.Session) – a requests.Session object (default None)
  • timeout (float or tuple) – the connect and read timeouts (see the requests documentation under Timeouts for details)
read(hosts, service, start=None, end=None, view=None, create_multiindex=True)[source]

read the data from PNP4Nagios

Parameters:
  • hosts (str or list) – the hosts you want have metrics for
  • service (str) – The service metric you want to look up.
  • start (str, optional) – the starting date timestamp. All PNP4Nagios datestrings are allowed (see PNP4Nagios documentation under timeranges for details)
  • end (str, optional) – the ending date timestamp, same as start date
  • view (Integer, optional) – limits the time range to the time period specified in the PNP4Nagios config (for details see PNP4Nagios documentation under timeranges).
  • create_multiindex (bool, optional) – split the metrics names and create a hierarchical Index.
Returns:

a pandas DataFrame with the requested Data from PNP4Nagios

Prometheus

coming soon!