def export(self, name, columns, points):
        """Write the points to the ES server."""
        logger.debug("Export {} stats to ElasticSearch".format(name))

        # Create DB input
        # https://elasticsearch-py.readthedocs.io/en/master/helpers.html
        actions = []
        for c, p in zip(columns, points):
            dtnow = datetime.utcnow()
            action = {
                "_index": self.index,
                "_id": '{}.{}'.format(name,c),
                "_type": "glances",
                "_source": {
                    "plugin": name,
                    "metric": c,
                    "value": str(p),
                    "timestamp": dtnow.isoformat('T')
                }
            }
            logger.debug("Exporting the following object to elasticsearch: {}".format(action))
            actions.append(action)

        # Write input to the ES index
        try:
            helpers.bulk(self.client, actions)
        except Exception as e:
            logger.error("Cannot export {} stats to ElasticSearch ({})".format(name, e))
def export ( self , name , columns , points ) : logger . debug ( "Export {} stats to ElasticSearch" . format ( name ) ) actions = [ ] for c , p in zip ( columns , points ) : dtnow = datetime . utcnow ( ) action = { "_index" : self . index , "_id" : '{}.{}' . format ( name , c ) , "_type" : "glances" , "_source" : { "plugin" : name , "metric" : c , "value" : str ( p ) , "timestamp" : dtnow . isoformat ( 'T' ) } } logger . debug ( "Exporting the following object to elasticsearch: {}" . format ( action ) ) actions . append ( action ) try : helpers . bulk ( self . client , actions ) except Exception as e : logger . error ( "Cannot export {} stats to ElasticSearch ({})" . format ( name , e ) )
Write the points to the ES server.