MonitoringReporter

This class is used to insert data to a db (currently elasticsearch). It uses an internal list which is used to keep messages in the memory. addRecord is used to insert messages to the internal queue. commit is used to insert the acumulated messages to elasticsearch. It provides two failover mechanism: 1.) If the database is not available, the data will be kept in the memory. 2.) If a MQ is available, we store the messages in MQ service.

Note: In order to not send too many rows to the db we use __maxRecordsInABundle.

Configuration Parameters:

If the section /Resources/MQServices exists in the CS, it’s assumed that a MQ service is available, if the MQ is not working a failover will be performed.

class DIRAC.MonitoringSystem.Client.MonitoringReporter.MonitoringReporter(monitoringType='', failoverQueueName='dirac.monitoring')

Bases: object

class MonitoringReporter

This class is used to interact with the ES DB, using a MQ as a failover mechanism.

Parameters:
  • __maxRecordsInABundle (int) – limit the number of records to be inserted to the db.

  • __documentLock (threading.RLock) – is used to lock the local store when it is being modified.

  • __documents (list) – contains the records which will be inserted to the db.

  • __monitoringType (str) – type of the records which will be inserted to the db. For example: WMSHistory.

  • __failoverQueueName (str) – the name of the messaging queue. For example: /queue/dirac.certification

__init__(monitoringType='', failoverQueueName='dirac.monitoring')
addRecord(rec)

It inserts the record to the list

Parameters:

rec (dict) – it contains a key/value pair.

commit()

It inserts the accumulated data to the db. In case of failure it keeps in memory/MQ

processRecords()

It consumes all messages from the MQ (these are failover messages). In case of failure, the messages will be inserted to the MQ again.

publishRecords(records, mqProducer=None)

send data to the MQ. If the mqProducer instance is provided, it will be used for publishing the data to MQ.

Parameters:
  • records (list) – contains a list of key/value pairs (dictionaries)

  • mqProducer (object) – We can provide the instance of a producer, which will be used to publish the data